Discuss RoboTask here
kravtsov
Posts: 6 Joined: Thu Nov 10, 2016 7:09 am
Post
by kravtsov » Thu Nov 10, 2016 4:32 pm
How can i extract few variables from text?
I want to receive these variables as a result of parsing:
{surname}=Иванов
{firstname}=Иван
{middlename}=Иванович
{birthdate}=01.01.1990
{birthplace}=Нижний Новгород
{passport }=1
{passser}=1122
{passnum}=112233
{passdate}=03.02.2011
{passplace}=Нижний Новгород
{passorg}=ОУФМС России в Нижегородской области в Канавинском районе г. Нижнего Новгорода
{regRegion}=52
{regcity}=Нижний Новгород
{regstreet}=пр-т Ленина
{reghouse}=21
{regflat}=12
{email}=
test@test.com
{phone}=89161112233
Code: Select all
Hey there,
Someone just submitted your form on testformspree.com/. Here's what they had to say:
surname
Иванов
firstname
Иван
middlename
Иванович
birthdate
01.01.1990
birthplace
Нижний Новгород
passport
1
passser
1122
passnum
112233
passdate
03.02.2011
passplace
Нижний Новгород
passorg
ОУФМС России в Нижегородской области в Канавинском районе г. Нижнего Новгорода
regRegion
52
regcity
Нижний Новгород
regstreet
пр-т Ленина
reghouse
21
regflat
12
email
test@test.com
phone
89161112233
message
This form was submitted at 10:57 AM UTC - 10 November 2016.
You are receiving this because you confirmed this email address on Formspree. If you don't remember doing that, or no longer wish to receive these emails, please remove the form on testformspree.com/ or send an email to team@formspree.io.
Oleg
Site Admin
Posts: 3202 Joined: Thu Jan 01, 1970 1:00 am
Contact:
Post
by Oleg » Thu Nov 10, 2016 8:44 pm
For example see the task below
Save the text of the task to a file and use menu Task->Import to import the task into RoboTask.
One of algorithms.
You can the text from text file directly in the step #4 (
Text loop )
Code: Select all
;*****************************
;* RoboTask Task file
;* Do not edit in text editor!
;*****************************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|1040932817
Comment=STRINGLIST
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task155"
Hide=INTEGER|0
ID=INTEGER|1352064740
LogOnAsUser=INTEGER|1
Name=STRING|"parse text"
OnErrorTaskID=INTEGER|-1
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
UnicodeFormat=INTEGER|1
WriteGeneralLog=INTEGER|0
[Actions]
Action1=FOLDER
Action10=FOLDER
Action11=FOLDER
Action12=FOLDER
Action13=FOLDER
Action14=FOLDER
Action15=FOLDER
Action2=FOLDER
Action3=FOLDER
Action4=FOLDER
Action5=FOLDER
Action6=FOLDER
Action7=FOLDER
Action8=FOLDER
Action9=FOLDER
[Actions\Action1]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""TEXT"" with value ""Hey there,{EOL}Someone just submitted your form on..."""
Params=FOLDER
[Actions\Action1\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"TEXT"
varvalue=STRING|"Hey there,{EOL}Someone just submitted your form on testformspree.com/. Here's what they had to say:{EOL}surname {EOL}{EOL}Рванов{EOL}{EOL}firstname {EOL}{EOL}Рван {EOL}{EOL}middlename {EOL}{EOL}Рванович{EOL}{EOL}birthdate {EOL}{EOL}01.01.1990{EOL}{EOL}birthplace {EOL}{EOL}РќРёР¶РЅРёР№ РќРѕРІРіРѕСЂРѕРґ{EOL}{EOL}passport {EOL}{EOL}1{EOL}{EOL}passser {EOL}{EOL}1122{EOL}{EOL}passnum {EOL}{EOL}112233{EOL}{EOL}passdate {EOL}{EOL}03.02.2011{EOL}{EOL}passplace {EOL}{EOL}РќРёР¶РЅРёР№ РќРѕРІРіРѕСЂРѕРґ{EOL}{EOL}passorg {EOL}{EOL}ОУФМС Р РѕСЃСЃРёРё РІ Нижегородской области РІ Канавинском районе Рі. Нижнего РќРѕРІРіРѕСЂРѕРґР°{EOL}{EOL}regRegion {EOL}{EOL}52{EOL}{EOL}regcity {EOL}{EOL}РќРёР¶РЅРёР№ РќРѕРІРіРѕСЂРѕРґ{EOL}{EOL}regstreet {EOL}{EOL}РїСЂ-С‚ Ленина{EOL}{EOL}reghouse {EOL}{EOL}21{EOL}{EOL}regflat {EOL}{EOL}12{EOL}{EOL}email {EOL}{EOL}test@test.com{EOL}{EOL}phone {EOL}{EOL}89161112233{EOL}{EOL}message {EOL}{EOL}{EOL}{EOL}This form was submitted at 10:57 AM UTC - 10 November 2016.{EOL}You are receiving this because you confirmed this email address on Formspree. If you don't remember doing that, or no longer wish to receive these emails, please remove the form on testformspree.com/ or send an email to team@formspree.io."
[Actions\Action10]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER
[Actions\Action10\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"0"
type=STRING|"1"
value1=STRING|"{num}"
value2=STRING|"2"
[Actions\Action11]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""{VARNAME}"" with value ""{Line}"""
Params=FOLDER
[Actions\Action11\Params]
expand=STRING|"1"
varname=STRING|"{VARNAME}"
varvalue=STRING|"{Line}"
[Actions\Action12]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
[Actions\Action13]
ActionID=STRING|"A_VARIABLES_INCREMENT"
Enabled=INTEGER|-1
Name=STRING|"Increment variable ""num"""
Params=FOLDER
[Actions\Action13\Params]
incement=STRING|"1"
vaiable=STRING|"num"
[Actions\Action14]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
[Actions\Action15]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""surname = {surname}"""
Params=FOLDER
[Actions\Action15\Params]
icon=STRING|"1"
msg0=STRING|"surname = {surname}"
msg1=STRING|"firstname = {firstname} "
msg10=STRING|"passorg = {passorg}"
msg11=STRING|"regRegion = {regRegion}"
msg12=STRING|"regcity = {regcity}"
msg13=STRING|"regstreet = {regstreet}"
msg14=STRING|"reghouse = {reghouse}"
msg15=STRING|"regflat = {regflat}"
msg16=STRING|"email = {email}"
msg17=STRING|"phone = {phone}"
msg2=STRING|"middlename = {middlename}"
msg3=STRING|"birthdate = {birthdate}"
msg4=STRING|"birthplace = {birthplace}"
msg5=STRING|"passport = {passport}"
msg6=STRING|"passser = {passser}"
msg7=STRING|"passnum = {passnum}"
msg8=STRING|"passdate = {passdate}"
msg9=STRING|"passplace = {passplace}"
msgcount=STRING|"18"
playsound=STRING|"0"
showmessage=STRING|"1"
[Actions\Action2]
ActionID=STRING|"A_VARIABLES_CREATE"
Enabled=INTEGER|-1
Name=STRING|"Create local variable ""KEYWORDS"" with value ""surname,firstname,middlename,birthdate,birthplace,..."""
Params=FOLDER
[Actions\Action2\Params]
expand=STRING|"0"
varkind=STRING|"1"
varname=STRING|"KEYWORDS"
varvalue=STRING|"surname,firstname,middlename,birthdate,birthplace,passport,passser,passnum,passdate,passplace,passorg,regRegion,regcity,regstreet,reghouse,regflat,email,phone"
[Actions\Action3]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NUM"" with value ""5"""
Params=FOLDER
[Actions\Action3\Params]
expand=STRING|"0"
varname=STRING|"NUM"
varvalue=STRING|"5"
[Actions\Action4]
ActionID=STRING|"A_LOOP_TEXT"
Enabled=INTEGER|-1
Name=STRING|"Text Loop"
Params=FOLDER
[Actions\Action4\Params]
destvar=STRING|"LINE"
line0=STRING|"{Text}"
linecount=STRING|"1"
sourcetext=STRING|"1"
[Actions\Action5]
ActionID=STRING|"A_STR_TRIM"
Enabled=INTEGER|-1
Name=STRING|"STR Trim"
Params=FOLDER
[Actions\Action5\Params]
custom=STRING|"0"
eol=STRING|"1"
lead=STRING|"1"
source=STRING|"{Line}"
spaces=STRING|"1"
tabs=STRING|"1"
trailing=STRING|"1"
variable=STRING|"Line"
[Actions\Action6]
ActionID=STRING|"A_FLOW_IF"
Enabled=INTEGER|-1
Name=STRING|"If Then"
Params=FOLDER
[Actions\Action6\Params]
case=STRING|"0"
connection=STRING|"0"
count=STRING|"1"
operator=STRING|"6"
type=STRING|"0"
value1=STRING|"{Line}"
value2=STRING|"{KeyWords}"
[Actions\Action7]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""VARNAME"" with value ""{Line}"""
Params=FOLDER
[Actions\Action7\Params]
expand=STRING|"1"
varname=STRING|"VARNAME"
varvalue=STRING|"{Line}"
[Actions\Action8]
ActionID=STRING|"A_VARIABLES_SET"
Enabled=INTEGER|-1
Name=STRING|"Set variable ""NUM"" with value ""0"""
Params=FOLDER
[Actions\Action8\Params]
expand=STRING|"0"
varname=STRING|"NUM"
varvalue=STRING|"0"
[Actions\Action9]
ActionID=STRING|"A_FLOW_ENDIF"
Enabled=INTEGER|-1
Name=STRING|"End If"
Oleg Yershov
kravtsov
Posts: 6 Joined: Thu Nov 10, 2016 7:09 am
Post
by kravtsov » Fri Nov 11, 2016 9:57 am
WOW!!! Robotask is the magic program! Can you explain to me and others how this script works?
Oleg
Site Admin
Posts: 3202 Joined: Thu Jan 01, 1970 1:00 am
Contact:
Post
by Oleg » Fri Nov 11, 2016 10:35 am
The task reads each second line after keyword.
The each keyword is the name of variable
Find the keyword and reset the counter to 0 (variable num )
Line 0 - keyword. Also the name of variable
Line 1 - empty (skipped)
Line 2 - the value of variable
Other lines are skipped
The task contains only 15 steps. It is not too complex.
Oleg Yershov