Sign in to follow this  
Followers 0
Champak

Default

24 posts in this topic

Is there a way to set up a default ini---and I don't mean the last option on the iniread part. (that is what I've found through searching for this answer.

Basically the program will have changeable settings/preference. Then the user can change those settings. If at anytime after they have changed them, the user has the option to press the "default" button and it returns to the "factory set" settings. How do I do this?

Thanks.

Share this post


Link to post
Share on other sites



Is there a way to set up a default ini---and I don't mean the last option on the iniread part. (that is what I've found through searching for this answer.

Basically the program will have changeable settings/preference. Then the user can change those settings. If at anytime after they have changed them, the user has the option to press the "default" button and it returns to the "factory set" settings. How do I do this?

Thanks.

if you've got the code already to let the user change their preferences, all you have to do, is upon pressing the button, read in the values, and change them just like the user changed them, except to the values in the ini. use fileinstall() to include the file in your compiled script.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Are you saying to have 2 ini scripts, and then when they press the default button, it reads from the second ini, and then they can save that to the first ini...the one that they usually edit and read from?

Also, I lost you from "except" on. Could you clarify?

Share this post


Link to post
Share on other sites

Are you saying to have 2 ini scripts, and then when they press the default button, it reads from the second ini, and then they can save that to the first ini...the one that they usually edit and read from?

Also, I lost you from "except" on. Could you clarify?

ok, here's easiest way to do it. have 1 ini that stores the default values, and 1 ini that is modified as user changes preferences. if they press the default button, get confirmation, then do a filecopy() and copy the default one right over the user controlled.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

Cant you have 1 ini with sections for each setting and then in each section have "default=xxxxxxx" and "modified=xxxxxxx"? Then based on waht the user wants read the default of modified value.


_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Share this post


Link to post
Share on other sites

Cant you have 1 ini with sections for each setting and then in each section have "default=xxxxxxx" and "modified=xxxxxxx"? Then based on waht the user wants read the default of modified value.

you could, i was saying the 'easiest way'. tried to list a way that doesn't require any decision making at all, just an event that resets everything.

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

This code shows the basic idea of what your trying to do i think.

HotKeySet( "{Esc}", "exit_now" )
HotKeySet( "`", "toggle" )

IniWrite( ".\settings.ini","setting1", "default", "DEFAULT_SETTING1" ) 
IniWrite( ".\settings.ini","setting1", "modified", "MODIFIED_SETTING1" )

IniWrite( ".\settings.ini","setting2", "default", "DEFAULT_SETTING2" )
IniWrite( ".\settings.ini","setting2", "modified", "MODIFIED_SETTING2" )

Global $val = 1

While 1

If $val = 0 Then
    $output = "setting1: " & IniRead( ".\settings.ini","setting1", "default", "-1" ) & @CRLF & _
          "setting2: " & IniRead( ".\settings.ini","setting2", "default", "-1" )
Else
    $output = "setting1: " & IniRead( ".\settings.ini","setting1", "modified", "-1" ) & @CRLF & _
          "setting2: " & IniRead( ".\settings.ini","setting2", "modified", "-1" )
EndIf
    
ToolTip( "Press tilda key(`) to change settings" & @CRLF & $output )
Sleep( 100 )

Wend

Func toggle()
    $val = Abs( $val - 1 )      
EndFunc

Func exit_now()
    Exit
EndFunc

_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Share this post


Link to post
Share on other sites

Personal Opinion:

Easiest way about this is the following.

Structure your INI as follows

;Default Settings (DO NOT CHANGE)
[settingsDefault]
Setting1=12581
Setting2=Jon
Setting3=AutoIt
Setting4=someone@noone.com

;Current Settings (CHANGED BY *YOUR PROGRAM HERE*)
[settingsCurrent]
Setting1=3123
Setting2=Suzie
Setting3=VBScript
Setting4=imessedupmysettings@idiot.com

Now when they press the "Default Settings" button it reads the settingsDefault and replaces the settingsCurrent with the default values using INIRead then INIWrite.

Func _RestoreDefaults()
    $iniSetting1 = INIRead("your.ini", "settingsDefault", "Setting1")
    $iniSetting2 = INIRead("your.ini", "settingsDefault", "Setting2")
    $iniSetting3 = INIRead("your.ini", "settingsDefault", "Setting3")
    $iniSetting4 = INIRead("your.ini", "settingsDefault", "Setting4")

    INIWrite("your.ini", "settingsCurrent", "Setting1", $iniSetting1)
    INIWrite("your.ini", "settingsCurrent", "Setting2", $iniSetting2)
    INIWrite("your.ini", "settingsCurrent", "Setting3", $iniSetting3)
    INIWrite("your.ini", "settingsCurrent", "Setting4", $iniSetting4)
EndFunc

That in my personal opinion is the easiest option, but everyone has their own comfort level :)

Enjoy!,

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

Personal Opinion:

Easiest way about this is the following.

Structure your INI as follows

