KiXforms Forum Index KiXforms
The Forum for the KiXforms Community
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Quick Links 
Site News
Downloads
Documentation
Donations
Script Archive
Tracking Systems

List Template

 
Post new topic   Reply to topic    KiXforms Forum Index -> Script Archive
View previous topic :: View next topic  
Author Message
krabourn
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 273
Location: San Antonio. TX

PostPosted: Sun Mar 16, 2003 12:19 am    Post subject: List Template Reply with quote

I thought I should get something out.

Here is a form and funtion that I use in my scripts to do simple list management. It will accept and return single and multi-dimensional arrays.
    Add single items - Type into into the text box and press Enter or click the Disk Icon.
    Delete single or multiple items by selecting and clicking the X icon.
    Double click an item in the list to edit it.
    Left/Right Spin Buttons - They will appear if there are more than one column when Editing or Adding.
    Add Multiple Items - Allows you to type or paste a bunch of items at one time. The only drawback is that it will only add to the first column.
    You can cancel out of the "Add Multiple Items" and the list.

Code:

BREAK  ON

$ScriptDir = @CurDir

;--- Initialize
$iMargin = 5
$ilblHeight = 15
$iToolButtonWidth = 20
$iToolButtonHeight = 20
$iSpinButtonHeight = 15
$iSpinButtonWidth = 25
$ColorBack = 'silver'
;--- Initialize

;--- DB form
$frmDB = CreateObject("Kixtart.Form")
$frmDB.ClientWidth = 300
$frmDB.ClientHeight = 300
$frmDB.BackColor = $ColorBack
$frmDB.BorderStyle = 0
$frmDB.Center
$frmDB.Rectangle(0, 0, $frmDB.ClientWidth, $frmDB.ClientHeight)

$txtDBName = $frmDB.TextBox
$txtDBName.ToolTip = ''
$txtDBName.Location = $iMargin, $iMargin
$txtDBName.Size = 185, $ilblHeight
$txtDBName.BorderStyle = 5
$txtDBName.OnChange='
   IF $$txtDBName.Value <> ""
      $$btnDBSave.Show
      IF $lvwDB.Columns.Count > 1
         $spnDBName.Show
      ENDIF
   ELSE
      $spnDBName.Hide
      $$btnDBSave.Hide
   ENDIF'
$txtDBName.OnGotFocus = '$$btnDBDelete.Hide'

$spnDBName = $frmDB.SpinButton
$spnDBName.ToolTip = 'Which column to edit.'
$spnDBName.Location = $txtDBName.Right + $iMargin, $txtDBName.Top
$spnDBName.Size = $iSpinButtonHeight,$iSpinButtonWidth
$spnDBName.Orientation = 0
$spnDBName.BorderStyle = 0
$spnDBName.OnChange = '
   $$txtDBName.ToolTip = ""
   $$btnDBSave.ToolTip = "Save the Item back to the list."
   $$txtDBName.Text = $$lvwDB.FocusedItem.SubItems($$spnDBName.Value).Text
   $$txtDBName.SetFocus'
$spnDBName.Hide

