Results 1 to 9 of 9

Thread: Sub should wait for previous one

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Canada
    Posts
    264

    Cool

    I need a way to run subs/functions one after the other BUT make each wait untill the previous is finished.

    Example:

    private sub ProccessALL ()
    call ProccessFile
    call showinfo ' should run AFTER "ProccessFile" finished
    call MakeAll ' should run AFTER "showinfo" finished
    end sub



    In the beginning the universe was created. This has made a lot of people very angry and is generally regarded as a bad idea.

    - Douglas Adams
    The Hitchhiker's Guide to the Galaxy

  2. #2
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    What are you talking about? Your code will do exactly what you want it to do.
    -Shickadance

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Canada
    Posts
    264

    Cool

    Well, that's what I thought, but from some reason, it doesn't ... , it just goes through all of them in a row and the last one is finished before the first one is done..
    In the beginning the universe was created. This has made a lot of people very angry and is generally regarded as a bad idea.

    - Douglas Adams
    The Hitchhiker's Guide to the Galaxy

  4. #4
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Boulder, Colorado, USA
    Posts
    325
    What are you doing in these 3 functions?
    -Shickadance

  5. #5
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Lightbulb Return value

    May be you can return a value from each function
    • ProccessFile
    • showinfo
    • MakeAll


    So that you can base on the return value to determine whether the program should continue with the next function or skip the next coming up function.

    Let assume each function will return a Boolean value either True or False. (True = Succesfful, False = Fail)

    Code:
    If ProcessFile Then
        If showinfo Then
            If MakeAll Then
                MsgBox "All the function is completed!.", vbExclamation
            Else
                MsgBox "MakeAll function does not completed!.", vbExclamation
            End If
        Else
            MsgBox "showinfo function does not completed!.", vbExclamation
        End If
    Else
        MsgBox "ProcessFile function does not completed!.", vbExclamation
    End If

  6. #6
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    I can't see the problem either, that should work totally in the order you have put them.

    You could put a breakpoint on the first and then press F8 so you can follow in which order all executes
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    Canada
    Posts
    264

    Cool

    Well, the thing it does is parsing a text file, and putting all the information into a dictionary object, and than it makes folders (according to the keys in the dictionary object), the last step is making text files under each folder (in each file there is part of the original file).


    Chris gave a nice way to do it, but I will be more than happy to get some other ideas as well :-)

    Thank you every body.


    In the beginning the universe was created. This has made a lot of people very angry and is generally regarded as a bad idea.

    - Douglas Adams
    The Hitchhiker's Guide to the Galaxy

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Another possible thing that can cause this is if you enable a timercontrol which inhibits it's code wherever it you got a doevents... Have you tried to use F8 as i said?
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431
    I'm sorry to disagree with some of you folks, but the code as shown in the original post will ALWAYS run one after the other, and you don't need to turn them into functions that return something in order to ensure that. What CAN happen however is that ProcessFile calls some routine or causes some other routine to be called, and that routine then calls MakeAll, which may make it seem like the routines are running out of order. Even in that case however, when ProcessFile is done, showinfo will run and then MakeAll (again) unless there is an "End" someplace inbetween. To find out what's going on, set a breakpoint in MakeAll and when that routine is reached, examine the call tree to see how it got there.

Posting Permissions

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



Click Here to Expand Forum to Full Width