Sign in to follow this  
Followers 0
W3bMa5t3r

Arrays & Variables... ugh...

8 posts in this topic

Hey guys, I've been bashing my head against the wall for the past couple of hours, but apparently I can't seem to figure out arrays and variables for this instance even though I've written a few working scripts/programs (though bashing my head on the wall probably isn't helping... lol).

Anywho... I"m trying to read a file layout like such

overspeed=80
scrollmode=1
builtinvideo=true
disableinternat=true
locale=0
hidetaskbar=false
hidedesktop=false
radiomode=0
radioline=0
lazytag=false
allowallfreqs=false
browsertype=0

The lines change order constantly so I can't do a line count, to just jump to the setting and value I need to read/write from/to. Also not every file has the same settings, but do have the majority of the same. If anything some will have more. I will only edit the settings common to all the files.

I tried the readfile to array bit, which I'm able to do, but once it's in an array, I need to split each string/array (splitstring) at the "=" and have both the setting and value written to additional strings/arrays to be edited by a gui (got that part down)... with that part... I'm clueless apparently.

Any assistance would be greatly appreciated so as to prevent further damage of my wall :whistle:

Cheers...

Share this post


Link to post
Share on other sites



I don't understand, where a problem is.

Write your settings in an INI-file. All about this you'll find in autoit help.


Best Regards BugFix  

Share this post


Link to post
Share on other sites

I don't understand, where a problem is.

Write your settings in an INI-file. All about this you'll find in autoit help.

I've used ini files quite a bit in the other scripts I've writtin, but this... It's not a standard INI file. There are no 'sections' and the lines change with each edit or use by the main program. The only thing that is consistent is "setting=value". The number of settings can also be different from system to system.

Unless... can you not have a section? .. lol I didn't try that. would it just be ""?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I've used ini files quite a bit in the other scripts I've written, but this... It's not a standard INI file. There are no 'sections' and the lines change with each edit or use by the main program. The only thing that is consistent is "setting=value". The number of settings can also be different from system to system.

Unless... can you not have a section? .. lol I didn't try that. would it just be ""?

Nope, that didn't work... but what if I had the script open the file, write in a 'section' name at the beginning of the file. that would make the script read everything as keys in an ini file and once I'm done and have written everything back, I can delete the section name from the file and close it out... good idea?

Edited by W3bMa5t3r

Share this post


Link to post
Share on other sites

Anywho... I"m trying to read a file layout like such

overspeed=80
scrollmode=1
builtinvideo=true
Why not use _arraySearch? That returns the numeric location of the searched string. YOu then set your variable = the text in that location. To extract the values on either side of the "=" sign, just use any combination of the string functions (left, right, mid, trimleft, etc...) That way you don't have to write any files and I believe this would be faster than using ini files (2 or 3 microseconds?)...

...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format

Share this post


Link to post
Share on other sites

Just add a section at the top called everything. INI will work no matter what order items are in.

Share this post


Link to post
Share on other sites

I've used ini files quite a bit in the other scripts I've writtin, but this... It's not a standard INI file. There are no 'sections' and the lines change with each edit or use by the main program. The only thing that is consistent is "setting=value". The number of settings can also be different from system to system.

Unless... can you not have a section? .. lol I didn't try that. would it just be ""?

http://www.autoitscript.com/forum/index.ph...st&p=301009

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

Thanks guys for the tips. Looks like I'm going with writing in the [everything] section, using in the info as a regular/real ini file and then writing the info back to the file, and deleting the first line which is the [everything] section line. :whistle:

Cheers

Edited by W3bMa5t3r

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