Extracting text from a file?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
rullbandspelare
Pro Scripter
Posts: 149
Joined: Tue Mar 23, 2004 9:11 pm

Extracting text from a file?

Post by rullbandspelare » Tue Mar 23, 2004 9:22 pm

Hi!
I have a text file, like this:
text.txt: rullbandspelare,det,e,jag,1234
(I have some freedom in the way this file will look)

I whant this text to fill a form that always is the same.
So the result in my case if i use key pressing would be.
paste rullbandspelare
tab
paste det
tab
paste jag
etc

How can i do this in Macro Scheduler? Any input on where to start would make me glad.

Thanks!
/tomas

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Mar 23, 2004 11:22 pm

No time to help right now but I think the sensible solution will be SEPARATE.

From the HELP file:
Separate>list,delimiter,returnvar

Separate takes a list, a delimiter and returns the elements of the list. The command returns a number of variables, one for each list element, each with the suffix "_n" where n is the index of the element in the list. The variable names are determined by the name given in returnvar. e.g. returnvar_1, returnvar_2, etc. Also returned is the number of elements in the list, in returnvar_count.

Abbreviation : SEP

Example

GetFileList>c:\temp\*.*,files
Separate>files,;,file_names
MessageModal>Num Files: %file_names_count%

Let>k=0
Repeat>k
Let>k=k+1
Message>file_names_%k%
Until>k,file_names_count
Use TABs vs. Messages in the Example file, use comma vs. semicolon as delimiter.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Lumumba

Post by Lumumba » Fri Mar 26, 2004 9:57 pm

Another option, cause ...
(I have some freedom in the way this file will look)
Use an INI file as the data source (so you would be able to update that file if necessary)

text.ini

[DATA]
1=rullbandspelare
2=det
3=e
4=jag
5=1234

-----

Let>KeyNo=0

INILoop:
Add>KeyNo,1
ReadIniFile>c:\text.ini,DATA,%KeyNo%,KeyValue
SetFocus>MyWebsite*
Send>%KeyValue%
Press TAB
If>KeyNo=5, Done, INILoop

Label>Done
Exit

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts