Results 1 to 7 of 7

Thread: get a value from the registry and concatenate with other strings

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    5

    Unhappy

    Hi,

    I try to retrieve the path of my java interpreter from the window registry and then concatenate this path with some other strings so as to run my java program. I always loss the second part of my string. This is my code:

    ' get the path from registry
    Dim javaBuffer as String

    javaBuffer = GetStringValue("HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\1.2", "JavaHome")

    javaBuffer = Trim(javaBuffer)
    tempvar = javaBuffer + "\bin\java -classpath..."

    'run my java program
    Shell tempvar (+ some other arguments)

    I notice that tempvar does not contain "\bin\java..." at all even if I do the simple string concatenation as shown in the code above. The value obtained from the registy, though, is correct. Any ideas?

    maria.

  2. #2
    Addicted Member
    Join Date
    Feb 2000
    Posts
    224
    use

    tempvar = javaBuffer & "\bin\java -classpath.."

    Instead of...
    tempvar = javaBuffer + "\bin\java -classpath.."
    If you can't pronounce my name, call me GURU

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    5

    get a value from the registry and concatenate with other strings

    Hi,

    I try your suggestion but it doesn't seem to work. Any more ideas?

    Also, I found something weird happening:
    if I do:
    Dim tempvar as String
    tempvar = javaBuffer + "\bin\java" 'it doesn't concatenate

    but if I do:
    Dim tempvar as String
    tempvar = "\bin\java..." + javaBuffer ' it does concatenate

    I also try the above code using '&' instead. Same results found.

    maria.

  4. #4
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Shoud work with both + and & but you should use & to avoid numeric addition

    What errors do you get? Do you get the correct definitions of both javabuffer and tempvar?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  5. #5

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    5
    Hi again,

    javaBuffer and tempvar are both declared as Strings and javaBuffer seems to have the right value. Please help.

    I also used '&'

    maria.
    maria

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Hmm, this is getting hard without knowing any code, could you explain what's wrong then? or could you provide more code since what you showed, seems to work correctly
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7

    Thread Starter
    New Member
    Join Date
    Jul 2000
    Posts
    5
    hi again,
    this is all of my code:

    Sub SaveAsHtml()
    '
    ' SaveAsHtml Macro
    ' Macro recorded 7/5/00 by mtsang
    '
    Dim pathBuffer As String
    Dim javaBuffer As String

    Randomize
    Filename = "c:\temp\RBHTML_" + CStr(Math.Round(Math.Rnd * 10000000000#, 0)) + ".htm"

    If Application.Name = "Microsoft Word" Then
    ActiveDocument.SaveAs Filename, FileFormat:=wdFormatHTML, _
    LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
    :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
    SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
    False

    ElseIf Application.Name = "Microsoft Excel" Then
    ActiveWorkbook.SaveAs Filename, FileFormat:=xlHtml, _
    ReadOnlyRecommended:=False, CreateBackup:=False

    ElseIf Application.Name = "Microsoft PowerPoint" Then
    ActivePresentation.SaveAs Filename, FileFormat:=ppSaveAsHTML, EmbedTrueTypeFonts:=msoFalse

    Else
    MsgBox "Unrecognized Office Application: " + Application.Name
    End If

    ' the value represents the path of the client.properties file
    pathBuffer = GetStringValue("HKEY_LOCAL_MACHINE\Software\relBUILDER", "propertiesFile")
    pathBuffer = Trim(pathBuffer)

    ' debug
    MsgBox "pathBuffer: " + pathBuffer

    ' the value represents the path of the java interpreter
    javaBuffer = GetStringValue("HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\1.2", "JavaHome")
    javaBuffer = Trim(javaBuffer)

    'debug
    MsgBox "javaBuffer: " + javaBuffer

    '''''''''''''''''''''''''''''''''''''''''''''''''
    ' CAN'T CONCATENATE 2 STRINGS!!!
    var3 = "\bin\java -classpath c:\jars\relbuilder.jar;c:\jars\relbuilder_be.jar;c:\development\relbuilder\officeintegration\classes com.deltacap.relbuilder.client.plugin.Office2000Plugin

    'var4 = javaBuffer & var3 'this doesn't works!!
    ' var4 = var3 + javaBuffer 'this works

    'Shell javaBuffer + var3 + Filename + " " + pathBuffer, vbNormalFocus


    End Sub

    I got a "file not found" error when I run the shell command because it is ignoring "var3 + Filename...."

    maria.
    maria

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width