Page 1 of 1

Get Variable using RoboTask.App object

Posted: Tue Apr 15, 2008 7:47 am
by IanJ
Is it possible to get the contents of a variable from the robotask.app object in BASIC.  You can create them using AddUserVariable and delete them with DelUserVariable but I cannot see a way of reading them.  Thanks.

Get Variable using RoboTask.App object

Posted: Tue Apr 15, 2008 8:14 am
by Oleg
Yes of course. It is RoboTaskApp.ExpandText() method.

In order to expand variable only as a string:
RoboTaskApp.ExpandText("{MyVar}")

Or whole expression:
RoboTaskApp.ExpandText("Value of my variable is {MyVar}")

Get Variable using RoboTask.App object

Posted: Wed Apr 16, 2008 12:46 am
by IanJ
Hi Oleg.  I am having a problem accessing the variable in my script.  As an example I have created a variable in my task called VAR_TEMP.
I have written a script to show the value of the variable in a messagebox ...
Sub Main
  Dim strTemp As String
  Dim oApp As New RoboTask.App
  oApp=strTemp=RoboTask.ExpandText("{VAR_TEMP}")
  MsgBox(strTemp)
End Sub
The code does not work and throws an error.  Should I somehow be referencing the active Robotask app in my code?  I.e. is there some way of assigning the current robotask instance to my variable oApp?
Thanks.
 

Get Variable using RoboTask.App object

Posted: Wed Apr 16, 2008 1:46 am
by Oleg
See my text more carefully. I use RoboTaskApp object instead of RoboTask.App
RoboTaskApp is predefined object and you don't need to create anything

See correct text:

Sub Main
   Dim strTemp As String

   strTemp = RoboTaskApp.ExpandText("{VAR_TEMP}")
   MsgBox(strTemp)
End Sub


BTW: if you want to create new RoboTaskApp object you have to do the following:

Sub Main
   Dim strTemp As String
   Dim obj As Object

   Set obj = New RoboTask.App
   strTemp = obj.ExpandText("{VAR_TEMP}")
   MsgBox(strTemp)
End Sub

Also see help file or online help the topic "Actions | Basic | RoboTaskApp object"