strate Posted November 2, 2004 Share Posted November 2, 2004 Below is some code that I am having a problem with. I had the Select statment inside of the readini()(formatted like: readini($Loc) and it gave me the correct responses. So for fewer lines I decided to take it out and run SelectINI before ReadINI are these formatted bad? This is in the .ini file: [LABEL NAMES] S1=Aiag-Non-GM.lbl S2=GM.lbl $Loc = 1 SelectINI($Loc,$Sector,$Key) Readini($Sector,$Key) $input = InputBox("Label Creation","Please input address label you would like to use:"&@CR& $list2,"0","",300,($counter*15)+150) Func SelectINI($Loc,$Sector,$Key) Select Case $Loc = 1 $Sector = "LABEL NAMES" $Key = "S" Case $Loc = 2 $Sector = "Printer Paths" $Key = "P" EndSelect EndFunc func readini($Sector,$Key) $list="" $list2=@crlf $counter=0 $badnum="|" For $i= 1 to 200 $line = IniRead ( $File, $Sector, $Key & $i, "Error" ) if $line="Error" then continueloop $list=$list & $line & @cr $list2=$list2 &$i &" - "& $line & @crlf $counter=$counter+1 $badnum=$badnum & $i &"|" next endfunc INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station... Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted November 2, 2004 Share Posted November 2, 2004 Your functions are not returning anything. If you want SelectINI to return $Sector and key then make them ByRef. *** Matt @ MPCS Link to comment Share on other sites More sharing options...
scriptkitty Posted November 2, 2004 Share Posted November 2, 2004 the other option is to Dim all your variables before hand, that way valuse changed will be global. Dim $Loc Dim $Sector Dim $Key Dim $line Dim $list Dim $list2 Dim $counter Dim $badnum Not that this is best, but an option AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Guest Py7|-|[]/\/ Posted November 3, 2004 Share Posted November 3, 2004 (edited) If you declare all of them as global. Then you cannot reassign them: This you cannont do if it is global: Dim $hello =1 $Hello = 5 Edited November 3, 2004 by Py7|-|[]/\/ Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted November 3, 2004 Share Posted November 3, 2004 You are wrong, that works just fine. The global scope isn't what he was talking about. His source defined the variables in the scope of the module. Even if he had done as you are saying it would still work. Try it! *** Matt @ MPCS Link to comment Share on other sites More sharing options...
scriptkitty Posted November 3, 2004 Share Posted November 3, 2004 Dim $hello =1 $Hello = 5 msgbox(1,"See hello is 5",$hello)Global doesn't make it a permanent value that you can't change, it only sets the scope. The difference between Dim/Local/Global is the scope in which they are created:Dim = Local scope if the variable name doesn't already exist globally (in which case it reuses the global variable!)Global = Forces creation of the variable in the Global scopeLocal = Forces creation of the variable in the Local/Function scopeWhen using variables the local scope is checked first and then the global scope second. AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Guest Py7|-|[]/\/ Posted November 3, 2004 Share Posted November 3, 2004 Sorry for my mistake! I am very used to global with Java. EX: final int x = 123; x = 5; <-- error cannot reassign a constant Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted November 3, 2004 Share Posted November 3, 2004 (edited) That only doesn't work in java because you defined it as final not because it is global. I may be mistaken but Final is the same as const (or constant). It has nothing to do with the scope of the variable. *** Matt @ MPCS Edit: Fixed Typo Edited November 3, 2004 by Matt @ MPCS Link to comment Share on other sites More sharing options...
Guest Py7|-|[]/\/ Posted November 4, 2004 Share Posted November 4, 2004 You are right... But final is the equivalent of #define for C which is a global. I was therefore under the impression that final makes it a constant, otherwise known as a "global variable" which cannot be modified through a script except at its instantiation. Link to comment Share on other sites More sharing options...
CyberSlug Posted November 4, 2004 Share Posted November 4, 2004 ... final makes it a constant, otherwise known as a "global variable" ....<{POST_SNAPBACK}>Nitpick: Constants are a subset of "global variables", so the term is not completely the same. Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted November 4, 2004 Share Posted November 4, 2004 To avoid this I believe you can declare the variable as "public". Here is an example how to do it. Final variables may be defined in the "public" scope but they are not public variables, they are public constants.*** Matt @ MPCS Link to comment Share on other sites More sharing options...
Guest Py7|-|[]/\/ Posted November 4, 2004 Share Posted November 4, 2004 Thanks, but I already knew about public. There is also "private" declarations that can only be used in the method as well. I was under the impression that "Global" and "Final" were synonymous (spelling); but I suppose I was wrong. I stand corrected. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now