Sign in to follow this  
Followers 0
kenedy

Variables scope question.

4 posts in this topic

Look at this example code.

How is that possible that myFunc can access $input2 value? I don't pass it as argument. :)

#include <guiconstants.au3>
ShowGUI()

Func ShowGUI()
   GUICreate("My GUI")
   $Input1 = GUICtrlCreateInput  ( "text1", 10, 10)
   $Input2 = GUICtrlCreateInput  ( "text2", 10, 30)
   $Input3 = GUICtrlCreateInput  ( "text3", 10, 50)
   GUISetState (@SW_SHOW)
   
   $msg = GUIGetMsg()
   myFunc($input1,$input3)
EndFunc 

Func myFunc ($first,$second)
   For $i = $first to $second
      MsgBox (0,"",GUIRead ( $i ))
   Next
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Look at this example code.

How is that possible that myFunc can access $input2 value? I don't pass it as argument.  :)

<{POST_SNAPBACK}>

Myfunc doesn't access $input2.

This will be the values for $input?;

$input1 = 1

$input2 = 2

$input3 = 3

You tell MyFunc to retrieve the values for control 1 to 3.

MyFunc itself does the retrieval itselve for the 3 controls.

Edited by JdeB

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

Look at this example code.

How is that possible that myFunc can access $input2 value? I don't pass it as argument.  :)

#include <guiconstants.au3>
ShowGUI()

Func ShowGUI()
   GUICreate("My GUI")
   $Input1 = GUICtrlCreateInput  ( "text1", 10, 10)
   $Input2 = GUICtrlCreateInput  ( "text2", 10, 30)
   $Input3 = GUICtrlCreateInput  ( "text3", 10, 50)
   GUISetState (@SW_SHOW)
   
   $msg = GUIGetMsg()
   myFunc($input1,$input3)
EndFunc 

Func myFunc ($first,$second)
   For $i = $first to $second
      MsgBox (0,"",GUIRead ( $i ))
   Next
EndFunc

<{POST_SNAPBACK}>

define $input2 as a global variable at the begining of your script :)

Share this post


Link to post
Share on other sites

JdeB

I understand now. Thanks.

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
Sign in to follow this  
Followers 0