KeshHERE

How to change Variable value permenently!!?

8 posts in this topic

$gui1=GUICreate("google", 250, 150)
$input1 = GUICtrlCreateInput("", 75, 40, 100, 25)
$OK1 = GUICtrlCreateButton("Done", 100, 120, 55, 20,$BS_DEFPUSHBUTTON)
GUISetState(@SW_SHOW,$gui1)

$google="google,hi,ih"

While 1
 Switch GUIGetMsg()
      Case $GUI_EVENT_CLOSE
         Exit
      Case $OK1
         CHANGEVARIABLE($google,'hi,hi,hi')

   EndSwitch
WEnd

So, what i want to do is..

I want to change $google variable value after pressed "ok" button, so that next time i open script (to run or to edit), value of $google will be new value.

it should permanently change value of that variable in script, so that even after i close this script and reopen it next day, new (changed value 'hi,hi,hi') value is there, rather then old value "google,hi,ih".

 

i don't think there is any direct function for it cause it checked it, so is there any way to do it??

 

Share this post


Link to post
Share on other sites



Save the value in an INI file or somewhere in the registry and restore that when you start the program.

Jos

 


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

thanks, using iniwrite() function right?

Share this post


Link to post
Share on other sites

Yes @KeshHERE. Use IniWrite and IniRead :D


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

thank you very much..

Actually i am trying to write an AI (not high level just basic).

After i complete it, is there a way to share it among all autoit user so that you can check it for improvement or use it for their daily tasks?

Share this post


Link to post
Share on other sites

Yes, you can share your programs here: https://www.autoitscript.com/forum/files/

 

Good luck, TD ;)


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

Spoiler

My contributions to the AutoIt Community

Some messages & Apologizes:

If I hurt you, Please accept my apologies, I never (regardless of the situation) mean to hurt anybody!!!

Also, I am very busy with my project so I will appear in the last row of the online list, if you want to contact me: Email@TheDcoder.xyz

Or you can have a nice chat with me in freenode, I use the same nick on freenode too!

3fHNZJ.gif

PLEASE JOIN ##AutoIt AND HELP THE IRC AUTOIT COMMUNITY!

Share this post


Link to post
Share on other sites

for simple data: 

Global $hGUI = GUICreate("Google", 407, 55, -1, -1)
Global $Input1 = GUICtrlCreateInput("google,hi,ih", 115, 16, 188, 21)
Global $OK1 = GUICtrlCreateButton("SAVE", 316, 8, 87, 36)
GUICtrlCreateLabel("Input data to save:", 16, 18, 93, 17)

Global $sFileToSaveData = @ScriptDir & "\" & @ScriptName & "_DATA.ini" ; Change to path you want to save
Global $Google = FileRead($sFileToSaveData)
If Not @error And $Google <> "" Then GUICtrlSetData($Input1, $Google)
GUISetState(@SW_SHOW, $hGUI)

While 1
    Switch GUIGetMsg()
        Case -3
            Exit
        Case $OK1
            $Google = GUICtrlRead($Input1)
            CHANGEVARIABLE($Google)
            MsgBox(32, "Done", $Google & " saved to" & $sFileToSaveData)
    EndSwitch
    Sleep(10)
WEnd

Func CHANGEVARIABLE($VARIABLE)
    Local $hOpen = FileOpen($sFileToSaveData, 2 + 8 + 128)
    FileWrite($hOpen, $VARIABLE)
    Return SetError(@error, FileClose($hOpen), 1)
EndFunc   ;==>CHANGEVARIABLE

 


Regards,
 

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