friends Posted October 24, 2004 Share Posted October 24, 2004 I wonder what is .INI file for ? When we need to use .INI file instead of .txt or other extension ? What is the different of these two ? Thanks if someone mind to explain it. I know it is in HELP file, but I don't see the usage of this .INI. Link to comment Share on other sites More sharing options...
Somerset Posted October 24, 2004 Share Posted October 24, 2004 ok here goes my best shot. a text file basically is used for storing mass abouts of data. while an ini is used for storing specific data and being able to retrieve it alot easier than just a simple text document. Link to comment Share on other sites More sharing options...
friends Posted October 24, 2004 Author Share Posted October 24, 2004 I've written a script, and I'm not sure which one to use. This script will create a file where it stores only 1 or 0 to check if a particular process has been done or not. In this case, which is the one you would suggest to use ? a simple .TXT file or .INI file ? If .INI file, mind to provide me a sample ? Cos I never use .INI file before, I'm kinda blurred about this.... Thanks ------------------------------------------------------------------------------------- Also, I have tested out on reading a file that stores either 1 or 0. But, it fails to return the correct message. $file = FileOpen ("C:\checkfile.txt", 0) While 1 $value = FileReadLine ($file) IF $file = -1 Then ExitLoop Wend If $value = 1 then MsgBox (0, "", "The value is correct") else MsgBox (0, "", "The value is incorrect") endif FileClose ($file) When the file stores 1, it displays "The Value is correct". However, when the files stores 0, it also displays "The value is correct". What goes wrong with this coding ? If you have any better solution, please share it with me. Thanks Link to comment Share on other sites More sharing options...
Somerset Posted October 24, 2004 Share Posted October 24, 2004 $file = FileOpen ("C:\checkfile.txt", 0) $value = FileReadLine ($file) If $value = 1 then MsgBox (0, "", "The value is correct") else MsgBox (0, "", "The value is incorrect") endif FileClose ($file) remove it from the loop. Link to comment Share on other sites More sharing options...
friends Posted October 24, 2004 Author Share Posted October 24, 2004 $file = FileOpen ("C:\checkfile.txt", 0) $value = FileReadLine ($file) If $value = 1 then MsgBox (0, "", "The value is correct") else MsgBox (0, "", "The value is incorrect") endif FileClose ($file)remove it from the loop.<{POST_SNAPBACK}>that simple ? wow.... couldn't believe that I stuck in that for so long !arrgg.... Anyway...... thanks for the big helps ! Now I think I can move forwardto other things ! Link to comment Share on other sites More sharing options...
friends Posted October 24, 2004 Author Share Posted October 24, 2004 wait wait... just tested, looks like it's not working. the checkfile.txt contains 1 or 0, it also displays "This value is incorrect". what goes wrong ? Link to comment Share on other sites More sharing options...
Developers Jos Posted October 24, 2004 Developers Share Posted October 24, 2004 (edited) wait wait... just tested, looks like it's not working.the checkfile.txt contains 1 or 0, it also displays "This value is incorrect".what goes wrong ? <{POST_SNAPBACK}>Add error checking to see what goes wrong. This script works for me:$file = FileOpen("C:\checkfile.txt", 0) If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf $value = FileReadLine($file) If @error = -1 Then MsgBox(0, "Error", "Unable to read record.") Exit EndIf If $value = 1 Then MsgBox(0, "", "The value is correct") Else MsgBox(0, "", "The value is incorrect") EndIf FileClose($file) Edited October 24, 2004 by JdeB SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted October 24, 2004 Share Posted October 24, 2004 I miss Java. I love booleans. Link to comment Share on other sites More sharing options...
Developers Jos Posted October 24, 2004 Developers Share Posted October 24, 2004 I miss Java. I love booleans.<{POST_SNAPBACK}> where's the relation to a boolean here ?AutoIt does work with the value 0 and 1 like booleans:$a = 1 If $a then Msgbox(0,'demo','$a is True') $a = 0 If Not $a then Msgbox(0,'demo','$a is False')So explain your point here please? SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Guest BL@(K-R34P3R Posted October 24, 2004 Share Posted October 24, 2004 I know that =) I was just saying that I like Java's way of using booleans. If there is a common way to use booleans like in java with AutoIt, then I do not know of it. In Java you can declare boolean specific variables. public boolean hithere = 0 hithere = 1 And you can just mess around with it like that. I already know that you can do it with your above code, but I like the way in Java better. Possibly because of the declaration, I love the way "boolean" sounds and looks in code! Link to comment Share on other sites More sharing options...
Developers Jos Posted October 24, 2004 Developers Share Posted October 24, 2004 I know that =) I was just saying that I like Java's way of using booleans. If there is a common way to use booleans like in java with AutoIt, then I do not know of it. In Java you can declare boolean specific variables.public boolean hithere = 0hithere = 1And you can just mess around with it like that. I already know that you can do it with your above code, but I like the way in Java better. Possibly because of the declaration, I love the way "boolean" sounds and looks in code!<{POST_SNAPBACK}>What ever makes you smile ... SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
friends Posted October 25, 2004 Author Share Posted October 25, 2004 to check if the file's value (1 or 0), which one to use ? If $value = 1 Then MsgBox(0, "", "The value is correct") Else MsgBox(0, "", "The value is incorrect") EndIf or If $value = "1" Then MsgBox(0, "", "The value is correct") Else MsgBox(0, "", "The value is incorrect") EndIf And, is there any "==" ? What does that mean ? If I'm not mistaken, C is using == to compare the value, while = is to assign the value to a variable. Link to comment Share on other sites More sharing options...
Guest Py7|-|[]/\/ Posted October 25, 2004 Share Posted October 25, 2004 to check if the file's value (1 or 0), which one to use ?CODEIf $value = 1 Then MsgBox(0, "", "The value is correct")Else MsgBox(0, "", "The value is incorrect")EndIforCODEIf $value = "1" Then MsgBox(0, "", "The value is correct")Else MsgBox(0, "", "The value is incorrect")EndIfAnd, is there any "==" ? What does that mean ?If I'm not mistaken, C is using == to compare the value, while= is to assign the value to a variable.Well... Firstly, in the second section of your code... You have If $value ="1"Why do you have this? Because the "'s indicate that 1 is a string, and I don't see anywhere in your script you declaring the output of a funtion to be a string. Link to comment Share on other sites More sharing options...
JSThePatriot Posted October 25, 2004 Share Posted October 25, 2004 Actually it should be the second as in the case of reading the file and line of the file it will be outputing a string. That is the whole reason it hasnt been working... @Friends The code below should work excellently. You dont really need the elseif but I added it so it would be a bit easier to read. If $value = "1" Then MsgBox(0, "", "The value is correct") ElseIf $value = "0" Then MsgBox(0, "", "The value is incorrect") EndIf I hope that helps, JS AutoIt Links File-String Hash Plugin Updated! 04-02-2008Â Plugins have been discontinued. I just found out. ComputerGetInfo UDF's Updated! 11-23-2006 External Links Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more) Link to comment Share on other sites More sharing options...
Developers Jos Posted October 25, 2004 Developers Share Posted October 25, 2004 to check if the file's value (1 or 0), which one to use ?If $value = 1 Then MsgBox(0, "", "The value is correct") Else MsgBox(0, "", "The value is incorrect") EndIforIf $value = "1" Then MsgBox(0, "", "The value is correct") Else MsgBox(0, "", "The value is incorrect") EndIf<{POST_SNAPBACK}>IniRead is returning a string, but both should work as long as the file only contains 1 character. And, is there any "==" ? What does that mean ?If I'm not mistaken, C is using == to compare the value, while= is to assign the value to a variable.<{POST_SNAPBACK}>No not really.... = Tests if two values are equal (case insensitive if used with strings). e.g. If $var= 5 Then  (true if $var equals 5) == Tests if two values are equal (case sensitive if used with strings) SciTE4AutoIt3 Full installer Download page  - Beta files    Read before posting   How to post scriptsource   Forum etiquette Forum Rules  Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
scriptkitty Posted October 26, 2004 Share Posted October 26, 2004 (edited) The == means various thiings in various languages. Had this been PhP, you compare with == and asign with =. in AutoIt, = is just like JdeB stated. A quick example for ya:$x="bob" if $x=="Bob" then msgbox(1,"info","An exact match"); case sensitiive elseif $x="Bob" then msgbox(1,"info","A match"); case insensitiive else msgbox(1,"info","no match") endif Edited October 26, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
friends Posted October 28, 2004 Author Share Posted October 28, 2004 thanks to all of you..... you've made my mind clear now ! 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