Jump to content

How to save variable globally so can use later even if setting it is dissabled, like if the variable was saved in cache?


xuzo
 Share

Recommended Posts

If you try to write a variable to notepad - it must first exist. If you don't create the variable - it doesn't exist. If you want to write information to notepad, the information has to come from somewhere. Go figure!

BTW - IV does not work.

Step IV does work. The pop up message displays the correct variable, time after time, even if it's commented out.

Link to comment
Share on other sites

  • Developers

Your posted step IV will not work and error out on the MsgBox() as it doesn't know the value for $my_variable.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

It works for me, I'm pretty sure I'm not clear as what I want done here...

When I press F5, regardless if:

Global $my_variable = "text"

is commented or not.

The pop up works and displays properly, there is an error in the console, but it doesn't affect the results I need.

My goal is to declare at the top of  the script, and be able to comment out the declaration, and still have work later in the script.

Sorry...I'm sure I have all this wrong... !

I'm trying to emulate the functionality of Vista Task studio, http://www.vtaskstudio.com/index.php

That software lets you declare variables, and pause steps, then use them later.

I have other ways to do this, I will simply save the variables in a separate text file, then write a new script and re-declare, something like that.

Thanks to everybody, you can close this post, I give up!

Edited by xuzo
Link to comment
Share on other sites

Depending on which version of AutoIt / SciTE you are using, and whether you run the script from the SciTE console, or not, the message may appear. AutoIt throws an error on the ConsoleWrite section afterwards. SciTE should throw an error immediately. Older versions of AutoIt had the option to ignore some warnings - this may still be possible (I'm not sure). The code in #IV is incorrect regardless.

Edited by czardas
Link to comment
Share on other sites

Depending on which version of AutoIt / SciTE you are using, and whether you run the script from the SciTE console, or not, the message may appear. AutoIt throws an error on the ConsoleWrite section afterwards. SciTE should throw an error immediately. Older versions of AutoIt had the option to ignore some warnings - this may still be possible (I'm not sure). The code in #IV is incorrect regardless.

Well SciTe shouldn't throw any error. Au3Check should catch it. ;) 

I will answer every single PM, and you are free to ask anything anytime.

Link to comment
Share on other sites

  • 3 weeks later...

If you don't want to declare the variable and still use it then it is "possible" but only if you are not going to change this "variable" later.

This is the FAKE variable concept and I personally use it a lot

I changed your non-working example
 

;Global $my_variable = "text"

IniRead("IniFile.ini", "Storage", "Variable", "")
IniWrite("IniFile.ini", "Storage", "Variable", $my_variable)
Local $hWnd = WinWait("[CLASS:Notepad++]", "", 10)
    WinActivate($hWnd)
    send ($my_variable)

 

 

To this:

#AutoIt3Wrapper_Run_Au3Stripper=y
#Au3Stripper_Parameters=/PE
; ^ Very important for this to work


;Global $my_variable = "text"
;^ This will not work.

Global Const $my_variable = "test"
;^ This will work and when you compile the script, this variable will be deleted and will not declared + the script will work with no error.


IniRead("IniFile.ini", "Storage", "Variable", "")
IniWrite("IniFile.ini", "Storage", "Variable", $my_variable)
Local $hWnd = WinWait("[CLASS:Notepad++]", "", 10)
WinActivate($hWnd)
send ($my_variable)

 

What is happening here is that you use variable without declaring it only if you compile it through SciTE.

When you compile it through through SciTE, this code is converted to this:

IniRead("IniFile.ini", "Storage", "Variable", "")
IniWrite("IniFile.ini", "Storage", "Variable", "test")
Local $hWnd = WinWait("[CLASS:Notepad++]", "", 10)
WinActivate($hWnd)
send("test")

 

What it does it just replace every "$my_variable" to its value - in this case "test"

Edited by Guest
Link to comment
Share on other sites

  • 4 weeks later...

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