Reading Variables from a file

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
nevetS
Newbie
Posts: 1
Joined: Sun Jun 18, 2006 8:11 am
Contact:

Reading Variables from a file

Post by nevetS » Sun Jun 18, 2006 8:17 am

One of the primary reasons I'm looking at buying a tool like this is to automate a lot of webmaster duties - for instance webshots of pages in my directories, verifying links before publishing pages, etc.

I'd like to be able to read a set of values from a file - I see that there's an INI file read function, but I was hoping for something more along the lines of a CSV or XML format.

Is this something that's supported easily? Or is there a code snippet that would work well for this request?

A brief perusal through the forums came up empty, but then again, I'm really new so maybe I just missed it.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Sun Jun 18, 2006 8:33 am

To read from CSV use the ReadLn and Separate Functions. See examples in help file. ReadLn reads a line from the file, Separate will explode the fields into variables given the delimiter (comma in the case of CSV). To read from Excel use DDE or VBScript. Many examples on these forums (Search for Excel). There's also a sample script showing how to read data from Excel that comes with Macro Scheduler.

Hope this helps.
Last edited by Marcus Tettmar on Sun Jun 18, 2006 2:43 pm, edited 1 time in total.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Sun Jun 18, 2006 2:39 pm

.csv, comma delimited, is a bit tricky since the Macro Scheduler commands are also comma delimited, but Separate works well if you define the delimiter first like this:

Let>datafile=c:\test\mydata.csv
Let>delim=,
IfFileExists>%datafile%,next,finish
Label>next
Let>k=1
Label>start
ReadLn>%datafile%,k,line
If>line=##EOF##,finish
Separate>line,delim,data
MessageModal>Data Elements=%data_count% %data_1% %data_2% %data_3% %data_4%
Let>k=k+1
Goto>start

Label>finish

clickfast
Pro Scripter
Posts: 58
Joined: Wed May 23, 2007 12:04 am

Parsing XML

Post by clickfast » Wed May 23, 2007 3:14 pm

I think his question about .CSV/Excel was answered... but WHAT ABOUT XML??? That was the other part of his initial question above??


Anyone have any ideas?

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