Sign in to follow this  
Followers 0
strate

Expandable Programs?

3 posts in this topic

I've created a program here at work that eliminated alot of the time spent doing my job :o The program prints various labels for production. My problem is I need to write the new version so that the day I no longer work for the company they can add to it themselves. Currently the user has 3 groups of controls to click to enable them to create the correct print job. Each control is assigned a unique value. All the values are then added up. This final number will give the user requested print job. Here is the current controls, values for the current controls, and then the printjob for the final value.

$ADDRESS_SELECTION_GROUP_X = 258
$ADDRESS_SELECTION_GROUP_Y = 25
$ADDRESS_LABELS_GROUP = GUICtrlCreateGroup("Address Labels", $ADDRESS_SELECTION_GROUP_X - 10, $ADDRESS_SELECTION_GROUP_Y, 165, 100)
$GM_ADD = GUICtrlCreateRadio("GM Address Label", $ADDRESS_SELECTION_GROUP_X, $ADDRESS_SELECTION_GROUP_Y + 20, 120, 20)
$NON_GM_ADD = GUICtrlCreateRadio("NON-GM Address Label", $ADDRESS_SELECTION_GROUP_X, $ADDRESS_SELECTION_GROUP_Y + 40, 135, 20)
$NONE_ADD = GUICtrlCreateRadio("None", $ADDRESS_SELECTION_GROUP_X, $ADDRESS_SELECTION_GROUP_Y + 60, 135, 20)
$MISC_SELECTION_GROUP_X = 258
$MISC_SELECTION_GROUP_Y = 280
$MISC_SELECTION_GROUP_INPUT_W = 230
$MISC_SELECTION_GROUP_INPUT_H = 80
$MISC_LABELS_GROUP = GUICtrlCreateGroup("Misc. Labels", $MISC_SELECTION_GROUP_X - 10, $MISC_SELECTION_GROUP_Y - 10, 165, 100)
$AUDIT = GUICtrlCreateCheckbox("Audit Tag", $MISC_SELECTION_GROUP_X, $MISC_SELECTION_GROUP_Y + 5, 120, 20)
$4X6_OP = GUICtrlCreateRadio("4X6 Over Pack Labels", $MISC_SELECTION_GROUP_X, $MISC_SELECTION_GROUP_Y + 25, 135, 20)
$5X3_OP = GUICtrlCreateRadio("5X3 Over Pack Labels", $MISC_SELECTION_GROUP_X, $MISC_SELECTION_GROUP_Y + 45, 135, 20)
$NONE_OP = GUICtrlCreateRadio("No Over Pack Labels", $MISC_SELECTION_GROUP_X, $MISC_SELECTION_GROUP_Y + 65, 135, 20)

If GUICtrlRead($GM_ADD) = 1 Then
        $Label_Total = $Label_Total + 1
    EndIf
    If GUICtrlRead($NON_GM_ADD) = 1 Then
        $Label_Total = $Label_Total + 16
    EndIf
    If GUICtrlRead($AUDIT) = 1 Then
        $Label_Total = $Label_Total + 256
    EndIf
    If GUICtrlRead($4X6_OP) = 1 Then
        $Label_Total = $Label_Total + 4096
    EndIf
    If GUICtrlRead($5X3_OP) = 1 Then
        $Label_Total = $Label_Total + 65536
    EndIf

Select
        Case $Label_Total = 1
            printset1()
        Case $Label_Total = 16
            printset4()
        Case $Label_Total = 256
            printset2()
        Case $Label_Total = 257
            printset3()
        Case $Label_Total = 272
            printset5()
        Case $Label_Total = 4096
            Over_Pack_Labels()
        Case $Label_Total = 4097
            printset14()
        Case $Label_Total = 4112
            printset13()
        Case $Label_Total = 4352
            printset15()
        Case $Label_Total = 4353
            printset8()
        Case $Label_Total = 4368
            printset7()
        Case $Label_Total = 65536
            Over_Pack_Labels()
        Case $Label_Total = 65537
            printset16()
        Case $Label_Total = 65552
            printset17()
        Case $Label_Total = 65792
            printset12()
        Case $Label_Total = 65793
            printset9()
        Case $Label_Total = 65808
            printset10()
    EndSelect

How can I create this so that they can add new labels? I know I need to use list boxes instead of Radios. My problem is assembling the print job, telling it what to do. I need help bad I think I've coded myself into a corner, lol.


INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

1. Design a configuration file, and read your settings/ values from that at runtime. This can be as simple or complex as your needs require.

2. DOCUMENT, DOCUMENT, document.

You can use an ini file, XML w/ a configurable front-end, etc.

I use FileInstall() to put my default .config file in @WorkingDir if it doesn't exist, (this protects against server name / path changes and accidental code deletions. Weakness is that there is no way that I am aware of to post-compile an updated .ini file so that the new one is installed after a new installation; this could be handled by a setup routine or a patch utility that would wrap your au3 exe and their latest config for new installs.

Include a menu option in your code to modify the config file.

I also include an option to extract source in code I write for customers who own the source, with notes in the source as to version / website of any necessary tools (including au3 itself). If client owns source, I also include website link to all tools used, and the versions of tools used to create the compiled code or tools on which compiled code depends. That way I have a one-line entry in the help file (also fileinstalled) about how to extract / build source if the need to change source occurs.

NOTE: Assign() and Eval() are your friends in this regard, you can use things like

Global $MAX_ENTRIES = IniRead($ini_file,"MAIN","MAX_ENTRIES",100)
Global $Array[$MAX_ENTRIES + 1]
For $i = 1 to $MAX_ENTRIES
  Assign ("Label" & $i)  = IniRead($ini_file,".............................) 
Next
Edited by flyingboz

Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

I've created a program here at work that eliminated alot of the time spent doing my job :o

Then why you wanna leave ?? :geek:

Your parameters could go in an ini_file

You need to use relative positioning for your controls, and account for desktop size, such that a huge ini doesn't leave you offscreen w/ no way to get where you want to go. Scrollbars work well for this kind of thing, or logic that creates additional tab groupings, etc.

$ADDRESS_SELECTION_GROUP_X = 258
$ADDRESS_SELECTION_GROUP_Y = 25
$ADDRESS_LABELS_GROUP = GUICtrlCreateGroup("Address Labels", $ADDRESS_SELECTION_GROUP_X - $AUDIT = GUICtrlCreateCheckbox("Audit Tag", $MISC_SELECTION_GROUP_X,

The below would be faster if it were a case statement , too.

If GUICtrlRead($GM_ADD) = 1 Then
        $Label_Total = $Label_Total + 1
    EndIf
    If GUICtrlRead($NON_GM_ADD) = 1 Then
        $Label_Total = $Label_Total + 16
    EndIf
    If GUICtrlRead($AUDIT) = 1 Then
        $Label_Total = $Label_Total + 256
    EndIf
    If GUICtrlRead($4X6_OP) = 1 Then
        $Label_Total = $Label_Total + 4096
    EndIf
    If GUICtrlRead($5X3_OP) = 1 Then
        $Label_Total = $Label_Total + 65536
    EndIf

;these need to be read in from your config file or calculated from said read.

Select
        Case $Label_Total = 1
        Case $Label_Total = 65808
            printset10()
    EndSelect

How can I create this so that they can add new labels? I know I need to use list boxes instead of Radios. My problem is assembling the print job, telling it what to do. I need help bad I think I've coded myself into a corner, lol.


Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

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