PDA

View Full Version : Do While and While Wend



AIman
08-23-2006, 03:58 AM
I have been running into some problems and was hoping someone might have an answer. My code reads (in psudeo) as follows:

While Timer <= Start + pausetime··· ' Pauses program for designated time

Do events·· ' Goes to other program. Some things work, some don't

Wend

Why can't my other programs keep up? All I am doing is running a second loop while the one program pauses but have found repeatedly that this proceudre runs so fast that the data isn't being transered into my other program. The set up and start procedure takes but nothing else.
Do I have to slow it down or is there a way·to use the speed without screwing up my program?·The kicker is that if I run without the While Wend it works just fine, but if I run the While Wend it screws up and won't transfer data.

Bruce Bates
08-23-2006, 10:55 AM
AIMan -

Your portrayal of exactly what your program is doing, isn't very clear. Could you show us the program, or offer an example?

Regards,

Bruce Bates

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->

AIman
08-23-2006, 08:43 PM
When I start one sub there is a point at which it needs to pause and initalize.
During this time the code reads

While Timer <= Start + pausetime··· ' Pauses program for designated time

Get second sub ready to collect data

Wend

Goes back to first sub and executes it, then goes to second sub to continue. Problem is it will only go part way through the prep process on the second sub.

Sub one pulls an array but before the array can be used there is a slight hiccup in the program that requires a pause. I have run the code on different computers and sometimes it works fine, other times it catchs just briefly. To solve for this there is a timer function is utulized that causes a 1 second lapse of time to allow for complete initalization of sub one. During the pause·for sub one·sub two opens. Problem is that sub two will only intalize and not go to the point of being useable.

Sub one always works as it should and the hiccup problem is solved.
Sub two only gets setup but won't go beyond. If things go smoothly I can get a line or two more code out but sub two stops right there. It should be picking up data at this point, but it won't. I can manually go through the code line by line and it works, I can even go through a couple of lines at a time but not all at once.

In otherwords, sub one pulls the array and sub two runs the sonar. Sub one comes on line, initalizes, stops for a second and then during the pause Sub two comes in to check sonar.

So it looks more like this (in psudeo code)

Sub One
·· Pull·sonar array
·· Pause so·array won't get whacky

Sub Two
·· While pause is going on
·· Initalize Sonar
·· End pause


Sub one
·· Start talking to sub two

Sub Two
·· Ping sonar


Usually I can get a ping or two out of the sonar but it won't continue, or I can combine initalizing the sonar with a sonar ping and then only get the sonar to initalize.

Each sub will work independantly and each will function if its broken out into a few lines, but I can't get beyond one or two pings without it looking at me stupidly... or perhaps me looking at it stupidly...

http://forums.parallax.com/images/smilies/shakehead.gif

Post Edited (AIman) : 8/23/2006 12:47:04 PM GMT

Bruce Bates
08-23-2006, 10:36 PM
AIMan -

At the RISK of REPEATING myself, perhaps you misunderstood what I said. Most of us can create pseudo-code of one form or another, but some have problems with converting that to Parallax PBASIC!

Your portrayal of EXACTLY what your program is doing, isn't very clear. Could you show us the EXACT program, or offer a straight-forward PBASIC example? I'm presuming you want assistance here?

Regards,

Bruce Bates

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
<!--StartFragment -->