;Default Settings (DO NOT CHANGE)
[settingsDefault]
Setting1=12581
Setting2=Jon
Setting3=AutoIt
Setting4=someone@noone.com

;Current Settings (CHANGED BY *YOUR PROGRAM HERE*)
[settingsCurrent]
Setting1=3123
Setting2=Suzie
Setting3=VBScript
Setting4=imessedupmysettings@idiot.com

Now when they press the "Default Settings" button it reads the settingsDefault and replaces the settingsCurrent with the default values using INIRead then INIWrite.

Func _RestoreDefaults()
    $iniSetting1 = INIRead("your.ini", "settingsDefault", "Setting1")
    $iniSetting2 = INIRead("your.ini", "settingsDefault", "Setting2")
    $iniSetting3 = INIRead("your.ini", "settingsDefault", "Setting3")
    $iniSetting4 = INIRead("your.ini", "settingsDefault", "Setting4")

    INIWrite("your.ini", "settingsCurrent", "Setting1", $iniSetting1)
    INIWrite("your.ini", "settingsCurrent", "Setting2", $iniSetting2)
    INIWrite("your.ini", "settingsCurrent", "Setting3", $iniSetting3)
    INIWrite("your.ini", "settingsCurrent", "Setting4", $iniSetting4)
EndFunc

That in my personal opinion is the easiest option, but everyone has their own comfort level :)

Enjoy!,

JS

very similar to my idea, except mine has 2 ini files:

both start as:

[settingsCurrent]

Setting1=12581

Setting2=Jon

Setting3=AutoIt

Setting4=someone@noone.com

one is edited by user whenever a setting is changed, if they click a button that says restore defaults, the code for said button would be:

FileCopy($defaultini,$personalini,1)

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#10 ·  Posted

Personal Opinion:

Easiest way about this is the following.

Structure your INI as follows

;Default Settings (DO NOT CHANGE)
[settingsDefault]
Setting1=12581
Setting2=Jon
Setting3=AutoIt
Setting4=someone@noone.com

;Current Settings (CHANGED BY *YOUR PROGRAM HERE*)
[settingsCurrent]
Setting1=3123
Setting2=Suzie
Setting3=VBScript
Setting4=imessedupmysettings@idiot.com

Now when they press the "Default Settings" button it reads the settingsDefault and replaces the settingsCurrent with the default values using INIRead then INIWrite.

Func _RestoreDefaults()
    $iniSetting1 = INIRead("your.ini", "settingsDefault", "Setting1")
    $iniSetting2 = INIRead("your.ini", "settingsDefault", "Setting2")
    $iniSetting3 = INIRead("your.ini", "settingsDefault", "Setting3")
    $iniSetting4 = INIRead("your.ini", "settingsDefault", "Setting4")

    INIWrite("your.ini", "settingsCurrent", "Setting1", $iniSetting1)
    INIWrite("your.ini", "settingsCurrent", "Setting2", $iniSetting2)
    INIWrite("your.ini", "settingsCurrent", "Setting3", $iniSetting3)
    INIWrite("your.ini", "settingsCurrent", "Setting4", $iniSetting4)
EndFunc

That in my personal opinion is the easiest option, but everyone has their own comfort level :)

Enjoy!,

JS

I agree with js, you could make it a bit shorter yet

Func _RestoreDefaults()
    INIWrite("your.ini", "settingsCurrent", "Setting1", INIRead("your.ini", "settingsDefault", "Setting1"))
    INIWrite("your.ini", "settingsCurrent", "Setting2", INIRead("your.ini", "settingsDefault", "Setting2"))
    INIWrite("your.ini", "settingsCurrent", "Setting3", INIRead("your.ini", "settingsDefault", "Setting3"))
    INIWrite("your.ini", "settingsCurrent", "Setting4", INIRead("your.ini", "settingsDefault", "Setting4"))
EndFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

I agree with js, you could make it a bit shorter yet

Func _RestoreDefaults()
    INIWrite("your.ini", "settingsCurrent", "Setting1", INIRead("your.ini", "settingsDefault", "Setting1"))
    INIWrite("your.ini", "settingsCurrent", "Setting2", INIRead("your.ini", "settingsDefault", "Setting2"))
    INIWrite("your.ini", "settingsCurrent", "Setting3", INIRead("your.ini", "settingsDefault", "Setting3"))
    INIWrite("your.ini", "settingsCurrent", "Setting4", INIRead("your.ini", "settingsDefault", "Setting4"))
EndFunc
Thank you, and I rarely remember about embedding functions... I think one line one command.

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

#12 ·  Posted (edited)

Thanks, This is what I am trying to do....

Case $msg = $DefaultSleepTimes
            iniwrite($Where, 'Sleep', 'SleepSend1', iniread($Where, 'DefaultSleep', 'SleepSend1'))
            iniwrite($Where, 'Sleep', 'SleepSend2', iniread($Where, 'DefaultSleep', 'SleepSend2'))

