Using Didtok

Contributed by Yardiff
This tutorial uses examples to illustrate how to use the didtok command, an efficient and powerful way to enter information into dialogs.
How To Use
This is the dialog table - called "test", centered on the screen, some buttons and a sorted listbox (note that you need the "&Ok" button as a minimum).
dialog test {
  title "Test"
  size -1 -1 200 210
  button "&Ok", 1, 5 5 190 25, ok
  button "&Fill List", 2, 5 35 190 25
  button "&Save List", 3, 5 65 190 25
  button "&Load List", 4, 5 95 190 25
  list 5, 5 125 190 80, size sort
}
This is the click event for the dialog:
on 1:dialog:test:sclick:*:{
  ; check first to see if we clicked the "&Fill List" button (id 2)
  if ($did == 2) {
    ; load a comma-separated list of values into the listbox
    ; (44 is the ascii value for a comma)
    didtok Test 5 44 #1,#3,#5,#4,#2,#7,#6,#10,#8,#9
  }
  ; check next to see if we clicked the "&Save List" button (id 3)
  if ($did == 3) {
    ; save the comma-separated list of values from the listbox, and write into a file
    ; (note that the file is called "test.txt" and is in the same dir as the script)
    write -c $scriptdirtest.txt $didtok(Test,5,44)
  }
  ; check to see if we clicked the "&Load List" button (id 4)
  if ($did == 4) {
    ; load the first line from the test.txt file into the listbox
    ; (assume that it is comma-separated - I suggest playing with your own values)
    didtok Test 5 44 $read -l1 $scriptdirtest.txt
  }
}
Use this alias to load the dialog you have just created.
alias loadtest dialog -m test test
All content is copyright by mircscripts.org and cannot be used without permission. For more details, click here.