$btnDBSave = $frmDB.ToolButton
$btnDBSave.ToolTip = 'Save the Item back to the list.'
$btnDBSave.Size = $iToolButtonHeight, $iToolButtonWidth
$btnDBSave.Location = $spnDBName.Right, $txtDBName.Top - 2
$btnDBSave.FlatStyle = 1
$btnDBSave.Alignment = 0
$btnDBSave.Default = 1
$btnDBSave.Icon = 3
$btnDBSave.OnClick = '
   IF    $$lvwDB.Tag = "E"
      IF $$spnDBName.Value = 0
         $$lvwDB.Tag = 0
         FOR $$Index = 0 TO $$lvwDB.Items.Count
            IF $$txtDBName.Text = $$lvwDB.FocusedItem.SubItems(0).Text
               $$Index = $$lvwDB.Items.Count + 1
               $$txtDBName.ToolTip = "DUPLICATE"
               $$btnDBSave.ToolTip = "DUPLICATE - Save the Item back to the list."
               $$lvwDB.Tag = 1
            ENDIF
         NEXT
         IF $$lvwDB.Tag = 0
            $$lvwDB.FocusedItem.SubItems($$spnDBName.Value).Text = $$txtDBName.Text
            $$txtDBName.ToolTip = ""
            $$btnDBSave.ToolTip = "Save the Item back to the list."
         ENDIF
         $$lvwDB.Tag = ""
      ELSE
         $$lvwDB.FocusedItem.SubItems($$spnDBName.Value).Text = $$txtDBName.Text
      ENDIF
      $$txtDBName.Text = ""
      $$btnDBSave.Hide
      $$spnDBName.Hide
      $$txtDBName.SetFocus
   ELSE
      IF $$txtDBName.Text <> ""
         IF $$lvwDB.Tag = ""
            $$Item = $$lvwDB.Items.Add($$txtDBName.Text)
            $$lvwDB.EnsureVisible($$Item.Index)
            $$spnDBName.Value = $$spnDBName.Min
            $$txtDBName.Text = $$lvwDB.Items($$Item.Index).SubItems($$spnDBName.Value).Text
            $$txtDBName.ToolTip = ""
            $$btnDBSave.ToolTip = "Save the Item back to the list."
            $$btnDBSave.Hide
            $$spnDBName.Hide
            $$txtDBName.Text = ""
            $$txtDBName.SetFocus
         ENDIF
         $$lvwDB.Tag = ""
      ENDIF
   ENDIF'
$btnDBSave.Hide

$lvwDB = $frmDB.ListView
$lvwDB.ToolTip = 'Double Click an item to edit.'
$lvwDB.Location = $iMargin, $txtDBName.Bottom + $iMargin
$lvwDB.Size = $frmDB.Width - (2 * $iMargin), $frmDB.Height - $lvwDB.Top - $iMargin
$lvwDB.GridLines = 1
$lvwDB.View = 3
$lvwDB.FullRowSelect = 1
$lvwDB.MultiSelect = 1
$lvwDB.OnDoubleClick = '
   $$lvwDB.Tag = "E"
   $$spnDBName.Value = $$spnDBName.Min
   $$txtDBName.Text = $$lvwDB.FocusedItem.SubItems($$spnDBName.Value).Text
   $$btnDBSave.Show
   IF $$lvwDB.Columns.Count > 1
      $$spnDBName.Show
   ENDIF
   $$txtDBName.SetFocus'
$lvwDB.OnClick = '
   $$txtDBName.Text = ""
   $$txtDBName.ToolTip = ""
   $$btnDBAdd.ToolTip = "Add multiple items to the list."
   $$btnDBSave.ToolTip = "Save the Item back to the list."
   $$btnDBSave.Hide
   $$spnDBName.Hide
   $$btnDBDelete.Show'

$btnDBDelete = $frmDB.ToolButton
$btnDBDelete.ToolTip = 'Delete from the list.'
$btnDBDelete.Size = $iToolButtonHeight, $iToolButtonWidth
$btnDBDelete.Location = $txtDBName.Right + $iMargin, $txtDBName.Top - 2
$btnDBDelete.FlatStyle = 1
$btnDBDelete.Alignment = 0
$btnDBDelete.Icon = 9
$btnDBDelete.Hide
$btnDBDelete.OnClick = '
   SELECT
      CASE $$lvwDB.SelectedItems.Count > 1
         IF $$frmDB.MsgBox("Do you want to delete " + $$lvwDB.SelectedItems.Count + " items(s)?", "Delete items", 4) = 6
            $$lvwDB.SelectedItems.Clear
         ENDIF
      CASE $$lvwDB.SelectedItems.Count = 1
            IF $$frmDB.MsgBox("Do you want to delete " + $$lvwDB.FocusedItem.SubItems(0).Text + "?", "Delete items", 4) = 6
               $$lvwDB.FocusedItem.Remove
            ENDIF
   ENDSELECT
   $$txtDBName.SetFocus'

