Populate Memo Field with text file

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
titon
Newbie
Posts: 3
Joined: Wed Sep 23, 2009 8:35 pm

Populate Memo Field with text file

Post by titon » Wed Sep 23, 2009 8:42 pm

Hi,

We have been using Macroscheduler for some time, and it has been a great cost savings. We are now tasked to do something we haven't done before, and not sure how to do it. So hopefully someone can share some insight.

Here is the background on the current script we have. Our script interacts with a web based applications, and fills the necessary fields with information from a CSV file and submits the information. The company doesn't offer API, so we use Macroscheduler to perform the tasks. The script runs continously till the CSV file is complete.

Now we are required to input a significant amount of "text" into a memo field in the browser. Since we are currently using a CSV file, adding paragraphs of text to the CSV will be overwhelming.

Ideally, we would be able to tell MacroScheduler to pick up the text from a static text file.

Can that be done? If so.. how?

Any help or suggestions would greatly be appreciated.

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Sep 23, 2009 9:59 pm

Ideally, we would be able to tell MacroScheduler to pick up the text from a static text file.
Exactly. Yes use a text file.

Look into ReadFile> if your text to be written is an entire file or ReadLn> if you are going to read then write specific lines of a text file. Either way you will be assigning the text from the file to a variable. Once you have the text assigned to a variable send the variable value to the memo field probably using the same techniques you currently use to put the csv data into the edit field.

You don't mention how you are currently doing the csv to edit field but you could use the Send> function or you might try putting the text to the clipboard using PutClipBoard> then pasting the clipboard data into the memo field using:

Press ctrl
Send>v
Release ctrl

In either case make sure your window and memo field have focus.

titon
Newbie
Posts: 3
Joined: Wed Sep 23, 2009 8:35 pm

Post by titon » Thu Oct 01, 2009 8:32 pm

Cool.

I looked at the ReadFile command, and it seems pretty straigth forward, but I can't seem to get it to work.. maybe I am not seeing something.

Form what I understand, ReadFile syntax is this ReadFile>(textfile),(variablename).

So based on that, I wrote this little script:

ReadFile>c:\mysample.txt,myText
Message>myText

It runs.. and the message box comes out and says, "myText", versus the content of the text file.

I copied and pasted the "c:\mysample.txt", and the file does open. So I know the file name and path is right.

So what am I doing wrong here? Why is "myText" variable, not receiving the content of the text file?

I use the message a lot to test my variables.. so I know it should show the content.

Any insight woudl be great.

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

Post by Marcus Tettmar » Thu Oct 01, 2009 8:42 pm

Remove any trailing spaces and change Message to MessageModal just so you can be sure you see it.

Copy and paste this code in:

Code: Select all

ReadFile>c:\mysample.txt,myText
MessageModal>myText
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

titon
Newbie
Posts: 3
Joined: Wed Sep 23, 2009 8:35 pm

Post by titon » Thu Oct 01, 2009 9:58 pm

Ok.. this makes absolutely no sense.. it works now.

Not sure what I did.. but here is what I use to read the txt file, send a message for verification, and then populate a memo field:

ReadFile>C:\mysample.txt,mytextfile
Message>mytextfile

Let>FieldValue=%mytextfile%

Thanks again for all the help.

- Ton

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Post by gdyvig » Fri Oct 02, 2009 2:21 am

It makes sense. My guess this is the reason why:
Remove any trailing spaces
If your original script contained "ReadFile>C:\mysample.txt,mytextfile " then the variable name would be "mytextfile ", not "mytextfile".

You may have unintentionally removed the extra space while editing which is why the script works now. The rule of thumb is never put extra spaces in your scripts unless they are meaningful.

Try your script both ways and see the difference.

Other syntax variations that can cause trouble:
"ReadFile>C:\mysample.txt, mytextfile"
"ReadFile>C:\mysample.txt ,mytextfile"
"ReadFile> C:\mysample.txt,mytextfile"

If you got the ReadFile correct, the Message statement could be wrong:

"Message>mytextfile "
rather than
"Message>mytextfile"

This syntax makes it obvious what the variable name is:
"Message>%mytextfile%

(But you can't use that trick in the ReadFile statement)



Gale

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

Post by Marcus Tettmar » Fri Oct 02, 2009 7:49 am

And if you LIKE spaces then look at the IGNORESPACES directive.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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