GSAK (Geocaching Swiss Army Knife)
Contents - Index

EditForm (function)

EditForm(sForm, sName, sProperty, sValue) : string

This function allows you to change individual properties in your form variable. After making the required changes you would then normally use the Form() function again to redisplay the changed form. 

sForm - This is the form variable to edit
sName - This is the name of the control to change 
sProperty - This is the name of the property to change (the property of the corresponding sName control)
sValue - This is value you want to allocate to sProperty

After accepting input from the user you may want to redisplay the form with some of the properties changed. Rather than have to create the whole form again with a new set of <data> statements you can use this function to just change the properties required. In the following example we want to change the label data when the user makes a selection from the drop down box. The ComboBox has the "ExitOnChange" property set to "Yes" which means that as soon as a value in the ComboBox changes the form will exit. This enables us to test the selected value in the ComboBox, then use EditForm() to change our corresponding label. We could of course perform other calculations and do other Editing of properties on the form if required.  
 

While True
  $exit = Form($form,"")
  BeginCase
    Case $exit = "SystemExit"
      Cancel
    Case $exit = "BtnOk"
      Cancel Msg="You clicked on the OK button"
    Case $exit = "BtnCancel"
      Cancel Msg="You clicked on the Cancel button"
    Case $exit = "Dish"
      BeginCase
        Case $Dish = "None"
          $Form = EditForm($Form,"Label1","Caption","Nothing Selected")
        Case $Dish = "Steak"
          $Form = EditForm($Form,"Label1","Caption","Available Monday Only")
        Case $Dish = "Lamb"
          $Form = EditForm($Form,"Label1","Caption","Available Mon, Wed, Fri")
        Case $Dish = "Fish"
          $Form = EditForm($Form,"Label1","Caption","Available Thu, Sat")
      EndCase
   EndCase
EndWhile

<Data> VarName=$form
#********************************************************************
# Form generated by GSAK form designer on Fri 16-Nov-2007 13:57:41
#********************************************************************

Name = Form1
  Type = Form
  Height = 161
  Width = 258
  Caption = EditForm() Example 

Name = Dish
  Type = Combobox
  Exitonchange = Yes
  Height = 21
  Left = 30
  Top = 33
  Values = None;Steak;Lamb;Fish
  Width = 145

Name = Label1
  Type = Label
  Height = 13
  Left = 29
  Top = 64
  Width = 169
  Caption = Nothing Selected

Name = BtnOk
  Type = Button
  Height = 25
  Left = 23
  Top = 93
  Width = 75
  Caption = OK

Name = BtnCancel
  Type = Button
  Height = 25
  Left = 113
  Top = 93
  Width = 75
  Caption = Cancel

Name = Label2
  Type = Label
  Height = 13
  Left = 32
  Top = 12
  Width = 61
  Caption = Select a dish

<enddata>


The above code uses a while loop to continually show the form when the ComboBox changes. Any other method to exit the form will break out of this loop.

So when the form is initially shown we see this:



If we select "Steak" from the drop down list, we immediately see:



Related: Form()

Alpha List         Category List


Copyright 2004-2019 CWE Computer Services  
Privacy Policy Contact