Help with Looping Inquiry
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Help with Looping Inquiry
In my Desktop Application for the Comunity Members of my Web Application, I have been trying to display different messages in one specific field on the screen which I think I would need to use the command repeat. I also think that my repeat loop will need to be dynamic based on the various situations listed below. At the time the default update period is set to 15 minutes.
For right now I would like to concentrate on completed Situation 1 as this one should be the easist to complete. I am just not sure how to go about it. I have been playing with various code which I have managed to lock up RunRev and have had to Force Quit it through Task Manager. This is why I am asking on the forums to find a better way to handle this.
Situation 1:
If the web service returns 0 which most of the time it would be, I am wanting to display 2 different messages that will repeat itself at a slow rate until the time that the program needs to update iteself to see if anything is new from the web server. The first message would be something like All organizations operating on normal scedule and the second message being Results delayed 15 minutes. My thought was to space these two messages out every 30 seconds and that each message would be displayed 15 times before the next round to check for any new information.
Situation 2:
This one would be more difficult as it would have to take into account the number of organizations that have been returned from the web server and then display each Organization a specific amount of seconds so that the last one would be x amount of seconds before the next check from the web server. I would think that if the number of organizations is an odd number then I would put in a system message like Results Delayed 15 Minutes after so many Organizations have been displayed. I presume that this one would take more math to calculate.
For right now I would like to concentrate on completed Situation 1 as this one should be the easist to complete. I am just not sure how to go about it. I have been playing with various code which I have managed to lock up RunRev and have had to Force Quit it through Task Manager. This is why I am asking on the forums to find a better way to handle this.
Situation 1:
If the web service returns 0 which most of the time it would be, I am wanting to display 2 different messages that will repeat itself at a slow rate until the time that the program needs to update iteself to see if anything is new from the web server. The first message would be something like All organizations operating on normal scedule and the second message being Results delayed 15 minutes. My thought was to space these two messages out every 30 seconds and that each message would be displayed 15 times before the next round to check for any new information.
Situation 2:
This one would be more difficult as it would have to take into account the number of organizations that have been returned from the web server and then display each Organization a specific amount of seconds so that the last one would be x amount of seconds before the next check from the web server. I would think that if the number of organizations is an odd number then I would put in a system message like Results Delayed 15 Minutes after so many Organizations have been displayed. I presume that this one would take more math to calculate.
---
Graham Pearson
Goshen, IN USA
We Are Closed Today is your single internet resource for Indiana Area School Closings, Visit http://www.weareclosedtoday.com
Graham Pearson
Goshen, IN USA
We Are Closed Today is your single internet resource for Indiana Area School Closings, Visit http://www.weareclosedtoday.com
Re: Help with Looping Inquiry
Hi gpearson,
It would definitely help if you posted your repeat loop here.
You mention a web service. Do you mean web server or do you mean the revlet?
I am not sure what you want to accomplish, but it looks as if you will want to read about the send command in the dictionary. More specifically, you probably want to send a command in 15*60 seconds.
Best regards,
Mark
It would definitely help if you posted your repeat loop here.
You mention a web service. Do you mean web server or do you mean the revlet?
I am not sure what you want to accomplish, but it looks as if you will want to read about the send command in the dictionary. More specifically, you probably want to send a command in 15*60 seconds.
Best regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Help with Looping Inquiry
For Scenerio 1 here is my current code: In the code below gSchoolBugRefreshRate by default is set to 15 and performing the loop waits for 60 seconds so in theory these messages will be displayed for a period of 15 minutes while the application waits till the next data pull from the server.Mark wrote:It would definitely help if you posted your repeat loop here.
Code: Select all
repeat with tVarNum = 0 to gSchoolBugRefreshRate
put "All Organizations Operating on Normal Schedule" into field "School Name and Reason" on card "Base Display Screen" of stack "School DelayClosing Bug"
wait for 30 seconds
put "Results Delayed 15 Minutes" into field "School Name and Reason" on card "Base Display Screen" of stack "School DelayClosing Bug"
wait for 15 seconds
put "Desktop Application Provided by We Are Closed Today (www.weareclosedtoday.com)" into field "School Name and Reason" on card "Base Display Screen" of stack "School DelayClosing Bug"
wait for 15 seconds
end repeat
This RunRev Application is kinda like the Weather Bug application that so many people are using however I am pulling XML Information from my School Closing System and parsing the information into RunRev to display to the user.Mark wrote:You mention a web service. Do you mean web server or do you mean the revlet?
I have been trying to use the send command as I am using it in other places like when it is time to pull the server to get updated information, however I have been having troubles with the send command using a function that requires parameters.Mark wrote:I am not sure what you want to accomplish, but it looks as if you will want to read about the send command in the dictionary. More specifically, you probably want to send a command in 15*60 seconds.
---
Graham Pearson
Goshen, IN USA
We Are Closed Today is your single internet resource for Indiana Area School Closings, Visit http://www.weareclosedtoday.com
Graham Pearson
Goshen, IN USA
We Are Closed Today is your single internet resource for Indiana Area School Closings, Visit http://www.weareclosedtoday.com
Re: Help with Looping Inquiry
gpearson,
Your script does something that's completely different from what I think you want. It runs 15 times in 15 minutes and after that it just finishes. If I understand you correctly, you want your script to run indefinitely, with a time interval of 15 minutes. My advice: put your project in the trash, choose "Empty trash" and start from scratch.
This should get you started. Create a field names "Display" and a button with the following script.
Please mind line wraps and typos. I didn't test this script.
Click on the button to start the script. Click again to stop it. This script won't block your interface! It runs every 30 seconds and shows a different message each time it runs.
It is not clear to me where the XML information come into play, but you can give it a try and ask more questions as soon as you get stuck again.
Best regards,
Mark
Your script does something that's completely different from what I think you want. It runs 15 times in 15 minutes and after that it just finishes. If I understand you correctly, you want your script to run indefinitely, with a time interval of 15 minutes. My advice: put your project in the trash, choose "Empty trash" and start from scratch.
This should get you started. Create a field names "Display" and a button with the following script.
Code: Select all
on mouseDown
set the hilite of me to not the hilite of me
if the hilite of me is true then
doUpdate
else
stopUpdate
end if
end mouseDown
on doUpdate theItem
if theItem is empty or theItem > 3 then put 1 into theItem
if theItem is 1 then
put "All Organizations Operating on Normal Schedule" into \
field "Display"
else if theItem is 2 then
put "Results Delayed 15 Minutes" into field "Display"
else if theItem is 3 then
put "Desktop Application Provided by We Are Closed Today (www.weareclosedtoday.com)" \
into field "Display"
end if
add 1 to theItem
send "doUpdate theItem" to me in 30 secs
end doUpdate
on stopUpdate
put the pendingMessages into myMessages
filter myMessages with "*doUpdate*"
repeat for each line myMsg in myMessages
cancel item 1 of myMsg
end repeat
end stopUpdate
Click on the button to start the script. Click again to stop it. This script won't block your interface! It runs every 30 seconds and shows a different message each time it runs.
It is not clear to me where the XML information come into play, but you can give it a try and ask more questions as soon as you get stuck again.
Best regards,
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Help with Looping Inquiry
I hope that this will clear up some information. A Parent/Guardian would access the website of www.weareclosedtoday.com and signup as a Comunity Member to be notified anytime their childs school was closed or delayed due to severe weather. The Parent/Guardian would get an email and/or text message in a representative from the school logged into the website to post their status information. At this same time, the news media who participates in this pulls our system electonically and feeds the character generator to display the information on the television screen. As I am learning Runtime Revolution, I learn from examples and converting my Flash/AIR applications over to this platform.Mark wrote:It is not clear to me where the XML information come into play, but you can give it a try and ask more questions as soon as you get stuck again.
In this School Closing Application, the idea is that the parent/guardian would enter their email address and password which then sends the request to my Coldfusion Server to validate it. The Coldfusion Server will send XML back and if the information is correct it is written into an SQLite database that the program checks each time it is ran. In the Demo version of this application it will go out to the Coldfusion Server to get an update of new information which I have set to every 15 minutes.
An Example would be this. Each time the user runs the application it goes out to http://demo.weareclosedtoday.com/proper ... rd={Base64 Password}. The information that gets returned would be:
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<RunRevXML>
<Credit>We Are Closed Today Website Service</Credit>
<Credit_URL>http://www.weareclosedtoday.com</Credit_URL>
<Description>We Are Closed Today XML Feed of Organizations Current Status to be displayed on website</Description>
<ID>9</ID>
<UserID>1322</UserID>
<UserAccountType>C</UserAccountType>
<Username>gspearson@gmail.com</Username>
<Password>{Base64 Encrypted Password}</Password>
<SchoolBug_RefreshRate>0</SchoolBug_RefreshRate>
</RunRevXML>
I also check the value of SchoolBug_RefreshRate and if it is 0 then I set the default inside of RunRev to be 15.
Once this process has been completed and accurate, the application will then call another web service at http://demo.weareclosedtoday.com/proper ... ordID=1322 which will return another packet of XML information like below which inside of RunRev I test for the Value of ReturnedRecordCount. If ReturnRecordCount is equal to 0 then this would be my Scenerio 1 from the previous forum posts since all schools who use this service are operating under normall cicumstances. If ReturnRecordCount is greater than 1 then within the CheckCurrentUserStatus xml tags will be a listing of School District Names, Current Status, Any Comments, Date of Entry, Date of expire, plug other information yet to be determined so that the parent/guardian can see on the screen through my application which schools are delayed or closed for the date in question.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<RunRevXML>
<Credit>We Are Closed Today Website Service</Credit>
<Credit_URL>http://www.weareclosedtoday.com</Credit_URL>
<Description/>
<ReturnedRecordCount>0</ReturnedRecordCount>
<CheckCurrentUserStatus>
</CheckCurrentUserStatus>
</RunRevXML>
---
Graham Pearson
Goshen, IN USA
We Are Closed Today is your single internet resource for Indiana Area School Closings, Visit http://www.weareclosedtoday.com
Graham Pearson
Goshen, IN USA
We Are Closed Today is your single internet resource for Indiana Area School Closings, Visit http://www.weareclosedtoday.com
Re: Help with Looping Inquiry
OK - I get the webservice and xml stuff, and it looks straightforward. Your loop also looks like it will do *most* of what you want, but the problem is that it's doing exactly what you're telling it to do: put three messages out in sequence with a wait between each. There's no yielding time to other processes, so you have to force-quit it because there's no apparent response.
So one possible solution might be to use "wait with messages" instead of "wait" to free up some system time for mouseUp events, etc.
But a better solution might be to trigger the message displays using "send in time", as in (warning: untested):
Now you should have the three message rotating via asynchronous messages, each one firing off the next one. Then if there's something else to display instead you'd want to cancel the pendingMessages and move on with scenario 2.
So one possible solution might be to use "wait with messages" instead of "wait" to free up some system time for mouseUp events, etc.
But a better solution might be to trigger the message displays using "send in time", as in (warning: untested):
Code: Select all
on DisplayFirstMessage
Display "All Organizations Operating on Normal Schedule"
send "DisplaySecondMessage" to me in 30 seconds
end DisplayFirstMessage
on DisplaySecondMessage
Display "Results Delayed 15 Minutes"
send "DisplayThirdMessage" to me in 15 seconds
end DisplaySecondMessage
on DisplayThirdMessage
Display "Desktop Application Provided by We Are Closed Today (www.weareclosedtoday.com)"
send "DisplayFirstMessage" to me in 15 seconds
end DisplayThirdMessage
on Display pMessage
put pMessage into field "School Name and Reason" on card "Base Display Screen" of stack "School DelayClosing Bug"
end Display