vi779900

How to set up message boxes throughout different functions

11 posts in this topic

I set up a msg on my first function for a case in my GUI but when i move on to case 2, to my second function and put in a msg it gives an error saying variable used without being declared. Can anyone give examples of how to properly do this?

Share this post


Link to post
Share on other sites



vi779900,

It would greatly assist us to help you if you were to post your code - see here how to do it.

M23

 


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Sorry work got hectic, but here is the script i was working on, and i'm having trouble with adding a popup message prompt to each function @Melba23

Version 1.0.au3

Share this post


Link to post
Share on other sites

Don't think you actually read what @Melba23 pointed you to...right? ;)
So tell me: What exactly is your problem adding that msgbox()? 

ps. maybe you want to run Tidy on your code to make it a little more readable.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Users\trioptics\Desktop\Autopositioner\JSF.kxf
Global $JSF = GUICreate("JSF", 402, 485, -1, -1)
Global $First = GUICtrlCreateButton("T8-77454200-05", 0, 0, 75, 25)
Global $Second = GUICtrlCreateButton("77454212-001", 0, 24, 75, 25)
Global $Third = GUICtrlCreateButton("T8-77454200-06", 0, 48, 75, 25)
Global $Fourth = GUICtrlCreateButton("77454211-001", 0, 72, 75, 25)
$Button5 = GUICtrlCreateButton("Button5", 0, 96, 75, 25)
$Button6 = GUICtrlCreateButton("Button6", 0, 120, 75, 25)
$Button7 = GUICtrlCreateButton("Button7", 0, 144, 75, 25)
$Button8 = GUICtrlCreateButton("Button8", 0, 168, 75, 25)
$Button9 = GUICtrlCreateButton("Button9", 0, 192, 75, 25)
$Button10 = GUICtrlCreateButton("Button10", 0, 216, 75, 25)
$Button11 = GUICtrlCreateButton("Button11", 0, 240, 75, 25)
$Button13 = GUICtrlCreateButton("Button13", 0, 288, 75, 25)
$Button12 = GUICtrlCreateButton("Button12", 0, 264, 75, 25)
$Button14 = GUICtrlCreateButton("Button14", 0, 312, 75, 25)
$Button15 = GUICtrlCreateButton("Button15", 0, 336, 75, 25)
$Button16 = GUICtrlCreateButton("Button16", 0, 360, 75, 25)
$Button17 = GUICtrlCreateButton("Button17", 0, 384, 75, 25)
$Button18 = GUICtrlCreateButton("Button18", 0, 408, 75, 25)
$Button19 = GUICtrlCreateButton("Button19", 0, 432, 75, 25)
$Button20 = GUICtrlCreateButton("Button20", 0, 456, 75, 25)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $First
            StartFirst()
        Case $Second
            StartSecond()
        Case $Third
            StartThird()
        Case $Fourth
            StartFourth
    EndSwitch
WEnd



Func StartFirst();T8-77454200-05
WinActivate('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]')
ControlCommand('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:Button; INSTANCE:45]', 'Check')
ControlClick('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:ComboBox; INSTANCE:6]')
Send('{HOME}{DOWN}{DOWN}{DOWN}{ENTER}')
Sleep(1000)
ControlClick('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:ComboBox; INSTANCE:3]')
Send('{HOME}{DOWN}{DOWN}{ENTER}')
Sleep(1000)
WinWait('OptiCentric 3.3.11')
Send('{ENTER}')
Sleep(1000)
ControlSetText('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:RichEdit20A; INSTANCE:8]', '200')
ControlClick('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:Button; INSTANCE:24]', 'left', 1)
EndFunc



Func StartSecond();77454212-001
WinActivate('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]')
ControlCommand('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:Button; INSTANCE:45]', 'UnCheck')
ControlClick('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:ComboBox; INSTANCE:6]')
Send('{HOME}{ENTER}')
Sleep(1000)
ControlSetText('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:Edit; INSTANCE:7]', '258.318')
ControlClick('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:ComboBox; INSTANCE:3]')
Send('{HOME}{DOWN}{DOWN}{ENTER}')
Sleep(1000)
WinWait('OptiCentric 3.3.11')
Send('{ENTER}')
Sleep(1000)
ControlSetText('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:RichEdit20A; INSTANCE:8]', '128')
ControlClick('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:Button; INSTANCE:24]', 'left', 1)
EndFunc



Func StartThird();T8-77454200-06
WinActivate('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]')
ControlCommand('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:Button; INSTANCE:32]', 'Check')
ControlClick('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:ComboBox; INSTANCE:5]')
Send('{HOME}{DOWN}{DOWN}{DOWN}{ENTER}')
Sleep(1000)
ControlClick('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:ComboBox; INSTANCE:1]')
Send('{HOME}{DOWN}{DOWN}{ENTER}')
Sleep(1000)
WinWait('OptiCentric 3.3.11')
Send('{ENTER}')
Sleep(1000)
ControlSetText('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:RichEdit20A; INSTANCE:5]', '200')
ControlClick('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:Button; INSTANCE:12]', 'left', 1)
EndFunc



Func StartFourth();7745211-001
WinActivate('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]')
ControlCommand('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:Button; INSTANCE:32]', 'UnCheck')
ControlClick('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:ComboBox; INSTANCE:5]')
Send('{HOME}{ENTER}')
Sleep(1000)
ControlSetText('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:Edit; INSTANCE:3]', '151.13')
ControlClick('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:ComboBox; INSTANCE:1]')
Send('{HOME}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}')
Sleep(1000)
WinWait('OptiCentric 3.3.11')
Send('{ENTER}')
Sleep(1000)
ControlSetText('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:RichEdit20A; INSTANCE:5]', '355.778')
ControlClick('OptiCentric 3.3.11  - Trioptics GmbH - [Reflection]', '', '[CLASS:Button; INSTANCE:12]', 'left', 1)
EndFunc

My bad! :)

Edited by vi779900

Share this post


Link to post
Share on other sites

When i add a msg box to more than one function only the first function works while the others give me an error that variable is not found.

Share this post


Link to post
Share on other sites

vi779900,

If you add #include <MsgBoxConstants.au3>  to the start of the script, this works for me:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $First
            MsgBox($MB_SYSTEMMODAL, "Function", "Starting First")
            StartFirst()
            MsgBox($MB_SYSTEMMODAL, "Function", "Ending First")
        Case $Second
            MsgBox($MB_SYSTEMMODAL, "Function", "Starting Second")
            StartSecond()
            MsgBox($MB_SYSTEMMODAL, "Function", "Ending Second")
        Case $Third
            MsgBox($MB_SYSTEMMODAL, "Function", "Starting Third")
            StartThird()
            MsgBox($MB_SYSTEMMODAL, "Function", "Ending Third")
        Case $Fourth
            MsgBox($MB_SYSTEMMODAL, "Function", "Starting Fourth")
            StartFourth() ; Added () <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            MsgBox($MB_SYSTEMMODAL, "Function", "Ending Fourth")
    EndSwitch
WEnd

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

So i will be able to have a different message box for each function, each giving different set of instructions?

 

Share this post


Link to post
Share on other sites

Thanks!

Share this post


Link to post
Share on other sites

#10 ·  Posted

vi779900,

As you can see above, each of the MsgBoxes has a different message - you just write what you require in each one.

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

Thank you, you have a great one!

Share this post


Link to post
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