$btnDBAdd = $frmDB.ToolButton
$btnDBAdd.ToolTip = 'Add multiple items to the list.'
$btnDBAdd.Size = $iToolButtonHeight, $iToolButtonWidth
$btnDBAdd.Location = $frmDB.Width - (3 * $btnDBAdd.Width) - $iMargin, $txtDBName.Top - 2
$btnDBAdd.FlatStyle = 1
$btnDBAdd.Alignment = 0
$btnDBAdd.Icon = 58
$btnDBAdd.OnClick = '
   $$frmDB.ForeColor = $ColorBack
   $$frmDB.Rectangle(0, 0, $$frmDB.ClientWidth, $$frmDB.ClientHeight)
   $$frmDB.ForeColor = ""
   $$frmDB.Width = $$lvwDB.Width + $$txtMultiName.Width + (3* $$iMargin)
   $$btnDBMultiNameCancel.Location = $$frmDB.Width - (2 * $$btnDBMultiNameCancel.Width) - $$iMargin, $$txtDBName.Top - 2
   $$btnDBMultiNameOkay.Location = $$frmDB.Width - $$btnDBMultiNameOkay.Width - $$iMargin, $$txtDBName.Top - 2
   $$txtMultiName.Value = ""
   $$txtMultiName.Show
   $$btnDBMultiNameCancel.Show
   $$btnDBMultiNameOkay.Show
   $$frmDB.Rectangle(0, 0, $$frmDB.ClientWidth, $$frmDB.ClientHeight)
   $$frmDB.Center
   $$txtMultiName.SetFocus'

$btnDBCancel = $frmDB.ToolButton
$btnDBCancel.ToolTip = 'Cancel and return.'
$btnDBCancel.Size = $iToolButtonHeight, $iToolButtonWidth
$btnDBCancel.Location = $frmDB.Width - (2 * $btnDBCancel.Width) - $iMargin, $txtDBName.Top - 2
$btnDBCancel.FlatStyle = 1
$btnDBCancel.Alignment = 0
$btnDBCancel.Icon = 37
$btnDBCancel.OnClick = '$$DBCancel = 1 $$frmDB.Hide'

$btnDBDone = $frmDB.ToolButton
$btnDBDone.ToolTip = 'Save and return.'
$btnDBDone.Size = $iToolButtonHeight, $iToolButtonWidth
$btnDBDone.Location = $frmDB.Width - $btnDBDone.Width - $iMargin, $txtDBName.Top - 2
$btnDBDone.FlatStyle = 1
$btnDBDone.Alignment = 0
$btnDBDone.Icon = 10
$btnDBDone.OnClick = '$$frmDB.Hide'

$txtMultiName = $frmDB.TextBox
$txtMultiName.ToolTip = ''
$txtMultiName.Location = $lvwDB.Right + $iMargin, $lvwDB.Top
$txtMultiName.Size = $lvwDB.Width, $lvwDB.Height
$lvwDB.Size = $frmDB.Width - (2 * $iMargin), $frmDB.Height - $lvwDB.Top - $iMargin
$txtMultiName.MultiLine = 1
$txtMultiName.Hide

$btnDBMultiNameCancel = $frmDB.ToolButton
$btnDBMultiNameCancel.ToolTip = 'Cancel adding multiple items to the list.'
$btnDBMultiNameCancel.Size = $iToolButtonHeight, $iToolButtonWidth
$btnDBMultiNameCancel.Location = $frmDB.Width - (2 * $btnDBMultiNameCancel.Width) - $iMargin, $txtDBName.Top - 2
$btnDBMultiNameCancel.FlatStyle = 1
$btnDBMultiNameCancel.Alignment = 0
$btnDBMultiNameCancel.Hide
$btnDBMultiNameCancel.Icon = 37
$btnDBMultiNameCancel.OnClick = '
   $$frmDB.ForeColor = $ColorBack
   $$frmDB.Rectangle(0, 0, $$frmDB.ClientWidth, $$frmDB.ClientHeight)
   $$frmDB.ForeColor = ""
   $$btnDBMultiNameOkay.Hide
   $$btnDBMultiNameCancel.Hide
   $$txtMultiName.Hide
   $$frmDB.Width = $$lvwDB.Width + (2* $$iMargin)
   $$frmDB.Rectangle(0, 0, $$frmDB.ClientWidth, $$frmDB.ClientHeight)
   $$frmDB.Center
   $$txtDBName.SetFocus'

