Support Forums
How to Access a Variable that is in Page Code elsewhere in an Expression?

Hello everyone!

I have a noob question here. I am experimenting around with using the date selector function inside the page source code. I have got that working to the point that I can display the UTC value I want from the date selector function. This is great, but now I need to use that number elsewhere in the application.

How do I get access to this variable? I tried using the scope function, but I couldn't get that to work (I could very well be using it wrong). Is there a way I can reference or store or output this variable from the page code?

For reference, I am using a steady state application, and the page code uses simple script blocks I pulled from the documentation. Here is my sample code:

[
Title = "OverviewLabel";
Color = "<FFFFFFFF>";
Shared StartDate;
ShowCalendar;
]

Main [
Return(Self);
If !Valid(StartDate);
[
StartDate = Today() * 86400;
]
If GUIButton(100, 200, 200, 150,
1, 1, 1, 1,
1, 0, 0, 1,
0, 68, 2, 0,
7, 15, 8, 0,
0, 0,
\GetPhrase("ChangeLabel"smile, \GetPhrase("ChangeLabel"smile, _DialogFont,
2, 1, 0);
[
ShowCalendar = 1;
]
\DateSelector(ShowCalendar, 200, 200, &StartDate);
ZText(400, 100, StartDate, 3, 0);
]

The ZText is just filler to for me to see that the DateSelector function is working the way I expect. I need that StartDate variable.

Also (this may be unrelated) but when I tried to open the properties of the created widget on the page from this code, I got this error: (You cannot view the properties of this graphic as the source code is no longer compliant.)

Thank you in advance!

Hello everyone! I have a noob question here. I am experimenting around with using the date selector function inside the page source code. I have got that working to the point that I can display the UTC value I want from the date selector function. This is great, but now I need to use that number elsewhere in the application. How do I get access to this variable? I tried using the scope function, but I couldn&#039;t get that to work (I could very well be using it wrong). Is there a way I can reference or store or output this variable from the page code? For reference, I am using a steady state application, and the page code uses simple script blocks I pulled from the documentation. Here is my sample code: [ Title = &quot;OverviewLabel&quot;; Color = &quot;&lt;FFFFFFFF&gt;&quot;; Shared StartDate; ShowCalendar; ] Main [ Return(Self); If !Valid(StartDate); [ StartDate = Today() * 86400; ] If GUIButton(100, 200, 200, 150, 1, 1, 1, 1, 1, 0, 0, 1, 0, 68, 2, 0, 7, 15, 8, 0, 0, 0, \GetPhrase(&quot;ChangeLabel&quot;), \GetPhrase(&quot;ChangeLabel&quot;), \_DialogFont, 2, 1, 0); [ ShowCalendar = 1; ] \DateSelector(ShowCalendar, 200, 200, &amp;StartDate); ZText(400, 100, StartDate, 3, 0); ] The ZText is just filler to for me to see that the DateSelector function is working the way I expect. I need that StartDate variable. Also (this may be unrelated) but when I tried to open the properties of the created widget on the page from this code, I got this error: (You cannot view the properties of this graphic as the source code is no longer compliant.) Thank you in advance!

Try this: Create a normal tag e.g. FullTagName. then in script use Scope(\VTSDB, "FullTagName" ).Set(StartDate); to write the value to a FullTagName

Try this: Create a normal tag e.g. FullTagName. then in script use Scope(\VTSDB, &quot;FullTagName&quot; ).Set(StartDate); to write the value to a FullTagName

That worked! I will admit I was skeptical because the Set function is listed as scripting mode only, so I was worried it wouldn't work because I am running in real time. Thank you

That worked! I will admit I was skeptical because the Set function is listed as scripting mode only, so I was worried it wouldn&#039;t work because I am running in real time. Thank you
39
2
2
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft