Get Variable using RoboTask.App object

Discuss RoboTask here
Post Reply
IanJ
Posts: 4
Joined: Tue Apr 15, 2008 2:54 am

Get Variable using RoboTask.App object

Post 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.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Get Variable using RoboTask.App object

Post 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}")
IanJ
Posts: 4
Joined: Tue Apr 15, 2008 2:54 am

Get Variable using RoboTask.App object

Post 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.
 
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

Get Variable using RoboTask.App object

Post 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"
Post Reply