Digital Workshop

Welcome to the Digital Workshop Message Boards
It is currently May 21st, 2024, 6:09 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: InternetPostData
PostPosted: January 25th, 2006, 3:27 pm 
Offline

Joined: January 10th, 2005, 11:08 am
Posts: 63
Location: Birmingham, United Kingdom
Opus: All between ver Pro XE 4.5 and Ver 9.62
OS: Windows XP Pro SP3
System: Intel Core2 Duo 2.67Ghz, Matrox Millennium G550 dual head graphics card
As one who has only just got his head around this function maybe I can be of assistance with the InternetPostData function.

First a bit of background. We had a requirement to select a students record from a database on one of our central servers. This was okay when we used CD based publications as we could use the database tab and create a DNS to handle the data transfer. However when we went to web publications this did not work. Thus we wrote a set of ASP pages to act as interpreters between the publication and the database. We could not work out how to use the InternetPostData action to actually post and retrieve data and thus we opted to use the PostWebData action selected from the Actions Organiser.
The action sent 2 items of data out as a query and then received 23 items of data back from the database.

To do the same thing in script first you need to point at the interpreter thus:

var url="http://www.DigitalWorkshop.com/datahere/find.asp"

next you need to set up an object that will contain the query data:

var student=new Object()

now populate the object with the fields to search for in the form:
object.database field to search for="data"

student.STUDENT_ID="SMITH"
student.COURSE_ID="Woodwork_Beginners"


now you need somewhere to store the data when it comes back and this is in a publication text variable, which I have called RETURNED_DATA. Then you need to issue the command that does the job:

RETURNED_DATA=InternetPostData(url,student,true)

The final true/false will send the returned data into either an object (true) or a text object (false).
This is useful as if you want to check what is coming back set it this to false and put a text object on the page and insert the variable RETURNED_DATA and this will display the whole data returned (if you get anything back!).
If you set this to true it will populate the object RETURNED_DATA with all the data fields returned (or any errors generated by the interpreter). This data can then be retrieved from the object and placed into normal variables using

VARIABLE=Object.FIELD_NAME

STUDENT_NAME=RETURNED_DATA.STUDENT_NAME
STUDENT_JOB=RETURNED_DATA.STUDENT_JOB

etc, etc

If you want to view a piece of this data directly on the screen, insert a variable/expression into a text object and in the expression area type the object name and the field name, i.e. RETURNED_DATA.STUDENT_NAME

The other useful utility here is the Debug.trace function. I have added a few lines to the bottom of the script which capture the incoming data and display them in the debug window after the script has been run.

Debug.trace("STUDENT_JOB: " + STUDENT_JOB +"\n")
Debug.trace("STUDENT_NAME: " + STUDENT_NAME +"\n")


Hope this is helpful to those who, like me, are struggling with this.

My most grateful thanks must go to eomc40, whoever he/she may be, without whom I would not have been able to grasp this function.

Andy Thompson


For this message Andrew Thompson has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject:
PostPosted: July 19th, 2009, 9:10 am 
Offline

Joined: July 12th, 2009, 10:33 am
Posts: 124
Hi

Just wondering if I've done something stoopid. I have found that I have to use the Opus PostWebData action to check for an internet connection rather than the script below.

I used a CASE function on the WebResponse variable to continue if the account was found and try again if it was not found. I then set the DEFAULT in the CASE to third action suggesting there wasn't a connection present.

With the script in place, but no connection, it just hung. Using the PostWebData action instead had the desired effect. The script worked OK otherwise.

I can work around this, but it would be nice to know if I have missed something. I have some other scripts that are collecting hundreds of scores from the net, so I would rather get to the root of the issue.



var url = "http://blahblah.asp"
var login=new Object()

login.Username=Username
login.Password=Password

WebLogin=InternetPostData(url,login,true)

WebResponse=WebLogin.WebResponse


Thanks
Dan


For this message dan1 has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: InternetPostData
PostPosted: March 22nd, 2012, 4:39 pm 
Offline

Joined: May 25th, 2008, 4:57 pm
Posts: 355
Location: Ireland
Opus: Pro 9.75
OS: Windows 10
System: MacBook Pro (Intel 2020)
I'm having the same issue. Using Actions to check if online or not. I am getting the same hang otherwise.

_________________
Opus Pro 9.75 on MacBookPro (2020 Intel) running Parallels 19 with Windows 10 (x64)


For this message lmc has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: InternetPostData
PostPosted: March 22nd, 2012, 9:20 pm 
Offline

Joined: July 12th, 2009, 10:33 am
Posts: 124
Sorry, that was long ago. Try placing a timer after the script to move on if no reply. In the example below, you need to send a 'resp' value back from your server.


var WebResponse = ""

....
Script, including
WebResponse =login.resp
....


var loopCounter = 0

while (WebResponse == '' && loopCounter < 100)
{
wait(0.1)
loopCounter++
}

_________________
V9.6. Windows 10. Testing on PC, Mac, iPad.


For this message dan1 has been thanked by : mackavi


Top
 Profile Visit website  
 
 Post subject: Re: InternetPostData
PostPosted: September 3rd, 2016, 7:11 pm 
Offline

Joined: May 25th, 2008, 4:57 pm
Posts: 355
Location: Ireland
Opus: Pro 9.75
OS: Windows 10
System: MacBook Pro (Intel 2020)
Hi,

Can someone explain how I can set a InternetPostData() to timeout if there has been no response from the server, currently it just hangs.

I'm sending a call to a PHP page, want to inform the user if the PHP page is unavailable or some other issue connecting. What is the best way of doing this so there is some response.

