WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Dialogs

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Create Dialog Control Variables


I have created a wsp-user.mnu item that can be used to create variables for dialog controls. Paste the code from the attached TXT file into your wsp-user.mnu file.

To use the menu item:

  1. Create a dialog with the Dialog Editor.
  2. Save the dialog to the clipboard.
  3. Paste the dialog into WinBatch Studio.
  4. Highlight the list of dialog controls ONLY, i.e.
    MyDialog001=`135,119,078,012,PUSHBUTTON...
    MyDialog002=`173,137,044,012,PUSHBUTTON...
    MyDialog003=`003,001,028,008,STATICTEXT...
    .
    .
    .
    MyDialog024=`003,009,088,038,ITEMBOX...
    
  5. Right-click the highlighted controls.
  6. Select Create Dialog Control Variables from the menu. The Dialog Control Variables will be placed in the clipboard.

The Create Dialog Control Variables menu item requires the following to function correctly:

  1. A unique entry in the Variable Name field in the Dialog Editor for the following controls: CALENDAR, CHECKBOX, DROPLISTBOX, EDITBOX, FILELISTBOX, ITEMBOX, MULTILINEBOX, RADIOBUTTON, SPINNER, VARYTEXT
  2. A unique entry in the Text field in the Dialog Editor for the following controls: GROUPBOX, PICTURE, PICTUREBUTTON, PUSHBUTTON, STATICTEXT

In the future if you need to add or delete a control from a dialog, open the dialog with Dialog Editor and add or delete your controls and then repeat the above steps to create the new variables. The menu item should generate the same variable names with their new numbers as long as the current controls did not get there Variable Name or Text fields changed in the Dialog Editor.

Feel free to improve on the code and repost.

Thanks

