Sign in to follow this  
Followers 0
friends

When to use INI ?

17 posts in this topic

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.

Share this post


Link to post
Share on other sites



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.


 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

$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.


 

Spoiler

shoot_zpsfd329d66.png
dontbelieveeverythingyouthink_zps0e1e900

Madness is the first step to understanding...

Share this post


Link to post
Share on other sites

$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 forward

to other things !

Share this post


Link to post
Share on other sites

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 ? :)

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 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

I miss Java. I love booleans.

Share this post


Link to post
Share on other sites

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?


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

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!

Share this post


Link to post
Share on other sites

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!

<{POST_SNAPBACK}>

What ever makes you smile ... :):)

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

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.

Share this post


Link to post
Share on other sites

to check if the file's value (1 or 0), which one to use ?

CODE

If $value = 1 Then

MsgBox(0, "", "The value is correct")

Else

MsgBox(0, "", "The value is incorrect")

EndIf

or

CODE

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.

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.

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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

<{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)


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

#16 ·  Posted (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 by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites

thanks to all of you..... you've made my mind clear now ! :)

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