For Programmers: Free Programming Magazines  


Home > Archive > APL > June 2004 > How to wait?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author How to wait?
Ric

2004-05-31, 7:30 pm

I need to upload a file to a FTP site, then retrieve a results file
once the uploaded file has been processed (might take an hour or so).
I am using Davin Church's excellent FTP functions to do the file
transfers but am trying to work out how I should go about checking the
FTP site to see if the results file is there yet. Doing the checking
is OK - just get a directory listing from the server & see if the
results file is there, the bit that is causing me problems is how to
"pause" or "wait" x minutes between checks.

Does anybody have any advice for me? I'm using APL+Win 4.0

TIA,
Ric
Mike Kent

2004-05-31, 8:30 pm

Ric wrote:
> the bit that is causing me problems is how to
> "pause" or "wait" x minutes between checks.


{quad)DL
LatLong

2004-05-31, 11:30 pm

I would not use []DL. Using []DL would cause two bad things. [1] it will
lock up your forgound window causing all user input to be ignored until the
[]DL completed. and [2] it will cause your CPU usage to go to 100% until
[]DL completes. The simple way is to use a Timer object and the onTimer
event. You can use a long or short timer interval, and use a variable or
user-defined-property of the Timer object to keep track of elapsed time to
allow you to check back as often as is required.



"Mike Kent" <mkent@acm.org> wrote in message
news:2i1si0Fikrs3U1@uni-berlin.de...
> Ric wrote:
>
> {quad)DL



Mike Kent

2004-06-01, 12:30 am

LatLong wrote:
> I would not use []DL. Using []DL would cause two bad things. [1] it will
> lock up your forgound window causing all user input to be ignored until the
> []DL completed.


Surely only for child windows of the specific APL session
that invokes {quad}DL.

> and [2] it will cause your CPU usage to go to 100% until
> []DL completes.


That's nasty -- are you sure? There /are/ APLs that don't use a
busy-wait to implement {quad}DL.

> The simple way is to use a Timer object and the onTimer
> event. You can use a long or short timer interval, and use a variable or
> user-defined-property of the Timer object to keep track of elapsed time to
> allow you to check back as often as is required.


Fair enough. It's not portable but the OP did imply he was running
under Windows. IMO it isn't exactly simple but you could wrap it so
as to provide a simple interface.

>
> "Mike Kent" <mkent@acm.org> wrote in message
> news:2i1si0Fikrs3U1@uni-berlin.de...
>
>
>
>

Ric

2004-06-01, 2:30 am

r.g.sherlock@massey.ac.nz (Ric) wrote in message news:<9355bc02.0405311420.4b20e4e1@posting.google.com>...
> the bit that is causing me problems is how to
> "pause" or "wait" x minutes between checks.
>

I haven't done much GUI stuff, but stumbled on the Timer class and
think I can solve my problem by creating a (hidden) form with a timer
class and an onTimer method that calls the function to do the
checking.
Does this sound like a sensible way to go?
LatLong

2004-06-01, 2:30 am

That will work. Note that a Timer can be a top level object. It does not
need to be a child of a form.


"Ric" <r.g.sherlock@massey.ac.nz> wrote in message
news:9355bc02.0405312132.7d2e42b0@posting.google.com...
> r.g.sherlock@massey.ac.nz (Ric) wrote in message

news:<9355bc02.0405311420.4b20e4e1@posting.google.com>...
> I haven't done much GUI stuff, but stumbled on the Timer class and
> think I can solve my problem by creating a (hidden) form with a timer
> class and an onTimer method that calls the function to do the
> checking.
> Does this sound like a sensible way to go?



Ric

2004-06-01, 7:30 pm

"LatLong" <NotThis.lat.long@earthlink.net> wrote in message news:<IfCdnWgcg82liyHdRVn-jg@adelphia.com>...
> "Ric" <r.g.sherlock@massey.ac.nz> wrote in message
> news:9355bc02.0405312132.7d2e42b0@posting.google.com...
> news:<9355bc02.0405311420.4b20e4e1@posting.google.com>...
[color=darkred]
> That will work. Note that a Timer can be a top level object. It does not
> need to be a child of a form.


