Sign in to follow this  
Followers 0
Raider

Flushing All Declared Env Vars

3 posts in this topic

Hi folks,

I'm having some trouble with AU3GUI.

AU3GUi workes with env vars that will exist until my script exists. The problem I'm running into is that I want to call several GUIs before I quit my script. Because all the env vars are still assigned I get some really messed up results and buttons/boxes/labels I used in one GUI before but one GUI later, I don't need them anymore.

Well, let's say I have GUI A and B.

GUI A has Button1, Button2, Label1,2,3 and Combo1.

GUI B should have Button1, Label1 and List1.

Because all the vars from GUI A still exist, GUI B has:

Button1, Button2, Label1,2,3, Combo1, List1.

I think it's pretty obvious that GUI cannot be used in this state.

So, is there a way to flush all recently set envvars without using an external .exe or quitting my script?

I thought about a do...until loop that checks for each var and resets it with EnvSet("var", "") but this will get really complicated when I have a envvar with 3 variable values.

Any ideas?

Share this post


Link to post
Share on other sites



Larry put at the bottom of the "Intro Tutorial.au3", that comes with the AU3GUI, a function called ClearGUi()... would that work for you ?

Func ClearGUI()
   EnvSet("GUI.title","")
   EnvSet("GUI.focus","")
   EnvSet("GUI.action","")
   EnvSet("GUI.file","")
   For $a = 1 to 10
      EnvSet("OBJ" & $a & ".type","")
      EnvSet("OBJ" & $a & ".text","")
      EnvSet("OBJ" & $a & ".close","")
      EnvSet("OBJ" & $a & ".submit","")
      EnvSet("OBJ" & $a & ".x","")
      EnvSet("OBJ" & $a & ".y","")
      EnvSet("OBJ" & $a & ".w","")
      EnvSet("OBJ" & $a & ".h","")
   Next
EndFunc

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Yeah, thanks... I think that will work.

I'll have to add some more vars and for...next loops but I think it's OK :whistle:

I was looking for a command like ClearAllEnv() but I guess i'll have to be confident with that.

If somebody has a quicker solution just post it, please B)

Edit:

Ok, I wrote some functions... They are not that professional :angry: but maybe someone finds them useful...

; ###### GUI-FUNCTIONS ######

func g_text ($obj, $text) ; Usage: g_test(1, "This is my text for object 1")

EnvSet("OBJ"& $obj &".text", $text)

$g_text_set=1

endfunc

func g_data ($obj, $datanum, $data)

EnvSet("OBJ"& $obj &".data"& $datanum &"", $data)

$g_data_set=1

endfunc

func g_pos ($obj, $x, $y) ; Usage (3, 15, 20) to set obj 3 to 15/20

EnvSet("OBJ"& $obj &".x", $x)

EnvSet("OBJ"& $obj &".y", $y)

$g_pos_set=1

endfunc

func g_size ($obj, $w, $h)

EnvSet("OBJ"& $obj &".w", $w)

EnvSet("OBJ"& $obj &".h", $h)

$g_size_set=1

endfunc

func g_file ($obj, $text)

EnvSet("OBJ"& $obj &".file", $text)

$g_file_set=1

endfunc

func g_type ($obj, $type)

EnvSet("OBJ"& $obj &".type", $type)

$g_type_set=1

endfunc

func guititle ($titel)

EnvSet("GUI.Title",$titel)

$guititle_set=1

endfunc

func g_focus ($focus)

EnvSet("GUI.Focus", $focus)

$g_focus_set=1

endfunc

func g_disableoe ($eventobj, $eventnumber, $targetobj) ; Usage g_disableoe(1, 1, 5) To disable obj 5 when obj1 changes. The second number is the number of disabloeoe-events for obj 5

EnvSet("OBJ"& $eventobj &".disable"& $eventnumber &"", $targetobj)

$g_disableoe_set=1

endfunc

func g_enableoe ($eventobj, $eventnumber, $targetobj)

EnvSet("OBJ"& $eventobj &".enable"& $eventnumber &"", $targetobj)

$g_enableoe_set=1

endfunc

func g_disabled ($obj)

EnvSet("OBJ"& $obj &".disabled", "1")

$g_disabled_set=1

endfunc

func g_submit ($obj)

EnvSet("OBJ"& $obj &".submit", "1")

$g_submit_set=1

endfunc

func g_close ($obj)

EnvSet("OBJ"& $obj &".close", "1")

$g_close_set=1

endfunc

func g_cancel ($obj)

EnvSet("OBJ"& $obj &".cancel", "1")

$g_cancel_set=1

endfunc

func g_selected ($obj)

EnvSet("OBJ"& $obj &".selected", "1")

$g_selected_set=1

endfunc

func g_hidden ($obj)

EnvSet("OBJ"& $obj &".hidden", "1")

endfunc

func guiicon ($icon)

EnvSet("GUI.icon", $icon)

$g_guiicon_set=1

endfunc

func guisize ($w, $h)

EnvSet("GUI.w", $w)

EnvSet("GUI.h", $h)

$guisize_set=1

endfunc

func guidata ($datamode)

EnvSet("GUI.action", $datamode)

$guidata_set=1

endfunc

func guistart ()

FileInstall("au3gui.exe", "c:\au3gui.exe", 1)

AutoItWinSetTitle("AU3GUI...")

runwait("c:\au3gui.exe")

FileDelete("c:\au3gui.exe") ; Cleanup!

EnvSet("GUI.title",$progname)

EnvSet("GUI.focus","")

EnvSet("GUI.action","")

EnvSet("GUI.file","")

For $a = 1 to 15

EnvSet("OBJ" & $a & ".type","")

EnvSet("OBJ" & $a & ".tooltip","")

EnvSet("OBJ" & $a & ".hidden","")

EnvSet("OBJ" & $a & ".selected","")

EnvSet("OBJ" & $a & ".disabled","")

EnvSet("OBJ" & $a & ".text","")

EnvSet("OBJ" & $a & ".close","")

EnvSet("OBJ" & $a & ".cancel","")

EnvSet("OBJ" & $a & ".submit","")

EnvSet("OBJ" & $a & ".x","")

EnvSet("OBJ" & $a & ".y","")

EnvSet("OBJ" & $a & ".w","")

EnvSet("OBJ" & $a & ".h","")

for $b = 1 to 15

EnvSet("OBJ"& $a &".data"& $b &"", "")

EnvSet("OBJ"& $a &".disable"& $b &"", "")

EnvSet("OBJ"& $a &".enable"& $b &"", "")

EnvSet("OBJ"& $a &".hide"& $b &"", "")

EnvSet("OBJ"& $a &".show"& $b &"", "")

next

Next

endfunc

Have fun and thanks again for support.

Edited by Raider

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  
Followers 0