Thanks.

_________________
Opus Pro 9.75 on MacBookPro (2020 Intel) running Parallels 19 with Windows 10 (x64)


For this message lmc has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: InternetPostData
PostPosted: September 5th, 2016, 10:40 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
What publication type?

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


For this message mackavi has been thanked by : lmc


Top
 Profile Visit website  
 
 Post subject: Re: InternetPostData
PostPosted: September 6th, 2016, 1:46 pm 
Offline

Joined: May 25th, 2008, 4:57 pm
Posts: 355
Location: Ireland
Opus: Pro 9.75
OS: Windows 10
System: MacBook Pro (Intel 2020)
Oh yeah, it is a Windows Exe application type.

Thanks, Luke

_________________
Opus Pro 9.75 on MacBookPro (2020 Intel) running Parallels 19 with Windows 10 (x64)


For this message lmc has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: InternetPostData
PostPosted: September 7th, 2016, 9:10 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
No, I don't think you can for that publication type.

You could set up a timer and after your delay, warn user that no reply has been found. Anything fancier would probably require web communication via a DLL.

DW could probably tell you what happens to the connection if nothing is found, but I think it just silently time's out.

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


For this message mackavi has been thanked by : lmc


Top
 Profile Visit website  
 
 Post subject: Re: InternetPostData
PostPosted: September 8th, 2016, 5:13 pm 
Offline

Joined: May 25th, 2008, 4:57 pm
Posts: 355
Location: Ireland
Opus: Pro 9.75
OS: Windows 10
System: MacBook Pro (Intel 2020)
Thanks Mack,

I tried a timer via a while loop, but if it hangs on InternetPostData it never gets to increment the while loop.

_________________
Opus Pro 9.75 on MacBookPro (2020 Intel) running Parallels 19 with Windows 10 (x64)


For this message lmc has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: InternetPostData
PostPosted: September 9th, 2016, 10:48 am 
Offline

Joined: May 25th, 2008, 4:57 pm
Posts: 355
Location: Ireland
Opus: Pro 9.75
OS: Windows 10
System: MacBook Pro (Intel 2020)
This is the code I am using, I left out some of the objects being passed to the PHP page and being returned to reduce repetition. I tried a While loop to do a count down to time out if ReturnedData object is empty but either Opus doesn't support similar or I am doing something very wrong. If the server cannot be reached it will never move onto ValidateKeyPost() and I cannot inform the user that the connection failed.

Any help would be great. Thanks, Luke

Code:
function CheckKeyOnline()
{
var webURL == "notarealurl.notaurl.ie/licenses.php";

var VerifyAppKey = new Object();
VerifyAppKey.ProductID = gAppID;
VerifyAppKey.SoftwareKey = gUserKey;
ReturnedData = InternetPostData(webURL,VerifyAppKey,true, true);

JSON_Check = ReturnedData.Valid;
ValidateKeyPost();
}

_________________
Opus Pro 9.75 on MacBookPro (2020 Intel) running Parallels 19 with Windows 10 (x64)


For this message lmc has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: InternetPostData
PostPosted: September 9th, 2016, 11:23 am 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
For Pro EXE, I'd suggest using the Ticker action.

Set it up independently on the page object and add a control mechanism that allows you to stop and start and add further code / actions.

IE use IF myTickerControl = false// then you can switch variable state accordingly.

Then you need to do two things:

1. Add the further code / actions that you want to run when the myTickerControl is on - such as
- increment a counter to keep track of the number of times the ticker has run.
- add the checking logic to see if something has happened - in your case a return variable from the InternetPostData has changed.
- timeout using the counter in point above
- display message if time is up or variable changed.

2. Add a switch to your InternetPostData function that starts the ticker running - IE myTickerControl = true

This method is for repeated checking over a period of time.

If you just want one check after a fixed period, that's much easier.

Just add a wait(x) after the InternetPostData call and then check the return value for a change.

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


For this message mackavi has been thanked by : lmc


Top
 Profile Visit website  
 
 Post subject: Re: InternetPostData
PostPosted: September 9th, 2016, 3:29 pm 
Offline

Joined: May 25th, 2008, 4:57 pm
Posts: 355
Location: Ireland
Opus: Pro 9.75
OS: Windows 10
System: MacBook Pro (Intel 2020)
Fantastic Mack,

That worked perfectly. I created a frame on the page and set it to hidden, within that frame was a ticker trigger that every 4 seconds called a function and it kept track of count and checked for the internet returned var has changed, if it has been updated hide the frame and stops the ticker. If after 20 seconds and the returned var has not been updated, the ticker checks and inform the user of the time out error.

Sorry I didn't grasp the original message you posted.

Thanks again, Luke

_________________
Opus Pro 9.75 on MacBookPro (2020 Intel) running Parallels 19 with Windows 10 (x64)


For this message lmc has been thanked by : mackavi


Top
 Profile  
 
 Post subject: Re: InternetPostData
PostPosted: September 9th, 2016, 6:57 pm 
Offline
Godlike
Godlike
User avatar

Joined: March 21st, 2007, 10:44 am
Posts: 3188
Location: UK
Opus: Evolution
No apologies necessary.

As one of my teacher's used to say - meaning is won and lost in a sea of words.

Glad it works.

</mack>

_________________
When you have explored all avenues of possibilities, what ever remains, how ever improbable, must be the answer.

Interactive Solutions for Business & Education
Learn Anywhere. Learn Anytime.

www.interaktiv.co.uk
+44 (0) 1395 548057


For this message mackavi has been thanked by : lmc


Top
 Profile Visit website  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group