$btnDBMultiNameOkay = $frmDB.ToolButton
$btnDBMultiNameOkay.ToolTip = 'Save multiple items to the list.'
$btnDBMultiNameOkay.Size = $iToolButtonHeight, $iToolButtonWidth
$btnDBMultiNameOkay.Location = $frmDB.Width - $btnDBMultiNameOkay.Width - $iMargin, $txtDBName.Top - 2
$btnDBMultiNameOkay.FlatStyle = 1
$btnDBMultiNameOkay.Alignment = 0
$btnDBMultiNameOkay.Hide
$btnDBMultiNameOkay.Icon = 10
$btnDBMultiNameOkay.OnClick = '
   $$frmDB.ForeColor = $ColorBack
   $$frmDB.Rectangle(0, 0, $$frmDB.ClientWidth, $$frmDB.ClientHeight)
   $$frmDB.ForeColor = ""
   $$btnDBMultiNameOkay.Hide
   $$btnDBMultiNameCancel.Hide
   $$txtMultiName.Hide
   $$frmDB.Width = $$lvwDB.Width + (2* $$iMargin)
   $$frmDB.Rectangle(0, 0, $$frmDB.ClientWidth, $$frmDB.ClientHeight)
   $$frmDB.Center
   IF InStr($$txtMultiName.Value, @@CRLF)
      $$atxtMultiName = Split($$txtMultiName.Value, @@CRLF, -1)
   ELSE
      $$atxtMultiName = Split($$txtMultiName.Value, Chr(13), -1)
   ENDIF
   $$TempList = ""
   FOR EACH $$MultiNameLine IN $$atxtMultiName
      $$LineCheck = 1
      WHILE $$LineCheck = 1
         SELECT
            CASE Substr ($$MultiNameLine, 1, 2) = "\\"
               $$MultiNameLine = Substr ($$MultiNameLine, 3, Len ($$MultiNameLine))
            CASE Substr ($$MultiNameLine, 1, 1) = "\"
               $$MultiNameLine = Substr ($$MultiNameLine, 2, Len ($$MultiNameLine))
            CASE Substr ($$MultiNameLine, 1, 1) = Chr (34)
               $$MultiNameLine = Substr ($$MultiNameLine, 2, Len ($$MultiNameLine))
            CASE InStr ($$MultiNameLine, Chr (34)) > 1
               $$MultiNameLine = Substr ($$MultiNameLine, 1, InStr ($$MultiNameLine, Chr (34)) - 1)
            CASE Substr ($$MultiNameLine, 1, 1) = Chr (44)
               $$MultiNameLine = Substr ($$MultiNameLine, 2, Len ($$MultiNameLine))
            CASE InStr ($$MultiNameLine, Chr (44)) > 1
               $$MultiNameLine = Substr ($$MultiNameLine, 1, InStr ($$MultiNameLine, Chr (44)) - 1)
            CASE InStr ($$MultiNameLine, " ") > 1
               $$MultiNameLine = Substr ($$MultiNameLine, 1, InStr ($$MultiNameLine, " ") - 1)
            CASE InStr ($$MultiNameLine, Chr (9)) > 1
               $$MultiNameLine = Substr ($$MultiNameLine, 1, InStr ($$MultiNameLine, Chr (9)) - 1)
            CASE InStr ($$MultiNameLine, ",") > 1
               $$MultiNameLine = Substr ($$MultiNameLine, 1, InStr ($$MultiNameLine, ",") - 1)
            CASE InStr ($$MultiNameLine, ";") > 1
               $$MultiNameLine = Substr ($$MultiNameLine, 1, InStr ($$MultiNameLine, ";") - 1)
            CASE InStr ($$MultiNameLine, ".") > 1
               $$MultiNameLine = Substr ($$MultiNameLine, 1, InStr ($$MultiNameLine, ".") - 1)
            CASE 1
               $$LineCheck = 0
         ENDSELECT
      LOOP
      IF $$MultiNameLine <> "" AND NOT InStr ($$TempList, $$MultiNameLine)
         $$lvwDB.Tag = ""
         FOR $$Index = 0 TO $$lvwDB.Items.Count
            IF $$MultiNameLine = $$lvwDB.Items($$Index).SubItems(0).Text
               $$Index = $$lvwDB.Items.Count + 1
               $$lvwDB.Tag = 1
            ENDIF
         NEXT
         IF $$lvwDB.Tag = ""
            $$TempList = $$TempList + $$MultiNameLine + ","
         ENDIF
      ENDIF
   NEXT
   $$ArrList = Split (Substr ($$TempList, 1, Len ($$TempList) - 1), ",", -1)
   $$CountOld = $$lvwDB.Items.Count
   $$lvwDB.Items.Count = $$lvwDB.Items.Count + Val (UBound ($$ArrList) + 1)

   FOR $$Index = 0 TO Val (UBound ($$ArrList))
      $$lvwDB.Items($$CountOld + $$Index).SubItems(0).Text = $$ArrList[$$Index]
   NEXT
   $$lvwDB.Tag = ""
   $$txtDBName.SetFocus'
