Jump to content
Sign in to follow this  
Zomp

conditional global dim statement

Recommended Posts

Zomp

Suppose I have a script that I can launch in two modes:

1. without parameters, so that is starts in a GUI-driven mode;

2. with a parameter, so that it starts in batch mode.

Briefly, the GUI-mode offers the newbie user a graphical interface to specify the parameters that a veteran user can write directly on a command line prompt.

Suppose that for the GUI-driven mode I have needed to make several global dims, which are not needed in the batch mode.

Is it possible to make the global statements conditional? That is, to write something similar to what follows:

if $cmdline[0]>0 then
     do nothing;
else
     global $VarA1, $VarA2, and so on
endif
Edited by Zomp

Share this post


Link to post
Share on other sites
system24

I think it is possible, because conditional includes are possible too.

Just test it.


[center]It's a question of mind over matter, if I don't mind, it doesn't matter.[/center]

Share this post


Link to post
Share on other sites
martin

I think it is possible, because conditional includes are possible too.

Just test it.

You can make declarations conditional but includes are not conditional because they have to be included before any of the script is executed.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites
Zomp

You can make declarations conditional but includes are not conditional because they have to be included before any of the script is executed.

Can you make an example? I do not know the syntax. Many thanks for your patience.

Share this post


Link to post
Share on other sites
Xand3r

Your example will do just fine !

what martin means by not being able to have conditional includes is this:

if $var=1 then
#include<udf1.au3>
else
#include<udf2.au3>
endif

both udf1 and udf2 are included... before any of the code is executed


Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro

Share this post


Link to post
Share on other sites
martin

Your example will do just fine !

what martin means by not being able to have conditional includes is this:

if $var=1 then
#include<udf1.au3>
else
#include<udf2.au3>
endif

both udf1 and udf2 are included... before any of the code is executed

Yes.

@zomp.

You only need to try what you have posted and you will find the answer to you rquestion even faster than the replies on this forum!

if 2 = 3 then
 Global $var1 = 3
endif

$var1 += 2
[code]

Or any way you like
[code]
Global $var1
If $CmdLine[0] = 0 then 
    $var1 = SetVariableWithGui()
else
    $var1 = $CmdLine[1]
endif

.
..
Func SetVariableWithGui()
    Local $gui = Guicreate(......
    Local $input1 = GuiCtrlCreateInput(
   ;blah

   ;blah

    return GuiCtrlRead($input2)
endfunc
Edited by martin

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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
Sign in to follow this  

×