Indigo Rose Software

Professional Software Development Tools

 
Results 1 to 5 of 5
  1. #1
    Join Date
    May 2003
    Location
    Pendleton, Oregon
    Posts
    1,038

    Slow down, you’re going too fast.

    How do I make sure that one piece (line) of code finishes, before the next line of code is executed? I’ve used Application.Sleep(x) but the length of time it needs to sleep, will be dependant on the user’s particular system, so what works on my computer, might not on someone else’s.

    Here is what I’m doing:
    1) I delete a picture file

    2) I rename a different picture file, same name as the one I deleted

    3) I copy the new picture to the old picture’s folder

    --I don’t want to use Application.Sleep(x) here --

    4) I refresh a web object that displays the picture.

    My problem is that I get a Web Object refresh, before the new picture is in place.

  2. #2
    Join Date
    May 2004
    Location
    Vancouver, BC, Canada
    Posts
    87

    Hi...

    I'm happy that i'm not the only one that still awake.

    are you using Functions, lets say function that delete the file and only then calls the next step in your code?

    cause what you were saying about using the sleep(x) sounds pretty bad idea, and you figured it out your self.

    Itamar.

  3. #3
    Join Date
    Jul 2002
    Location
    USA
    Posts
    3,959
    Here's some code that uses a while loop to wait for File.Delete to happen. Times out after 10 seconds

    Code:
    File.Delete("Autoplay\\images\\image1.jpg", false, true, false, nil)
    nTime = 0
    nBaseTime=String.ToNumber(DLL.CallFunction(_SystemFolder .. "\\winmm.dll", "timeGetTime", "", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL))
    while (File.DoesExist("Autoplay\\images\\image1.jpg")) and (nTime < 10000) do
    	--wait for the file to be deleted or 10 seconds to have elapsed
    	--otherwise we could be in an infinite loop
    	nTime=String.ToNumber(DLL.CallFunction(_SystemFolder .. "\\winmm.dll", "timeGetTime", "", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL)) - nBaseTime
    end
    if nTime > 10000 then
    	Dialog.Message("Error", "Unable to delete the file Image1.JPG")
    end

  4. #4
    Join Date
    May 2003
    Location
    Pendleton, Oregon
    Posts
    1,038
    itamar, thanks for the suggestion. Yes, I am using Functions. With AMS5, it seems that I do 90% of my programming as Global Functions, so much so, that I’m considering changing my user name to Mel Function


    Worm, thank you for the code. I’ll give it a try this evening. I’m sure that will do the trick. I was sort of hoping that I had overlooked some type of built in ‘wait until finished’ function.

    I had considered using a similar type of loop using the page’s On Timer event. I didn’t really want to go that route if I didn’t have to, because I’ll be using the On Timer for other things too. It would mean I’d have to add more conditionals to the On Timer code.

    That’s what makes your code so sweet. That Systems’ DLL call for the timer, makes it much simpler to implement. In effect, you have given us a separate clock to use concurrently with the On Timer event. That’s cool!

    Thanks again.

  5. #5
    Corey is offline Indigo Rose Staff Alumni
    Join Date
    Aug 2002
    Posts
    9,746
    Mel is a superb choice of name, second only to Lou. I'm behind you 100%.

    Corey Milner
    Creative Director, Indigo Rose Software

Similar Threads

  1. Cd si runing slow
    By Tarsuar in forum AutoPlay Media Studio 4.0
    Replies: 4
    Last Post: 09-16-2003, 02:32 AM
  2. AMS 4.0.0.4 List boxes load slow?
    By stagemon in forum AutoPlay Media Studio 4.0
    Replies: 0
    Last Post: 07-12-2003, 01:59 PM
  3. Fast forward and rewind
    By DanceParty in forum AutoPlay Media Studio 4.0
    Replies: 4
    Last Post: 09-26-2002, 09:51 AM
  4. Avi video is slow
    By shortstories in forum AutoPlay Menu Studio 3.0
    Replies: 3
    Last Post: 03-25-2002, 07:40 PM
  5. why ams 3 looks slow?
    By awvqa in forum AutoPlay Menu Studio 3.0
    Replies: 1
    Last Post: 09-10-2001, 08:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts