Jump to content

Assign() Function issue - (Moved)

Recommended Posts



I am trying to assign values from an imported properties file  to variables ( Which I am trying to create via Assign Function As well ) . But Somehow the Assign function fails to create the variables due to which my script errors out with : "Variable not Defined Error"


Snippet of Code

Assign("myVariable","Some Random Text",$ASSIGN_FORCEGLOBAL)
ConsoleWrite("Newly Created Variable : " & $myVariable)


Even this simple script errors out with the error : "Variable not Defined". My goal is to read , create and assign value to values at run time .



Link to post
Share on other sites
Global $myVariable = "Some Random Text"
ConsoleWrite("Newly Created Variable : " & $myVariable&@CRLF)

Never used "assign", does this work for you?

PS: this is the wrong forum section.

Edited by careca

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples


Link to post
Share on other sites
  • Moderators

Moved to the appropriate forum, as the AutoIt Example Scripts forum very clearly states:


Share your cool AutoIt scripts, UDFs and applications with others.

Do not post general support questions here, instead use the AutoIt Help and Support forums.

Moderation Team

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to post
Share on other sites

Assign won't bring you anything useful in this context. Read and parse your input file into variables (no need to create then with "special" names), arrays, maps, whatever structure fits the bill.

I'm still curious to see a situation where Assign would be beneficial.

Edited by jchd

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites
3 hours ago, HIMBIN said:

My goal is to read , create and assign value to values at run time

Assign("myVariable","Some Random Text",2)
ConsoleWrite("IsDeclared: " & IsDeclared("myVariable") & @CRLF)
ConsoleWrite("Newly Created Variable : " & Eval("myVariable") & @CRLF)
Func meh()
    ConsoleWrite("Newly Created Variable in func: " & Eval("myVariable") & @CRLF)

if you read the help for Assign(), you'll find: If there is a need to use Assign() to create/write to a variable, then in most situations, Eval() should be used to read the variable and IsDeclared() should be used to check that the variable exists.

Then again, like everyone so far advised, try a different way to code it. 

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...