;--- DB form

FUNCTION fnDB($aDBList, OPTIONAL $DBTitle)
    DIM $Index, $Index2, $DBTemp, $ColumnIndex, $ColumnName, $Column
      DIM $aDBTemp [0]
   $txtDBName.Value = ''
   $DBCancel = 0
   IF VarType($aDBList) <> 8
       REDIM $aDBTemp [Val(UBound($aDBList))]
    ENDIF
    FOR $ColumnIndex = 0 TO $lvwDB.Columns.Count - 1
        $lvwDB.Columns($ColumnIndex).Remove
    NEXT
    $lvwDB.Items.Clear
   IF VarType($aDBList) <> 8 AND UBound($aDBList) > 0
      IF UBound($aDBList[1]) > 0
          SELECT
             CASE UBound($DBTitle) > 0
                 FOR EACH $ColumnName IN $DBTitle
                      $Nul = $lvwDB.Columns.Add($ColumnName,, 0)
                  NEXT
             CASE $DBTitle <> ''
               FOR $Index = 0 TO UBound($aDBList)
                  IF $Index = 0
                     $Nul = $lvwDB.Columns.Add($DBTitle,, 0)
                  ELSE
                     $Nul = $lvwDB.Columns.Add($Index,, 0)
                  ENDIF
               NEXT
             CASE $DBTitle = ''
               FOR $Index = 0 TO UBound($aDBList)
                  $Nul = $lvwDB.Columns.Add($Index,, 0)
               NEXT
                  $lvwDB.HeaderStyle = 0
         ENDSELECT
      ELSE
          SELECT
             CASE UBound($DBTitle) > 0
               $Nul = $lvwDB.Columns.Add($DBTitle[0],, 0)
             CASE $DBTitle <> ''
               $Nul = $lvwDB.Columns.Add($DBTitle,, 0)
             CASE $DBTitle = ''
               $Nul = $lvwDB.Columns.Add(0,, 0)
                  $lvwDB.HeaderStyle = 0
         ENDSELECT
      ENDIF
   ELSE
       SELECT
          CASE UBound($DBTitle) > 0
            $Nul = $lvwDB.Columns.Add($DBTitle[0],, 0)
          CASE $DBTitle <> ''
            $Nul = $lvwDB.Columns.Add($DBTitle,, 0)
          CASE $DBTitle = ''
            $Nul = $lvwDB.Columns.Add(0,, 0)
               $lvwDB.HeaderStyle = 0
      ENDSELECT
   ENDIF

   IF VarType($aDBList) <> 8
       IF UBound($aDBList) <> 0
          IF UBound($aDBList[1]) > 0
             $lvwDB.Items.Count = Val (UBound($aDBList[0]) + 1)
             FOR $Index = 0 TO Val(UBound($aDBList[$Index2]))
                 FOR $Index2 = 0 TO Val(UBound($aDBList))
                     $lvwDB.Items($Index).SubItems($Index2).Text = $aDBList[$Index2][$Index]
                 NEXT
             NEXT
         ELSE
             $lvwDB.Items.Count = Val (UBound($aDBList) + 1)
              FOR $Index = 0 TO Val(UBound($aDBList))
               $lvwDB.Items($Index).SubItems(0).Text = $aDBList[$Index]
              NEXT
         ENDIF
      ELSE
          $lvwDB.Items.Count = Val (UBound($aDBList) + 1)
           FOR $Index = 0 TO Val(UBound($aDBList))
            $lvwDB.Items($Index).SubItems(0).Text = $aDBList[$Index]
           NEXT
      ENDIF
   ELSE
       $lvwDB.Items.Count = 1
       $lvwDB.Items(0).SubItems(0).Text = $aDBList
   ENDIF
    FOR EACH $Column IN $lvwDB.Columns
        $Column.Width = -1
        $Column.Width = -2
    NEXT
    $spnDBName.Min = 0
    $spnDBName.Max = $lvwDB.Columns.Count - 1
    $frmDB.Show
    $frmDB.SetFocus
    $txtDBName.SetFocus
    WHILE $frmDB.Visible
        $Nul = Execute($frmDB.DoEvents())
    LOOP

   IF $DBCancel <> 1
      IF Val($lvwDB.Items.Count) = 0
         REDIM $aDBTemp [0]
      ELSE
         IF VarType($aDBList) <> 8
             IF UBound($aDBList) <> 0
                IF UBound($aDBList[1]) > 0
                   REDIM $aDBTemp [Val($lvwDB.Columns.Count - 1)]
                   FOR $Index = 0 TO Val($lvwDB.Items.Count - 1)
                       FOR $Index2 = 0 TO Val(UBound($aDBTemp))
                           $aDBTemp[$Index2] = $aDBTemp[$Index2] + $lvwDB.Items($Index).SubItems($Index2).Text + ','
                       NEXT
                   NEXT
                   FOR $Index = 0 TO Val(UBound($aDBTemp))
                       $DBTemp = Substr($aDBTemp[$Index], 1, Len($aDBTemp[$Index]) - 1)
                       $aDBTemp[$Index] = Split($DBTemp, ',', -1)
                   NEXT
                ELSE
                   REDIM $aDBTemp [Val($lvwDB.Items.Count - 1)]
                   FOR $Index = 0 TO Val(UBound($aDBTemp))
                       $aDBTemp[$Index] = $lvwDB.Items($Index).SubItems(0).Text
                   NEXT
                ENDIF
             ELSE
                REDIM $aDBTemp [Val($lvwDB.Items.Count - 1)]
                FOR $Index = 0 TO Val(UBound($aDBTemp))
                    $aDBTemp[$Index] = $lvwDB.Items($Index).SubItems(0).Text
                NEXT
             ENDIF
         ELSE
            REDIM $aDBTemp [Val($lvwDB.Items.Count - 1)]
            FOR $Index = 0 TO Val(UBound($aDBTemp))
               $aDBTemp[$Index] = $lvwDB.Items($Index).SubItems(0).Text
            NEXT
         ENDIF
      ENDIF
       $fnDB = $aDBTemp
    ENDIF