Create Dialog Control Variables
      wCopy()
      #DefineSubRoutine CheckVariable(chkvar)
         verVar = ""
         For letx = 1 To StrLen(chkvar)
            letter = StrSub(chkvar,letx,1)
            If StrIndexNC(letters,letter,0,@FWDSCAN) != 0 Then verVar = StrCat(verVar,letter)
               Else Continue
         Next
         Return (verVar)
      #EndSubRoutine
      letters=`abcdefghijklmnopqrstuvwxyz0123456789_`
      Decimals(0)
      controls = ClipGet()
      controls = StrReplace(controls,@TAB,``)
      controls = StrReplace(controls,@CRLF,@TAB)
      While @TRUE
         If StrSub(controls,StrLen(controls),1) != @TAB Then Break
         controls = StrSub(controls,1,StrLen(controls)-1)
      EndWhile
      ctrlcnt = ItemCount(controls,@TAB)
      Variables = ""
      For ccnt = 1 To ctrlcnt
         ctrldata = ItemExtract(ccnt,controls,@TAB)
         ctrlvartxt = StrSub(ctrldata,1,StrScan(ctrldata,`=`,0,@FWDSCAN) - 1)
         ctrlsettings = StrSub(ctrldata,StrScan(ctrldata,`=`,0,@FWDSCAN) + 1,StrLen(ctrldata) - StrScan(ctrldata,`=`,0,@FWDSCAN))
         dlgname = StrSub(ctrlvartxt,1,StrLen(ctrlvartxt)-3)
         ctrlvarnum = StrSub(ctrlvartxt,StrLen(ctrlvartxt)-2,3) * 1
         ctrlType = ItemExtract(5,ctrlsettings,`,`)
         ctrlVar = ItemExtract(6,ctrlsettings,`,`)
         ctrlText = ItemExtract(7,ctrlsettings,`,`)
         ctrlText = StrReplace(ctrlText,`"`,``)
         ctrlText = StrReplace(ctrlText,` `,``)
         ctrlText = StrSub(ctrltext,1,15)
         Switch @TRUE
            Case (StrUpper(ctrltype) == `CALENDAR`)
               tmpVar = StrCat(`caln_`,dlgname,`_`,ctrlVar)
               Var = CheckVariable(tmpVar)
               Variables = StrCat(variables,var,` = `,ctrlvarnum,@CRLF)
               Break
            Case (StrUpper(ctrltype) == `CHECKBOX`)
               tmpVar = StrCat(`chck_`,dlgname,`_`,ctrlVar)
               Var = CheckVariable(tmpVar)
               Variables = StrCat(variables,var,` = `,ctrlvarnum,@CRLF)
               Break
            Case (StrUpper(ctrltype) == `DROPLISTBOX`)
               tmpVar = StrCat(`drop_`,dlgname,`_`,ctrlVar)
               Var = CheckVariable(tmpVar)
               Variables = StrCat(variables,var,` = `,ctrlvarnum,@CRLF)
               Break
            Case (StrUpper(ctrltype) == `EDITBOX`)
               tmpVar = StrCat(`etxt_`,dlgname,`_`,ctrlVar)
               Var = CheckVariable(tmpVar)
               Variables = StrCat(variables,var,` = `,ctrlvarnum,@CRLF)
               Break
            Case (StrUpper(ctrltype) == `FILELISTBOX`)
               tmpVar = StrCat(`flst_`,dlgname,`_`,ctrlVar)
               Var = CheckVariable(tmpVar)
               Variables = StrCat(variables,var,` = `,ctrlvarnum,@CRLF)
               Break
            Case (StrUpper(ctrltype) == `GROUPBOX`)
               tmpVar = StrCat(`grpb_`,dlgname,`_`,ctrlText)
               Var = CheckVariable(tmpVar)
               Variables = StrCat(variables,var,` = `,ctrlvarnum,@CRLF)
               Break
            Case (StrUpper(ctrltype) == `ITEMBOX`)
               tmpVar = StrCat(`item_`,dlgname,`_`,ctrlVar)
               Var = CheckVariable(tmpVar)
               Variables = StrCat(variables,var,` = `,ctrlvarnum,@CRLF)
               Break
            Case (StrUpper(ctrltype) == `MULTILINEBOX`)
               tmpVar = StrCat(`mtxt_`,dlgname,`_`,ctrlVar)
               Var = CheckVariable(tmpVar)
               Variables = StrCat(variables,var,` = `,ctrlvarnum,@CRLF)
               Break
            Case (StrUpper(ctrltype) == `PICTURE`)
               tmpVar = StrCat(`pict_`,dlgname,`_`,ctrlText)
               Var = CheckVariable(tmpVar)
               Variables = StrCat(variables,var,` = `,ctrlvarnum,@CRLF)
               Break
            Case (StrUpper(ctrltype) == `PICTUREBUTTON`)
               tmpVar = StrCat(`picb_`,dlgname,`_`,ctrlText)
               Var = CheckVariable(tmpVar)
               Variables = StrCat(variables,var,` = `,ctrlvarnum,@CRLF)
               Break
            Case (StrUpper(ctrltype) == `PUSHBUTTON`)
               tmpVar = StrCat(`push_`,dlgname,`_`,ctrlText)
               Var = CheckVariable(tmpVar)
               Variables = StrCat(variables,var,` = `,ctrlvarnum,@CRLF)
               Break
            Case (StrUpper(ctrltype) == `RADIOBUTTON`)
               tmpVar = StrCat(`radb_`,dlgname,`_`,ctrlVar)
               Var = CheckVariable(tmpVar)
               Variables = StrCat(variables,var,` = `,ctrlvarnum,@CRLF)
               Break
            Case (StrUpper(ctrltype) == `SPINNER`)
               tmpVar = StrCat(`spin_`,dlgname,`_`,ctrlVar)
               Var = CheckVariable(tmpVar)
               Variables = StrCat(variables,var,` = `,ctrlvarnum,@CRLF)
               Break
            Case (StrUpper(ctrltype) == `STATICTEXT`)
               tmpVar = StrCat(`stxt_`,dlgname,`_`,ctrlText)
               Var = CheckVariable(tmpVar)
               Variables = StrCat(variables,var,` = `,ctrlvarnum,@CRLF)
               Break
            Case (StrUpper(ctrltype) == `VARYTEXT`)
               tmpVar = StrCat(`vtxt_`,dlgname,`_`,ctrlVar)
               Var = CheckVariable(tmpVar)
               Variables = StrCat(variables,var,` = `,ctrlvarnum,@CRLF)
               Break
         EndSwitch
      Next
      variables = StrSub(variables,1,StrLen(variables) - 2)
      ClipPut(variables)
      Message(`Create Dialog Variables`,`Variables placed in clipboard.`)

Article ID:   W17246
File Created: 2007:07:03:14:28:58
Last Updated: 2007:07:03:14:28:58