And I am getting the following error when I hit the button.

Case $msg = $DefaultSleepTimes
            iniwrite($Where, 'Sleep', 'SleepSend1', iniread($Where, 'DefaultSleep', 'SleepSend1'))
            iniwrite($Where, 'Sleep', 'SleepSend2', ^ ERROR

ERROR: Incorrect number of parameters in function call

Help please.

Edited by Champak

Share this post


Link to post
Share on other sites

#13 ·  Posted

you need another parameter for iniread, it is default (use "")


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I tried that already, both with and without values in the quotes and I get the following:

iniwrite(................................
^ERROR

ERROR: Incorrect number of parameters in function call
Edited by Champak

Share this post


Link to post
Share on other sites

#15 ·  Posted

Case $msg = $DefaultSleepTimes
            iniwrite($Where, 'Sleep', 'SleepSend1', iniread($Where, 'DefaultSleep', 'SleepSend1', ""))
            iniwrite($Where, 'Sleep', 'SleepSend2', iniread($Where, 'DefaultSleep', 'SleepSend2', ""))
that works...


My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

Share this post


Link to post
Share on other sites

#17 ·  Posted

Thanks RazerM, that works for me too. I was putting it on both the read and write.

w0uter, I don't know...just never thought about fileinstall. And I would prefer to make this as simple, user friendly, and fast as possible.

One last problem with this though...and I suspect the same problem will occur with copying the file as well. When the default is hit, the new numbers don't appear in the input boxes. The natural inclination is to press save after the default, however if the save is pressed it will just resave what is currently being displayed in the input boxes....which defeats the whole purpose. Any solution to have the default populate the inputs when pressed? The following is what I currently have set up:

---------------------------Code

$sleep1=IniRead($Where, 'Sleep', 'SleepSend1', 'no')
$sleep2=GUICtrlCreateInput($sleep1, 230, 35, 36, 19, $ES_NUMBER)

---------------------------Saves to ini

Case $msg = $SaveSleepTimes     ;Saves preferences - Sleep and returns to main page
iniwrite($Where, 'Sleep', 'SleepSend1', guictrlread($sleep2))

---------------------------Default function

Case $msg = $DefaultSleepTimes
iniwrite($Where, 'Sleep', 'SleepSend1', iniread($Where, 'DefaultSleep', 'DefaultSleepSend1', ""))

Share this post


Link to post
Share on other sites

#18 ·  Posted

Out of curiousity, since you have a lot of posts here lately, what are you making? (The sleep saving thing kind of threw me off if it were a normal application)


[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

#19 ·  Posted (edited)

It is a $2000.00 audio engineering/post production software. With that hefty price it is lacking one essential tool that other apps in its range have. An automatic mixdown function, which can be VERY time consuming. This function has been begged for for the past 15 months by its users, and through all of the feature upgrades they have not included this essential feature. So I have finally gotten fed up and decided to put it together myself, with extra bells and whistles with sights on future upgrades.

What the sleep function is for is a matter of optimization. Its window system does not register the titles so to speak. The titles come in as text view, and on top of that, the gui in it sometimes reacts slow in certain functions. So the sleep time will allow the user to optimise how fast the mixdown goes based on what their system can handle. My system is decked out, so I can have very short sleep times, however, I've tested this with another studio whos app is not on their main system...so the computer is a little slower (1.?gigs and 500MB) and the script gets caught up. That's why I'm having the sleep times selectable.

I'm hoping I can solve mine and a lot of peoples problems with this.

Edited by Champak

Share this post


Link to post
Share on other sites

Thanks RazerM, that works for me too. I was putting it on both the read and write.

w0uter, I don't know...just never thought about fileinstall. And I would prefer to make this as simple, user friendly, and fast as possible.

One last problem with this though...and I suspect the same problem will occur with copying the file as well. When the default is hit, the new numbers don't appear in the input boxes. The natural inclination is to press save after the default, however if the save is pressed it will just resave what is currently being displayed in the input boxes....which defeats the whole purpose. Any solution to have the default populate the inputs when pressed? The following is what I currently have set up:

---------------------------Code

$sleep1=IniRead($Where, 'Sleep', 'SleepSend1', 'no')
$sleep2=GUICtrlCreateInput($sleep1, 230, 35, 36, 19, $ES_NUMBER)

---------------------------Saves to ini

Case $msg = $SaveSleepTimes ;Saves preferences - Sleep and returns to main page
iniwrite($Where, 'Sleep', 'SleepSend1', guictrlread($sleep2))

---------------------------Default function

Case $msg = $DefaultSleepTimes
iniwrite($Where, 'Sleep', 'SleepSend1', iniread($Where, 'DefaultSleep', 'DefaultSleepSend1', ""))
I dont know if you have figured this out yet or not, but YOU need to repopulate the values in the input boxes as part of the "Default" function. Then they can press save or not as it will already be saved.

You have to update the gui. Shouldnt be a big deal a few GUICtrlSetData() will set you straight.

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

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