String Manipulation

Discuss RoboTask here
Post Reply
millsey
Posts: 16
Joined: Tue Jan 25, 2005 12:32 pm
Location: United Kingdom

String Manipulation

Post by millsey »

Are there any commends that let us get part of a text variable into another - for example we are pulling the telephone records from a switchboard, they always arrive in format "dd/mm/yyyy hh/mm/ss", we then insert them into a database.
 
To make reports earier on theat data it would be very useful to get the "hh" part of the string into another variable and insert that into the databse also. Is there any way within Robotask? We have just installed 2.3 also is there any changelog or pinformation on what has been added/fixed??
Thanks
Brian
 
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

String Manipulation

Post by Oleg »

You can easily cut any part from string by using BASIC functions Left and Rignt.
Left(string,n) - retirns n characters from left side of the string
Right(string,n) - returns n characters from right side ot the string

In order to extract "hh" part from your string you can do this:
left(right("{YourString}",8),2)

See example below. You must have Basic plugin installed for normal work of this task. Download it here.

;**********************
;* RoboTask Task file *
;* Do not edit!       *
;**********************

[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1171663995
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task111"
Hide=INTEGER|0
ID=INTEGER|916430052
Name=STRING|"Extract Hours"
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3

[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER

[Actions\Action1]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""FULL_DT"" with value ""23/11/2005 09/21/25"""
Params=FOLDER

[Actions\Action1\Params]
expand=STRING|"0"
varname=STRING|"FULL_DT"
varvalue=STRING|"23/11/2005 09/21/25"

[Actions\Action2]
ActionID=STRING|"BASIC_EVALUATE"
Enabled=INTEGER|-1
Name=STRING|"Evaluate"
Params=FOLDER

[Actions\Action2\Params]
expression=STRING|"left(right(""{Full_dt}"",8),2)"
variable=STRING|"HH"

[Actions\Action3]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{hh}"""
Params=FOLDER

[Actions\Action3\Params]
icon=STRING|"1"
msg0=STRING|"{hh}"
msgcount=STRING|"1"
playsound=STRING|"0"
showmessage=STRING|"1"

[Actions\Action4]
ActionID=STRING|"A_VARIABLES_REMOVE"
Enabled=INTEGER|-1
Name=STRING|"Remove variable ""HH"""
Params=FOLDER

[Actions\Action4\Params]
varname=STRING|"HH"

[Actions\Action5]
ActionID=STRING|"A_VARIABLES_REMOVE"
Enabled=INTEGER|-1
Name=STRING|"Remove variable ""FULL_DT"""
Params=FOLDER

[Actions\Action5\Params]
varname=STRING|"FULL_DT"
millsey
Posts: 16
Joined: Tue Jan 25, 2005 12:32 pm
Location: United Kingdom

String Manipulation

Post by millsey »

Oleg,
Many thanks for this, I found another way by delimiting the string with / and : and <space> as the delimiters which is probably a little faster than using BASIC. I will use this technique for other things in the future.
Looking at this method, there is probably lots that can be done that is not obvious when just lookig through the list of available actions.
Brian
 
 
 
Last edited by millsey on Wed Nov 23, 2005 4:35 am, edited 1 time in total.
Oleg
Site Admin
Posts: 3014
Joined: Thu Jan 01, 1970 1:00 am
Contact:

String Manipulation

Post by Oleg »

Very well . You have solved problem by another way.
I simply forgot about Delimited Variable action.
Post Reply