Jump to content

Return value, then return another


Recommended Posts

I have set up a test script for an installer that will say what stage it is currently at. This is my test so far:

#include <GUIConstants.au3>
$win = GUICreate("VUbuntu Installer 1.0 by sandman", 589, 227, 193, 115)
$progresslbl = GUICtrlCreateLabel("bah", 10, 145, 552, 17)
GUISetState(@SW_SHOW)
Global $install = Install()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    While $install = "stage1"
        GUICtrlSetData($progresslbl, "1")
        Sleep(1)
    WEnd
    While $install = "stage2"
        GUICtrlSetData($progresslbl, "2")
        Sleep(1)
    WEnd
    While $install = "stage3"
        GUICtrlSetData($progresslbl, "3")
        Sleep(1)
    WEnd
    While $install = "stage4"
        GUICtrlSetData($progresslbl, "4")
        Sleep(1)
    WEnd
    While $install = "stage5"
        GUICtrlSetData($progresslbl, "5")
        Sleep(1)
    WEnd
    While $install = "stage6"
        GUICtrlSetData($progresslbl, "6")
        Sleep(1)
    WEnd
WEnd
Func Install()
    Return "stage1"
    Sleep(1000)
    Return "stage2"
    Sleep(2000)
    Return "stage3"
    Sleep(3000)
    Return "stage4"
    Sleep(1000)
    Return "stage5"
    Sleep(2000)
    Return "stage6"
EndFunc
The label immediately changes from 'bah' to '1', but it never goes any farther than that, no matter how long I wait. What is wrong here?

edit: I just tried using Ifs inside the While loop.. that doesn't work also.

Edited by sandman

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Link to comment
Share on other sites

What is happening is it is going through the whole Install() func, then you are not calling it again. Try calling it after each 'stage'.

Just a guess.

Edited by Firestorm

[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Link to comment
Share on other sites

Well of course../How could you possibly return more than one value?? As soon as the first Return statement is reached, the func exits.

Besides all of that code is rather unnecessary. why not just something like this?

#include <GUIConstants.au3>
$win = GUICreate("VUbuntu Installer 1.0 by sandman", 589, 227, 193, 115)
$progresslbl = GUICtrlCreateLabel("bah", 10, 145, 552, 17)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    GUICtrlSetData($progresslbl, "1")
    Sleep (1000)
    GUICtrlSetData($progresslbl, "2")
    Sleep (2000)
    GUICtrlSetData($progresslbl, "3")
    Sleep (3000)
    GUICtrlSetData($progresslbl, "4")
    Sleep (1000)
    GUICtrlSetData($progresslbl, "5")
    Sleep (2000)
    GUICtrlSetData($progresslbl, "6")
WEnd

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

Well of course../How could you possibly return more than one value?? As soon as the first Return statement is reached, the func exits.

Besides all of that code is rather unnecessary. why not just something like this?

#include <GUIConstants.au3>
$win = GUICreate("VUbuntu Installer 1.0 by sandman", 589, 227, 193, 115)
$progresslbl = GUICtrlCreateLabel("bah", 10, 145, 552, 17)
GUISetState(@SW_SHOW)
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    GUICtrlSetData($progresslbl, "1")
    Sleep (1000)
    GUICtrlSetData($progresslbl, "2")
    Sleep (2000)
    GUICtrlSetData($progresslbl, "3")
    Sleep (3000)
    GUICtrlSetData($progresslbl, "4")
    Sleep (1000)
    GUICtrlSetData($progresslbl, "5")
    Sleep (2000)
    GUICtrlSetData($progresslbl, "6")
WEnd
Well that was just a test, it will be copying files and writing registry entries and other stuff.. and it will be called from two different places in the script.. I guess I could just put the install code in both.. sigh.

[center]"Yes, [our app] runs on Windows as well as Linux, but if you had a Picasso painting, would you put it in the bathroom?" -BitchX.com (IRC client)"I would change the world, but they won't give me the source code." -Unknownsite . blog . portfolio . claimidcode.is.poetry();[/center]

Link to comment
Share on other sites

Or you could have the common install code in an include file and include it in the two apps. Just my $0.02.

Link to comment
Share on other sites

Or, just make a global stage variable, and use that while loop you've got to update it like you were based on it.

Kinda like this:

#include <GUIConstants.au3>
$win = GUICreate("VUbuntu Installer 1.0 by sandman", 589, 227, 193, 115)
$progresslbl = GUICtrlCreateLabel("bah", 10, 145, 552, 17)
GUISetState(@SW_SHOW)
Install()
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    While $install = "stage1"
        GUICtrlSetData($progresslbl, "1")
        Sleep(1)
    WEnd
    While $install = "stage2"
        GUICtrlSetData($progresslbl, "2")
        Sleep(1)
    WEnd
    While $install = "stage3"
        GUICtrlSetData($progresslbl, "3")
        Sleep(1)
    WEnd
    While $install = "stage4"
        GUICtrlSetData($progresslbl, "4")
        Sleep(1)
    WEnd
    While $install = "stage5"
        GUICtrlSetData($progresslbl, "5")
        Sleep(1)
    WEnd
    While $install = "stage6"
        GUICtrlSetData($progresslbl, "6")
        Sleep(1)
    WEnd
WEnd
Func Install()
Global $install
    $install = "stage1"
    Sleep(1000)
    $install = "stage2"
    Sleep(2000)
    $install = "stage3"
    Sleep(3000)
    $install = "stage4"
    Sleep(1000)
    $install = "stage5"
    Sleep(2000)
    $install = "stage6"
EndFunc

... That is, if AutoIt could run a function while continuing to run the rest of the script. Unfortunately, AutoIt stops running the script where it is when it calls a function, runs the entire function (barring more function calls), and then returns back to the line it stopped on and keeps going, so I'm pretty sure my example will just show "stage6" all the time. Theguy0000 probably has the best example of how it is gonna have to work, unless you use 2 separate scripts, with the one doing the installing writing it's stage to a file, and the other displaying the progress read from that file.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...