Announcement
Collapse
No announcement yet.
Trying to Create Variable
Collapse
X
-
Originally posted by tenholde View PostAny variable I intend to use in a script I create at startup instead of in each script
Code:'Setup Global Variable if needed Dim Errst Errst = hs.CreateVar('Foo') If Errst = "" then If Debug Then hs.WriteLog("MyTestScript", "DEBUG: Created Global Variable Foo") End If
But doing this means that your script is completely self contained, that has value to me....
Paul
Leave a comment:
-
Guest repliedOriginally posted by BME View PostI'm not very familiar with PHP, but more so other languages...
Could it be that the catch isn't triggered because it "only" gives a warning?
And that only the first line after the catch actually belongs to the catch, as you are not using brackets (try { something } catch { something }.
The Save is called as the next line after the catch - and that throws an error (which is not catched).
This code is typical Visual Basic, not PHP. It is not just the first line after the "catch" that is run, it is all the code between the "catch" and the "end try".
I also create all my globals in a startup script file, so that I do not have to deal with it later.
Leave a comment:
-
Any variable I intend to use in a script I create at startup instead of in each script
Leave a comment:
-
I've experienced the same issue. I now create all varialbles that I use in scripts in my Startup.vb script.
- Likes 2
Leave a comment:
-
I'm not very familiar with PHP, but more so other languages...
Could it be that the catch isn't triggered because it "only" gives a warning?
And that only the first line after the catch actually belongs to the catch, as you are not using brackets (try { something } catch { something }.
The Save is called as the next line after the catch - and that throws an error (which is not catched).
Leave a comment:
-
It seems you are trying to get the global variable LRPT, which doesn't exist. Have you created this one elsewhere?
I believe you need to create a global variable using hs.CreateVar, or within the HS GUI
Edit: Just realized that is what you are trying to do within the catch...
Leave a comment:
-
This is the error I am getting:
Aug-05 6:47:20 PM Error A call was made to save a global variable (LRPT) but that global variable has not been defined. Aug-05 6:47:20 PM PT 0 Aug-05 6:47:20 PM LR GetVar Error Aug-05 6:47:20 PM Warning A call was made to retrieve a global variable (LRPT) but that global variable has not been defined.
Leave a comment:
-
I want to store a decimal to PT.
I’ve tried Dim PT as single but will try object.
Leave a comment:
-
Trying to Create Variable
I'm using this code and the Catch never evaluates. Any suggestions?
PHP Code:Try
PT = hs.GetVar("LRPT")
hs.WriteLog("LR", "GetVar Error")
Catch ex As Exception
hs.CreateVar("LRPT")
hs.SaveVar("LRPT", 0)
hs.WriteLog("LR", "Exception" & ex.ToString)
End Try
The error I am getting is that LRPT is not defined
I am trying to create a global variable and would appreciate any help.Tags: None
Leave a comment: