parse data into multiple variables

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

macroman
Pro Scripter
Posts: 93
Joined: Mon Jun 02, 2014 5:32 am

Re: parse data into multiple variables

Post by macroman » Mon Oct 27, 2014 1:59 pm

Ok, what if after you grab the values in the text file, I update that text file with new data... will the loop grab the new data next time around? it doesn't seem to do it.....

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

Re: parse data into multiple variables

Post by Marcus Tettmar » Mon Oct 27, 2014 3:52 pm

What text file?

This macro is pulling data from a web page.

And - in this case - the web page is on mjtnet.com and that web page never changes.

So, of course, the data is always the same.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

macroman
Pro Scripter
Posts: 93
Joined: Mon Jun 02, 2014 5:32 am

Re: parse data into multiple variables

Post by macroman » Mon Oct 27, 2014 7:45 pm

And IF that file gets updated with new contents? And if that url gets changed dynamically every time it gets hit? Shouldn't the loop pick up new data the 2nd time around as well?

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

Re: parse data into multiple variables

Post by Marcus Tettmar » Mon Oct 27, 2014 8:42 pm

Yes. It will.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

macroman
Pro Scripter
Posts: 93
Joined: Mon Jun 02, 2014 5:32 am

Re: parse data into multiple variables

Post by macroman » Mon Oct 27, 2014 8:43 pm

I certainly promise you if you do a wait>60 and then go and change things in the text file/url.... on the next loop... it will not parse the new data you've just changed :)

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

Re: parse data into multiple variables

Post by Marcus Tettmar » Mon Oct 27, 2014 8:57 pm

I think perhaps your network/router is caching the request! Also depends on the web server. Our web server (as are many) is set up to cache static content and this is a static file.

Try adding some random parm or timestamp to the URL:

GetTime>theTime
HTTPRequest>http://www.mjtnet.com/demos/vals_exampl ... GET,,sVals

As you have promised me, I promise YOU - there is nothing wrong with the script itself!
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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

Re: parse data into multiple variables

Post by Marcus Tettmar » Mon Oct 27, 2014 9:02 pm

Here's a script which requests a page on our server which generates a random number. So it's dynamic. Different every time. I get different data every time. Works perfectly:

Code: Select all

Let>HTTP_SSL=1
Label>start
  HTTPRequest>https://www.mjtnet.com/demos/random.htm,,GET,,data
  MessageModal>data
  Wait>2
Goto>start
As this is dynamic it shouldn't get cached. But if you don't see different data each time then your system/network is caching the request, so try the timestamp thing:

Code: Select all

Let>HTTP_SSL=1
Label>start
  GetTime>time
  HTTPRequest>https://www.mjtnet.com/demos/random.htm?%time%,,GET,,data
  MessageModal>data
  Wait>2
Goto>start
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

macroman
Pro Scripter
Posts: 93
Joined: Mon Jun 02, 2014 5:32 am

Re: parse data into multiple variables

Post by macroman » Mon Oct 27, 2014 9:46 pm

Timestamp does not work... data still the same... but if I stop the loop and restart, then data changes....

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

Re: parse data into multiple variables

Post by Marcus Tettmar » Mon Oct 27, 2014 10:43 pm

My example scripts work for me!

Have you tried my script above?

I've written dozens, no hundreds, of scripts over the years which loop over an http request and never seen it get "stuck". Something tells me there's a missing piece of the puzzle here.

I asked if you could share your script and you showed us a version that uses a static example page on mjtnet.com. That can't really be your script can it? There has to be something different between what I've shown you above and what you doing. Has to be.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

macroman
Pro Scripter
Posts: 93
Joined: Mon Jun 02, 2014 5:32 am

Re: parse data into multiple variables

Post by macroman » Tue Oct 28, 2014 1:09 am

I'm sure you've wrote tons of scripts and lines never doubted you, but perhaps something is missing...

My url link has nothing but the following in it:

Code: Select all

<?php

echo "data=".rand(1,999999); 

?>

I recently tried to do this on different machines as well, it does not appear to be my systems... I know the code looks correct and the idea is correct.... but when you're actually testing it... it's not responding properly....

When testing on other development machines, I got hit with license code error, can you please remove my old machines as I am only developing on 1 machine.

Thank you.

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

Re: parse data into multiple variables

Post by JRL » Tue Oct 28, 2014 5:15 am

Macroman,

Marcus' scripts are working fine for me also (after I finally got OpenSSL installed). Have you tested these straight off the thread?

HttpRequest> sets a variable each time it is run. If the value of that variable does not change then HttpRequest> has polled the internet and retrieved the same data. As Marcus said, it sounds like there is a cache somewhere that your HttpRequest> call is retrieving. HttpRequest> can't control what happens when it polls the internet, that control is in settings on your computer or on your proxie server or on your DNS server or on your ISP's servers or....

I have a sample of my own for you to try. This takes the time and date from the Macro Scheduler main Forum page. It has a 61 second wait between loops so you will see the time change every 61 seconds.

Code: Select all

Let>HTTP_SSL=1
Message>Connecting...
Label>start
Let>sVals={""}

HTTPRequest>https://www.mjtnet.com/forum/index.php,,GET,,sVals
Separate>sVals,<p class="right">It is currently ,FD1
Separate>FD1_2,</p>,FoundDate

SetControlText>Macro Scheduler Message,TMemo,1,%FoundDate_1%%crlf%%crlf%%crlf%Seconds until refresh = 0
Let>kk=61
Repeat>kk
  Sub>kk,1
  SetControlText>Macro Scheduler Message,TMemo,1,%FoundDate_1%%crlf%%crlf%%crlf%Seconds until refresh = %kk%
  Wait>1
Until>kk=0
SetControlText>Macro Scheduler Message,TMemo,1,%FoundDate_1%%crlf%%crlf%%crlf%Seconds until refresh = %kk%%crlf%Reconnecting...
Goto>start

macroman
Pro Scripter
Posts: 93
Joined: Mon Jun 02, 2014 5:32 am

Re: parse data into multiple variables

Post by macroman » Tue Oct 28, 2014 9:33 pm

I am not using https, and it is unfortunate that I can't show my url because everything is localhost... but if I were to stop the macro and then re-run it, I get the new DATA just fine.... If I were to open up firefox and keep banging the url the data value would also changed...

I think I'm about to give up on this and find an alternative method :)

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

Re: parse data into multiple variables

Post by JRL » Tue Oct 28, 2014 9:49 pm

Two weeks ago my car quit. Would not start. Tried cleaning battery posts, Checked the connection to the starter. Tried jump starting. Nothing worked. Had the car towed to my local garage. Monday morning the mechanic walked out and the car started right up. They kept it four days trying to figure out what might be wrong but found nothing. Hard to diagnose a problem when its not there.

I'm feeling like my mechanic must have felt. I'd like to be helpful but I don't know how to make this fail.

I did have one thought on re-reading the entire thread. I wonder what would happen if instead of looping in your script you write the script to run straight through one time then end. Then write a second script that runs the Macro> function in a loop. Something like:

Code: Select all

Label>start
Macro>Path and file name of the httprequest script.
Wait>5
Goto>start
In this way you'd be running the script and closing it then running the script and closing it....

User avatar
Grovkillen
Automation Wizard
Posts: 1132
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: parse data into multiple variables

Post by Grovkillen » Wed Oct 29, 2014 11:39 am

JRL (off topic), sounds like your car has a problem with moisture. When something like that happens, especially in the fall, so moisture tends to be the problem. Does the car rest for a while the water condense and the car is working again.
Let>ME=%Script%

Running: 15.0.27
version history

macroman
Pro Scripter
Posts: 93
Joined: Mon Jun 02, 2014 5:32 am

Re: parse data into multiple variables

Post by macroman » Wed Oct 29, 2014 12:16 pm

Thanks everyone... I pull http all over my script, just this initial one with nested variables from an URL doesn't get updated... I ended up having another macro to check if the first macro is running, if not start it :)....

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