ENDFUNCTION

$aColors = 'White','Black','Red','Blue','Green'
$aShapes = 'Circle','Square','Rectangle','Triangle','Trapazoid'
$aColorsShapes = $aColors, $aShapes
$aColumTitles = 'Colors','Shapes'

$aColorsShapes = fnDB($aColorsShapes, $aColumTitles)
FOR EACH $k IN $aColorsShapes
    FOR EACH $s IN $k
        ? $s
    NEXT
   ? ' --- '
NEXT
QUIT 0
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Mon Mar 17, 2003 12:50 pm    Post subject: Reply with quote

Kelly,

hmmm .... no comments on the functionality yet , just one on first sight :

I always preferred having seperate functions for Events if the code for that Event (indented) is more than 2 lines Wink

_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
Sealeopard
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 436
Location: Boston, MA

PostPosted: Mon Mar 17, 2003 1:12 pm    Post subject: Reply with quote

I will have all events/action inside separate function/endfunction delimiters. My preferred way to code this is as follows:
Code:

global $btnDBSave
$btnDBSave.OnClick='btnDBSaveOnClick()'
function btnDBSaveOnClick()
endfunction

This makes it easier to add functionality to events and still keeps the function calls self-explanatory. Additionaly, I am defining all KiXForms elements as GLOBAL which enables me to reference the elements from within functions.

