Jump to content

Want to save variables for use in another script


Recommended Posts

Okay, so I'm going to try to explain this as well as can:

I want to have a script where, using a GUI window and various inputs, I can save variables into another file to be used by other scripts. See example below for my lousy attempt at making an example of my intended application :P

;;;;;;;;;;;Script.au3;;;;;;;;;;;

#include <GUIConstants.au3>

#include <variables.au3>

;inputs

;formulas

;loops

;other random stuff

;after everything is said and done, I'll have a set of 2 or more variables

$variable_a = 666

$variable_b = 777

;I want to save/update these 2 variables (and nothing else) into "Variables.au3" to be recalled by this and other scripts

;;;;;;;;;;;Variables.au3;;;;;;;;;;;

$variable_a = 0

$variable_b = 0

Link to comment
Share on other sites

Okay, so with some searching and some testing I found a way to get the results I want, but not necessarily by the method I want.

#include <File.au3>

FileDelete ( "variables.au3" ) ;deletes existing variables.au3

_FileCreate ("variables.au3") ;creates new "blank" variables.au3

$file = FileOpen("variables.au3", 1)

; Check if file opened for writing OK

If $file = -1 Then

MsgBox(0, "Error", "Unable to open file.")

Exit

EndIf

FileWrite($file, "$variable_a = 666" & @CRLF) ;writes new value to line one

FileWrite($file, "$variable_b = 777") ;writes new value to line two

FileClose($file)

Does anyone have any suggestions for a more effective method?

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...