Jump to content

Best Practice Multiple UI?


Recommended Posts

I was wondering the best practice for having multiple UI. I looked into the wiki to see how to do multiple UI but I think it could be done way better... 

I have about 5 different form and in each form I change the property of label and such. Right now i noticed that I need to set the variable at the begin of the program with dummy value to be able to change it later. I have about 50 variable now at the begin of my program. It working fine but i was just wondering if there is a better way to do it :S.

;Set Static Dummy Variable
#Region
Global $frmWindowsMenu = 9999, $frmMaitreDMenu = 9999, $frmRetailMenu = 9999,$frmLBossMenu = 9999, $frmWintecPrint = 9999
Global $OSArchi = 9999

Global $lblFirewallEtat = 9998, $btnFirewall = 9998
Global $lblUACEtat = 9998, $btnUAC = 9998
Global $lblDirCom = 9998, $btnDirCom = 9998
Global $lblIPv6Etat = 9998, $btnIPv6 = 9998
Global $lblSleepNetworkEtat = 9998, $btnSleepNetwork = 9998

Global $lblVersion = 9997, $lblLicense = 9997
Global $lblDoubleLicenseEtat = 9997, $btnDoubleLicense = 9997
Global $lblSlogTxtEtat = 9997, $btnSlogTxt = 9997
Global $lblCryptKeyEtat = 9997, $btnCryptKey = 9997
Global $lblBOSrvEtat = 9997, $btnBOSrv = 9997
Global $lblWindowsLogonEtat = 9997, $btnWindowsLogon = 9997
Global $lblNocommeEtat = 9997, $btnNocomme = 9997
Global $lblCRQEEtat = 9997, $btnCRQE = 9997

Global $lblTempWindowsEtat = 9996, $btnTempWindows = 9996

Global $btn_2400 = 9995, $btn_4800 = 9995, $btn_9600 = 9995, $btn_19200 = 9995, $btn_38400 = 9995, $btn_57600 = 9995, $btn_115200 = 9995
Global $btnAutoDetectCom = 9995, $btn_com1 = 9995, $btn_com2 = 9995, $btn_com3 = 9995, $btn_com4 = 9995, $btn_com5 = 9995, $btn_com6 = 9995, $btn_com7 = 9995
Global $btn_change2400 = 9995, $btn_change4800 = 9995, $btn_change9600 = 9995, $btn_change19200 = 9995, $btn_change38400 = 9995, $btn_change57600 = 9995, $btn_change115200 = 9995
Global $btn_testPrint = 9995, $btn_changeDensity1 = 9995, $btn_changeDensity2 = 9995, $btn_changeDensity3 = 9995, $btn_feedCut = 9995, $btn_disableChinese = 9995

;Print Dummy Variable
Global $aBaudRate[7]
$aBaudRate[0] = 2400
$aBaudRate[1] = 4800
$aBaudRate[2] = 9600
$aBaudRate[3] = 19200
$aBaudRate[4] = 38400
$aBaudRate[5] = 57600
$aBaudRate[6] = 115200
Global $sportSetError = ''
Global $CMPort = 1              ; Port
Global $CmBoBaud = 115200       ; Baud
Global $CmboDataBits = 8        ; Data Bits
Global $CmBoParity = "none"     ; Parity
Global $CmBoStop = 1            ; Stop
Global $setflow = 2             ; Flow
Global $RTSMode = 1
Global $DTRMode = 1
Global $iWait = 0
#EndRegion

Sry for my bad english it is my second language. Any advice is welcome :P. 

Link to comment
Share on other sites

What are all those 9999, 9998, ... "dummy values" for?

Your question isn't explicit at all.

BTW you can use a more compact style:

Global $aBaudRate = [2400, 4800, 9600, 19200, 38400, 57600, 115200]

 

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

Still clear as mud.

Can you post [short] runnable code showing the kind of problem you run into by not initializing all the values with dummy integers?

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

I need to go right now i have a convention to go :S Will send that the fastest i can! i have 1200 lines in my project so im gonna try to make it simple to reproduce the problem! Big thanks for the help!

Edited by MikiiTakagi
Link to comment
Share on other sites

  • Moderators

MikiiTakagi & jchd,

I imagine the OP are basing his code on the Managing Multiple GUIs tutorial in the Wiki.

As such you need these place holders ONLY if the control is being referenced within the GUIGetMsg loop of your script - this is to prevent the control Case being fired when there is no return from GUIGetMsg. This "No Event" return is 0 - as is the value of a non-assigned variable - and so would result in the Case code being actioned on every pass. Using a place holder prevents this as this arbitrarily large value is never returned by GUIGetMsg. So you should be able to reduce your problem by ONLY assigning placeholder values to those variables referenced within your idle loop.

Another solution is to create all your GUIs at the beginning of the script and use GUISetState to hide/show them as required - that way all the controls are automatically assigned valid ControlIDs and the problem no longer exists.

M23

 

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Exactly! thanks for the info. I just found out i can actually split my code into multiple au3 file. I started doing it and everyone works fine and easier to work with! Setting variable at the beginning of each file it needed make it so much easier to read!

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