It might be time that we collect these things as a 'Best Practices for Designing KiXForms GIUs' and then post them both here and in the FAQ Forum of KORG.

_________________
Jens

'There are two kinds of vessels, submarines and targets.'
Back to top
View user's profile Send private message Send e-mail MSN Messenger
krabourn
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 273
Location: San Antonio. TX

PostPosted: Mon Mar 17, 2003 3:04 pm    Post subject: Reply with quote

I used to have the functions seperate from the form. I still do if the function is called from multiple places. I just found myself scrolling from the top of the script to the bottom alot. I thought, why not put the code up in the form if the code is used by nothing else a particular object. That way it is all in one place and, to me, easier to edit. This way the form is more portable. That is why I can pick it up and easily copy it from script to script. I don't think I am doing anything so much wrong, just a different philosophy. Unless Shawn says that something may break in kixforms because of this.

Why define the kixforms objects as Global? Unless I am missing something, You can reference the the objects inside functions.

Example. We use Remote Administrator at work. I have two checkboxes that reference whether or not you want remote control or view only. One is in the main program and one in the default settings. The checkbox in the main program references only the currently running script and does not write back to the registry. The other check box in default settings changes itself, the registry and the main form's checkbox. I did not need Global.

_________________
Kelly
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Sealeopard
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 436
Location: Boston, MA

PostPosted: Mon Mar 17, 2003 3:17 pm    Post subject: Reply with quote

I'm sure you're not using SETOPTION('Explicit','ON') in your code.
_________________
Jens

'There are two kinds of vessels, submarines and targets.'
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Jochen
KiXforms Devotee
KiXforms Devotee


Joined: 05 Mar 2003
Posts: 1204
Location: Stuttgart, Germany

PostPosted: Mon Mar 17, 2003 3:24 pm    Post subject: Reply with quote

Certainly ... otherwise his code would fail Wink
_________________
Jochen

Tell me, and I will forget.
Show me, and I may remember.
Involve me, and I will understand.
Back to top
View user's profile Send private message MSN Messenger
krabourn
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 273
Location: San Antonio. TX

PostPosted: Mon Mar 17, 2003 3:40 pm    Post subject: Reply with quote

I forgot about that. Embarassed

I try to generally code like I have Explicit on but usually don't set it.

_________________
Kelly
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Sealeopard
KiXforms Aficionado
KiXforms Aficionado


Joined: 05 Mar 2003
Posts: 436
Location: Boston, MA

PostPosted: Mon Mar 17, 2003 3:54 pm    Post subject: Reply with quote

I created a standard header for any script that I start. This way, I'm forced to use my restrictive settings.
_________________
Jens

'There are two kinds of vessels, submarines and targets.'
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    KiXforms Forum Index -> Script Archive All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group