Thanks to both LatLong & Mike - unfortuantely for me the newsgroups
seem to be playing up so I didn't get your helpful suggestions until
after I'd already spent a heap of time last night trying to figure it
out myself. After spending quite a bit of time working out how to get
the Timer solution to work , I rediscovered []dl and just about kicked
myself (I don't think you can describe Timer as being as simple as
[]dl!). However it seems that although very simple, []dl has a
significant drawback (100% CPU usage) so perhaps my work on Timer is
not in vain after all!

The Timer method seems to work OK now except that I don't seem to be
able to do it with a hidden form. The problem is that I need to halt
further execution until the results file is available on the FTP site
& to do this I have used the Wait method on the form with the Timer.
But Wait also makes the form visible. The onTimer method calls a
function that checks if the file is available & if so closes the form
which resumes execution.

Any suggestions about how to get around this?
LatLong

2004-06-02, 1:30 am

We are speaking about APL+Win. The idea behind a Timer is that it is event
driven. The timer event fires, you do stuff, which might be check to see if
the required file is present. If it is, then grab it, and then execute the
code the requires the file, which may include showing a form. If the file
is not available, do nothing, wait for the next timer event, or do something
else and check for the file next timer event. Timers really are simple.
Run what code you can then quit. The onTimer code checks for the file.
Once it arrives, run the code that needs the file. Break the project up
into simple pieces. Use the events to keep things in sync. In a runtime
workspace, you do need to have a Wait on at least one form. It can be
hidden. Use style 2, for other forms will allow the forms to be independent
of other forms. You can have multiple active independent windows.

Now to really make things fun, create an APL session as a COM object, and
put your FTP transfer code there. Set up timers and/or use the Defer method
to get things going, use the Notify method to send back information on what
is going on, and you now have a multi-threaded APL program. The main APL
session can be doing other things while waiting for the COM to do file
transfers, lengthy calculations, etc. Setup multiple COM objects, do lots
of things at once. Load of fun.

But I digress...



"Ric" <r.g.sherlock@massey.ac.nz> wrote in message
news:9355bc02.0406011411.1417bc43@posting.google.com...
> "LatLong" <NotThis.lat.long@earthlink.net> wrote in message

news:<IfCdnWgcg82liyHdRVn-jg@adelphia.com>...
>
not[color=darkred]
>
> Thanks to both LatLong & Mike - unfortuantely for me the newsgroups
> seem to be playing up so I didn't get your helpful suggestions until
> after I'd already spent a heap of time last night trying to figure it
> out myself. After spending quite a bit of time working out how to get
> the Timer solution to work , I rediscovered []dl and just about kicked
> myself (I don't think you can describe Timer as being as simple as
> []dl!). However it seems that although very simple, []dl has a
> significant drawback (100% CPU usage) so perhaps my work on Timer is
> not in vain after all!
>
> The Timer method seems to work OK now except that I don't seem to be
> able to do it with a hidden form. The problem is that I need to halt
> further execution until the results file is available on the FTP site
> & to do this I have used the Wait method on the form with the Timer.
> But Wait also makes the form visible. The onTimer method calls a
> function that checks if the file is available & if so closes the form
> which resumes execution.
>
> Any suggestions about how to get around this?



Christopher C. Stacy

2004-06-02, 2:31 pm

>>>>> On Mon, 31 May 2004 19:15:48 -0400, Mike Kent ("Mike") writes:

Mike> Ric wrote:[color=darkred]

Mike> {quad)DL

Speaking of which, does anyone have the source code
for "The Lone Ranger" 2741 hack?
That always cracked me up.

mattern

2004-06-04, 3:55 pm

Ric wrote:

>I need to upload a file to a FTP site, then retrieve a results file
>once the uploaded file has been processed (might take an hour or so).
>I am using Davin Church's excellent FTP functions to do the file
>transfers but am trying to work out how I should go about checking the
>FTP site to see if the results file is there yet. Doing the checking
>is OK - just get a directory listing from the server & see if the
>results file is there, the bit that is causing me problems is how to
>"pause" or "wait" x minutes between checks.
>
>Does anybody have any advice for me? I'm using APL+Win 4.0
>
>TIA,
>Ric
>
>

this thread has 14 identical sub-threads, including the
time stamp. other threads have the original and a sub-thread
answer repeated many times. what's going on? other
newsgroups are ok. using mozilla's warpzilla browser for os/2.
thanks don mattern

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com