Jump to content

Check if constant exists and if not create one?


Recommended Posts

Hello.

I'm trying make my script be able run with stable autoit version and beta without modifying the script for each version.

Beta version is missing some constants (and wise-versa)

How do I check if a constant exists and create one if it doesn't?

This works with beta, but fails with stable:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
;#AutoIt3Wrapper_Version=Beta
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <WinAPI.au3>

If Not IsDeclared("__WINVER") Then Global Const $__WINVER = "blah"
ConsoleWrite("$__WINVER: " & VarGetType($__WINVER) & @CRLF)

 

[EDIT]

So far the only work around I could come up with is to define a different constant and use Eval() to retrieve value of existing one:

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
;#AutoIt3Wrapper_Version=Beta
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****

#include <WinAPI.au3>

Global Const $__WINVER_NEW = IsDeclared("__WINVER") ? Eval("__WINVER") : "blah"

ConsoleWrite("$__WINVER_NEW: " & VarGetType($__WINVER_NEW) & @CRLF)

 

Edited by VAN0
Link to comment
Share on other sites

Link to comment
Share on other sites

Using _WinAPI_GetVersion() directly is simpler.

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 comment
Share on other sites

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