I have problem in automatic form generation use of ctx and truectrl library:button problem. (corrected by ! John Arscott below)

Halo

In the below program.I have problem that no button is working to do task he must do in the second window.
When you start up the program from splash screen go the menu than you can go to the second window.
No button works what I do wrong event loop instruction.

Thanks a lot for support.

! *** AUTO GENERATED CODE BEGINS HERE ***
! *** SOURCE REF FILE ***GP20130807
! *** PROGRAM AUTHOR ***
!**********************************************
! button2:not usesd ???????????????????????????
! save as:*.csv not implemented in the program
!**********************************************
LET author$="John Doe"
! *** PROGRAM NAME ***
LET caption$="Data Table Program:Hospital"
! *** VERSION HISTORY ***
LET version$="version 1: dated 07 AUG 2013"

! *** LIBRARIES ***

!These library modules must be in the TBlibs folder
!otherwise you must specify their full pathnames

LIBRARY "CTX.trc"
LIBRARY "TDX.trc"
LIBRARY "TrueCTRL2.trc"

DECLARE DEF valstr
DIM array$(0:25,7)
DIM zero$(1,0:9)
MAT READ zero$
DATA Hospital,MD HOUSE,"","","","","","","",""

DIM menu$(1,0:1)
DIM rmenu$(1,0:1)

! *** ASSIGN VARIABLES ***
LET delim$=chr$(44)
LET eol$=chr$(13) & chr$(10)

! *** INITIALIZATION ***
CALL TC_Init ! Initialize TrueControls
CALL TC_SetUnitsToPixels ! Temporary...
CALL CT_SetUnitsToPixels
CALL TDX_init

CALL splash(caption$,author$,version$,zero$(,)) ! Make a splash window using window #0
CALL TC_Show (0) ! So we have something to see

CALL Form_1("New Form")
! *** EVENT LOOP ***
CALL TC_win_switch(0)

DO
WHEN exception in
CALL CT_Event (event$, window, x1, x2, CTid, CTtype)

IF event$="KEYPRESS" and x1 = 27 THEN
EXIT DO ! Exit the event loop when Escape pressed
END IF

IF window=0 then
IF event$="HIDE" then
EXIT DO
ELSEIF event$="KEYPRESS" then
IF x1=27 then ! ESC key
EXIT DO
END IF
ELSEIF event$="MENU" then ! splash menu
SELECT CASE x2 ! selected menu item
CASE 1
CALL TC_show(form1)
CALL TC_win_switch(form1)
CASE ELSE ! safety net
END SELECT
END IF
ELSEIF window=form1 then
CALL Form_1_events
CALL TC_Show (form1)
CALL TC_win_switch(form1)

IF event$ = "HIDE" then ! close window button has been pressed
EXIT DO
ELSEIF event$="KEYPRESS" then
IF x1=27 then ! ESC key
EXIT DO
END IF
ELSEIF event$="CONTROL DESELECTED" then
IF x2=id1049 then ! push button quit has been pressed
EXIT DO
ELSEIF x2=id1046 then ! sort
!syntax :CALL CT_Table_DataOrder(id1039,column highlighted,method)
REM: method 1=alphabetic A-Z
REM: method 2=reverse alph Z-A
REM: method 3=ascii & numeric ascending
REM: method 4=reverse ascii & numeric descending
CALL CT_Table_DataOrder(id1039,0,1)
ELSEIF x2=id1048 then ! insert
!syntax :CALL CT_Table_InsertData(id1039,row(insert(before)),datarow$)
CALL CT_Table_InsertData(id1039,0,datarow$)
ELSEIF x2=id1047 then
!error: How to solve
!*****************************************************
! CALL CT_Table_WriteFile(id1039,csvname$)
! action must be taken (manual gives wrong discription)
!*****************************************************
End If
END IF

END IF
! *** general purpose error handling routine ***
USE
REM: insert your own message here
CALL TDX_message("PROGRAM ERROR","The program has detected an error.","Continue|Quit",1,result)
LET anytext$=date$ & "/" & time$ & "/" & extext$ & "/" & exline$ & eol$
CALL append_file("ERRLOG.TXT",anytext$)

IF result>1 then
EXIT DO
END IF
END WHEN
let x1=0
let x2=0
LOOP

CALL TC_Cleanup
CALL TC_Win_Switch(0)

! *** FORM ROUTINES ***

! *** FORM_1 ***

SUB form_1(formname$)
CALL form_1_window
CALL form_1_menu
CALL form_1_objects
CALL form_1_showall
END SUB
! *** FORM_1 CREATE WINDOW ***
SUB form_1_window

LET option$="TITLE|SIZE|CLOSE"
CALL TC_win_create(form1,option$,160,1438,808,93)
LET wintitle$="Doctor Form"
CALL TC_Win_SetTitle(form1,wintitle$)
CALL TC_win_setbrush(form1,9,9,"SOLID")
CALL TC_win_setfont(form1,"SYSTEM",10,"BOLD")
CALL get_array(array$(,))
CLEAR
END SUB
! *** FORM_1 CREATE MENU ***
SUB form_1_menu

END SUB
! *** FORM_1 CREATE OBJECTS ***
SUB form_1_objects

LET option$="VSCROLL|RECESS|VRULE|HRULE"
CALL CT_Table_create(id1039,option$,183,1047,663,222)
CALL CT_Table_setcolor(id1039,-1,22,6,7,7,17)
CALL CT_setfont(id1039,"SYSTEM",10,"BOLD")
CALL CT_Table_ReadArray(id1039,array$(,))
LET optionS$="Name of Doctor"
CALL CT_Stext_create(id1044,optionS$,222,382,143,116)
CALL CT_SetTextJustify(id1044,"LEFT")
CALL CT_SText_SetRecess(id1044,-99999)
CALL CT_setcolor(id1044,-1,9)
CALL CT_setfont(id1044,"SYSTEM",10,"BOLD")
LET optionE$="give in the name of a doctor"
CALL CT_Edit_create(id1045,optionE$,219,480,201,178)
CALL CT_Edit_SetRecess(id1045,0)
CALL CT_setcolor(id1045,-1,7)
CALL CT_setfont(id1045,"SYSTEM",10,"BOLD")
LET option1$="Data Order"
CALL CT_PushBtn_create(id1046,option1$,899,999,105,80)
CALL CT_setcolor(id1046,-1,14)
CALL CT_PushBtn_SetToggle(id1046,0)
CALL CT_setfont(id1046,"SYSTEM",10,"BOLD")
LET option2$="Save as:*.csv"
CALL CT_PushBtn_create(id1047,option2$,899,999,144,119)
CALL CT_setcolor(id1047,-1,14)
CALL CT_PushBtn_SetToggle(id1047,0)
CALL CT_setfont(id1047,"SYSTEM",10,"BOLD")
LET option3$="Insert Data "
CALL CT_PushBtn_create(id1048,option3$,899,999,183,158)
CALL CT_setcolor(id1048,-1,14)
CALL CT_PushBtn_SetToggle(id1048,0)
CALL CT_setfont(id1048,"SYSTEM",10,"BOLD")
LET option4$="Quit"
CALL CT_PushBtn_create(id1049,option4$,729,840,181,151)
CALL CT_setcolor(id1049,-1,12)
CALL CT_PushBtn_SetToggle(id1049,0)
CALL CT_setfont(id1049,"SYSTEM",14,"BOLD")
CALL CT_GroupBox_create(id1050,1,138,1082,680,60)
CALL CT_setcolor(id1050,-1,6)
END SUB
! *** FORM_1 SHOW ***
SUB form_1_showall

CALL CT_show(id1039)
CALL CT_show(id1044)
CALL CT_show(id1045)
CALL CT_show(id1046)
CALL CT_show(id1047)
CALL CT_show(id1048)
CALL CT_show(id1049)
CALL CT_show(id1050)
END SUB
! *** FORM_1 PROCESSING ***
SUB form_1_events
IF event$="MENU" then
CALL form_1_menuevent
ELSE
CALL form_1_objectevent
END IF
END SUB
! *** FORM_1 MENU PROCESSING ***
SUB form_1_menuevent

END SUB
! *** FORM_1 OBJECT PROCESSING ***
SUB form_1_objectevent
SELECT CASE event$

CASE "RMENU SELECTED"

CASE "SINGLE"
IF CTid=id1050 then CALL action_id1050
IF CTid=id1049 then CALL action_id1049
IF CTid=id1048 then CALL action_id1048
IF CTid=id1047 then CALL action_id1047
IF CTid=id1046 then CALL action_id1046
IF CTid=id1044 then CALL action_id1044
IF CTid=id1039 then CALL action_id1039

CASE "END EDIT"
IF CTid=id1045 then CALL action_id1045

CASE "LIST SELECTED"

CASE "KEYPRESS"

CASE ELSE
END SELECT
END SUB
! *** FORM_1 OBJECT ACTIONS (user code) ***

SUB action_id1039
REM: What do you want to happen when the data table id1039 is clicked?
CALL CT_Table_GetRow(id1039,row) ! current highlight row
CALL CT_Table_GetData(id1039,row,data$) ! data content of current highlight row
END SUB
SUB action_id1044
REM: What do you want to happen when the text field id1044 is clicked?
END SUB
SUB action_id1045
REM: What do you want to happen when the user completes the edit field id1045?
CALL CT_Edit_GetText(id1045,text$) ! current edit field text
END SUB
SUB action_id1046
REM: What do you want to happen when the push button id1046 is clicked?
CALL CT_PushBtn_GetStatus(id1046,status) ! current button status
END SUB
SUB action_id1047
REM: What do you want to happen when the push button id1047 is clicked?
CALL CT_PushBtn_GetStatus(id1047,status) ! current button status
END SUB
SUB action_id1048
REM: What do you want to happen when the push button id1048 is clicked?
CALL CT_PushBtn_GetStatus(id1048,status) ! current button status
END SUB
SUB action_id1049
REM: What do you want to happen when the push button id1049 is clicked?
CALL CT_PushBtn_GetStatus(id1049,status) ! current button status
END SUB
SUB action_id1050
REM: What do you want to happen when the group box id1050 is clicked? (not the objects within the group box)
CALL TDX_message("Help","Order,Insert,save as:*.csv.","Continue|Quit",1,result)
END SUB

! *** END FORM_1 ***

! *** AUTO GENERATED CODE ENDS HERE ***

! *** USER SUB-ROUTINES ***
SUB get_array(array$(,))
MAT REDIM array$(0:25,7)
for a=0 to 25
for b=1 to 7
READ array$(a,b)
next b
next a
DATA Surname,First name,Middle name,Gender,UPN,DoB,Class
DATA Jones,Tom,Alan,M,777661,19951010,CLASS4K
DATA Alton,Mary,Jane,F,777662,19960504,CLASS4K
DATA Higgins,Henry,William,M,777663,19951215,CLASS4K
DATA Scott,David,Mark,M,777664,19960212,CLASS4K
DATA Cooper,Julie,May,F,777665,19951128,CLASS4K
DATA Biggs,Jason,Thomas,M,777666,19960110,CLASS4K
DATA Hammond,Sarah,Jane,F,777667,19960304,CLASS4K
DATA Crawley,Louise,Ann,F,777668,19960415,CLASS4K
DATA Craig,John,Ronald,M,777669,19960212,CLASS4K
DATA Williams,Victoria,Juliet,F,777671,19960528,CLASS4K
DATA Caraway,Amy,Marie,F,777672,19951001,CLASS4K
DATA Seabright,Candice,Ann,F,777673,19951127,CLASS4K
DATA Billings,Alison,June,F,777674,19960111,CLASS4K
DATA Mcdonald,Andrew,Lionel,M,777675,19960120,CLASS4K
DATA Watkins,Lily,Nina,F,777676,19960207,CLASS4K
DATA Bullock,Rose,Ann,F,777677,19960214,CLASS4K
DATA Conch,Steven,John,M,777678,19960425,CLASS4K
DATA Faraday,Shelly,Josephine,F,777679,19960611,CLASS4K
DATA Meakin,Andrew,John,M,777680,19951231,CLASS4K
DATA Huxley,James,Arthur,M,777681,19960714,CLASS4K
DATA Mallory,Timothy,John,M,777682,19960523,CLASS4K
DATA Soames,Nicholas,James,M,777683,19960722,CLASS4K
DATA Willis,William,Paul,M,777684,19960124,CLASS4K
DATA Khan,Miles,Jacob,M,777685,19951220,CLASS4K
DATA Griffiths,Hannah,Ann,F,777687,19960402,CLASS4K
END SUB

END

! *** UTILITIES ***

SUB splash(caption$,author$,version$,zero$(,))
REM: makes a decorative window announcing author and version
REM: allows user to show all windows created by DO_FORM
!***********************************************************
!*determines the size of the users screen *
!*calculates the mid point of the screen *
!*creates a window to fill the screen *
!*adds menu to window *
!*adds color and geometric decoration *
!*adds programe name, author and version number *
!***********************************************************

CALL TC_getscreensize(lscr,rscr,bscr,tscr)
LET midxscr=int((lscr+rscr)/2) ! mid x axis
LET midyscr=int((tscr+bscr)/2) ! mid y axis
CALL TC_setRect(0,lscr+4,rscr-4,bscr-36,tscr+44)
CALL TC_Win_SetTitle (0,caption$)
CALL TC_Menu_Set (0, zero$(,))

REM: set up logical window
ASK PIXELS xpix,ypix
SET WINDOW 0,xpix-1,ypix-1,0

REM: get window internal dimensions
CALL TC_getrect(0,wxl,wxr,wyb,wyt)
LET xs=wxr-wxl
LET x0=round(xs/2)
LET ys=wyb-wyt
LET y0=round(ys/2)
LET yq=round(y0/2)

REM: add main color blocks
SET COLOR 13
BOX AREA 1,xs,y0,0
SET COLOR -1
BOX AREA 1,xs,ys,y0

REM: add geometric decoration
SET COLOR 5
LET yp=int(yq/15)
LET m=0
FOR n=yp to 1 step-1
LET xn=n*10
LET m=m+1
BOX AREA 75,xs-75,y0+xn,y0+xn-m
BOX AREA 75,xs-75,y0-xn,y0-xn+m
NEXT n

REM: Main program title in Yellow
CALL TC_win_setfont(0,"TIMES",24,"BOLD")
SET COLOR 14
LET half=(STRWIDTH(0,caption$))/2
PLOT TEXT, AT x0-half,y0+10: caption$

REM: small print in white against black background
CALL TC_win_setfont(0,"SYSTEM",10,"BOLD")
SET COLOR 15
LET half=(STRWIDTH(0,version$))/2
PLOT TEXT, AT x0-half,(2*y0)-40: version$

CALL TC_win_setfont(0,"HELVETICA",8,"PLAIN")
SET COLOR 15
LET copy$="Copyright " & author$ & " " & date$[1:4]
LET half=(STRWIDTH(0,copy$))/2
PLOT TEXT, AT x0-half,(2*y0)-20: copy$
END SUB

SUB append_file(errorname$,anytext$)
REM: adds one line to an existing text file
CLOSE #11
OPEN #11: name errorname$, create newold, org text, access outin
RESET #11: end
SET #11: MARGIN maxnum
PRINT #11: anytext$
CLOSE #11
END SUB

DEF VALSTR(string$)

REM: converts string$ to a value without raising errors

LOCAL lens, temp$, hash, letter, negative, neg
LET lens = len(string$)
LET temp$ = ucase$(string$)
LET hash = cpos (temp$,"#")
IF hash > 0 then
LET temp$[hash:hash] = ""

END IF

LET letter = ncpos(temp$," 0123456789.-")

IF letter>1 then
LET temp$=temp$[1:letter-1]
LET letter=0
END IF

IF letter = 0 then
LET negative = 1
LET neg = cpos(temp$,"-")
IF neg > 0 then
LET negative = -1
LET temp$ = temp$[neg+1:lens]

END IF

LET temp$ = trim$(temp$)
IF len(temp$) = 0 then
LET valstr = 0
ELSE
LET valstr = val(temp$)*negative
END IF

ELSE
LET valstr = 0
END IF

END DEF

! *** END PROGRAM ***

REM: Untitled1

Comments

solution to problem:John Arscott

John Arscott

13:10 (10 uur geleden)

aan mij

Bericht vertalen
Uitschakelen voor: Engels
Hi Peter,

At the moment I don't have much time to check back through the manuals, but in general when using CTX push buttons you need to remember that all CTX objects are located by "SINGLE" event mouse clicks. The other point to remember is that the reference ID for normal TrueCtrl objects is the value of x2 whereas the ID for CTX objects is the value of CTid.

When you want to save a Data Table you must specify the name of the file you intend to use (csvname$) and you must specify the ID of the Data Table itself.

I have attached your corrected program.

Regards
PVPROGRAM.TRU PVPROGRAM.TRU
Below correction by john Arscott

! *** AUTO GENERATED CODE BEGINS HERE ***
! *** SOURCE REF FILE ***GP20130807
! *** PROGRAM AUTHOR ***
!**********************************************
! button2:not usesd ???????????????????????????
! save as:*.csv not implemented in the program
!**********************************************
LET author$="John Doe"
! *** PROGRAM NAME ***
LET caption$="Data Table Program:Hospital"
! *** VERSION HISTORY ***
LET version$="version 1: dated 07 AUG 2013"

! *** LIBRARIES ***

!These library modules must be in the TBlibs folder
!otherwise you must specify their full pathnames

LIBRARY "CTX7.trc"
LIBRARY "TDX.trc"
LIBRARY "TrueCTRL2.trc"

DECLARE DEF valstr
DIM array$(0:25,7)
DIM zero$(1,0:9)
MAT READ zero$
DATA Hospital,MD HOUSE,"","","","","","","",""

DIM menu$(1,0:1)
DIM rmenu$(1,0:1)

! *** ASSIGN VARIABLES ***
LET delim$=chr$(44)
LET eol$=chr$(13) & chr$(10)

! *** INITIALIZATION ***
CALL TC_Init ! Initialize TrueControls
CALL TC_SetUnitsToPixels ! Temporary...
CALL CT_SetUnitsToPixels
CALL TDX_init

CALL splash(caption$,author$,version$,zero$(,)) ! Make a splash window using window #0
CALL TC_Show (0) ! So we have something to see

CALL Form_1("New Form")
! *** EVENT LOOP ***
CALL TC_win_switch(0)

DO
WHEN exception in
CALL CT_Event (event$, window, x1, x2, CTid, CTtype)

IF event$="KEYPRESS" and x1 = 27 THEN
EXIT DO ! Exit the event loop when Escape pressed
END IF

IF window=0 then
IF event$="HIDE" then
EXIT DO
ELSEIF event$="KEYPRESS" then
IF x1=27 then ! ESC key
EXIT DO
END IF
ELSEIF event$="MENU" then ! splash menu
SELECT CASE x2 ! selected menu item
CASE 1
CALL TC_show(form1)
CALL TC_win_switch(form1)
CASE ELSE ! safety net
END SELECT
END IF
ELSEIF window=form1 then
CALL Form_1_events
CALL TC_Show (form1)
CALL TC_win_switch(form1)

IF event$ = "HIDE" then ! close window button has been pressed
EXIT DO
ELSEIF event$="KEYPRESS" then
IF x1=27 then ! ESC key
EXIT DO
END IF
ELSEIF event$="SINGLE" then !!!!!Note the change of event$ to SINGLE not CONTROL SELECTED

IF CTid=id1049 then ! push button quit has been pressed!!!!!Note the change to CTid not x2
EXIT DO
ELSEIF CTid=id1046 then ! sort!!!!!Note the change to CTid not x2
!syntax :CALL CT_Table_DataOrder(id1039,column highlighted,method)
REM: method 1=alphabetic A-Z
REM: method 2=reverse alph Z-A
REM: method 3=ascii & numeric ascending
REM: method 4=reverse ascii & numeric descending
CALL CT_Table_DataOrder(id1039,0,1)
ELSEIF CTid=id1048 then ! insert!!!!!Note the change to CTid not x2
!syntax :CALL CT_Table_InsertData(id1039,row(insert(before)),datarow$)
CALL CT_Table_InsertData(id1039,0,datarow$)
ELSEIF CTid=id1047 then !!!!!Note the change to CTid not x2
!error: How to solve
!!!!!!In order to write the data to a file you must define the filename (csvname$)
!*****************************************************
! CALL CT_Table_WriteFile(id1039,csvname$)
! action must be taken (manual gives wrong discription)
!*****************************************************
End If
END IF

END IF
! *** general purpose error handling routine ***
USE
REM: insert your own message here
CALL TDX_message("PROGRAM ERROR","The program has detected an error.","Continue|Quit",1,result)
LET anytext$=date$ & "/" & time$ & "/" & extext$ & "/" & exline$ & eol$
CALL append_file("ERRLOG.TXT",anytext$)

IF result>1 then
EXIT DO
END IF
END WHEN
let x1=0
let x2=0
LOOP

CALL TC_Cleanup
CALL TC_Win_Switch(0)

! *** FORM ROUTINES ***

! *** FORM_1 ***

SUB form_1(formname$)
CALL form_1_window
CALL form_1_menu
CALL form_1_objects
CALL form_1_showall
END SUB
! *** FORM_1 CREATE WINDOW ***
SUB form_1_window

LET option$="TITLE|SIZE|CLOSE"
CALL TC_win_create(form1,option$,160,1438,808,93)
LET wintitle$="Doctor Form"
CALL TC_Win_SetTitle(form1,wintitle$)
CALL TC_win_setbrush(form1,9,9,"SOLID")
CALL TC_win_setfont(form1,"SYSTEM",10,"BOLD")
CALL get_array(array$(,))
CLEAR
END SUB
! *** FORM_1 CREATE MENU ***
SUB form_1_menu

END SUB
! *** FORM_1 CREATE OBJECTS ***
SUB form_1_objects

LET option$="VSCROLL|RECESS|VRULE|HRULE"
CALL CT_Table_create(id1039,option$,183,1047,663,222)
CALL CT_Table_setcolor(id1039,-1,22,6,7,7,17)
CALL CT_setfont(id1039,"SYSTEM",10,"BOLD")
CALL CT_Table_ReadArray(id1039,array$(,))
LET optionS$="Name of Doctor"
CALL CT_Stext_create(id1044,optionS$,222,382,143,116)
CALL CT_SetTextJustify(id1044,"LEFT")
CALL CT_SText_SetRecess(id1044,-99999)
CALL CT_setcolor(id1044,-1,9)
CALL CT_setfont(id1044,"SYSTEM",10,"BOLD")
LET optionE$="give in the name of a doctor"
CALL CT_Edit_create(id1045,optionE$,219,480,201,178)
CALL CT_Edit_SetRecess(id1045,0)
CALL CT_setcolor(id1045,-1,7)
CALL CT_setfont(id1045,"SYSTEM",10,"BOLD")
LET option1$="Data Order"
CALL CT_PushBtn_create(id1046,option1$,899,999,105,80)
CALL CT_setcolor(id1046,-1,14)
CALL CT_PushBtn_SetToggle(id1046,0)
CALL CT_setfont(id1046,"SYSTEM",10,"BOLD")
LET option2$="Save as:*.csv"
CALL CT_PushBtn_create(id1047,option2$,899,999,144,119)
CALL CT_setcolor(id1047,-1,14)
CALL CT_PushBtn_SetToggle(id1047,0)
CALL CT_setfont(id1047,"SYSTEM",10,"BOLD")
LET option3$="Insert Data "
CALL CT_PushBtn_create(id1048,option3$,899,999,183,158)
CALL CT_setcolor(id1048,-1,14)
CALL CT_PushBtn_SetToggle(id1048,0)
CALL CT_setfont(id1048,"SYSTEM",10,"BOLD")
LET option4$="Quit"
CALL CT_PushBtn_create(id1049,option4$,729,840,181,151)
CALL CT_setcolor(id1049,-1,12)
CALL CT_PushBtn_SetToggle(id1049,0)
CALL CT_setfont(id1049,"SYSTEM",14,"BOLD")
CALL CT_GroupBox_create(id1050,1,138,1082,680,60)
CALL CT_setcolor(id1050,-1,6)
END SUB
! *** FORM_1 SHOW ***
SUB form_1_showall

CALL CT_show(id1039)
CALL CT_show(id1044)
CALL CT_show(id1045)
CALL CT_show(id1046)
CALL CT_show(id1047)
CALL CT_show(id1048)
CALL CT_show(id1049)
CALL CT_show(id1050)
END SUB
! *** FORM_1 PROCESSING ***
SUB form_1_events
IF event$="MENU" then
CALL form_1_menuevent
ELSE
CALL form_1_objectevent
END IF
END SUB
! *** FORM_1 MENU PROCESSING ***
SUB form_1_menuevent

END SUB
! *** FORM_1 OBJECT PROCESSING ***
SUB form_1_objectevent
SELECT CASE event$

CASE "RMENU SELECTED"

CASE "SINGLE"
IF CTid=id1050 then CALL action_id1050
IF CTid=id1049 then CALL action_id1049
IF CTid=id1048 then CALL action_id1048
IF CTid=id1047 then CALL action_id1047
IF CTid=id1046 then CALL action_id1046
IF CTid=id1044 then CALL action_id1044
IF CTid=id1039 then CALL action_id1039

CASE "END EDIT"
IF CTid=id1045 then CALL action_id1045

CASE "LIST SELECTED"

CASE "KEYPRESS"

CASE ELSE
END SELECT
END SUB
! *** FORM_1 OBJECT ACTIONS (user code) ***

SUB action_id1039
REM: What do you want to happen when the data table id1039 is clicked?
CALL CT_Table_GetRow(id1039,row) ! current highlight row
CALL CT_Table_GetData(id1039,row,data$) ! data content of current highlight row
END SUB
SUB action_id1044
REM: What do you want to happen when the text field id1044 is clicked?
END SUB
SUB action_id1045
REM: What do you want to happen when the user completes the edit field id1045?
CALL CT_Edit_GetText(id1045,text$) ! current edit field text
END SUB
SUB action_id1046
REM: What do you want to happen when the push button id1046 is clicked?
CALL CT_PushBtn_GetStatus(id1046,status) ! current button status
END SUB
SUB action_id1047
REM: What do you want to happen when the push button id1047 is clicked?
CALL CT_PushBtn_GetStatus(id1047,status) ! current button status
END SUB
SUB action_id1048
REM: What do you want to happen when the push button id1048 is clicked?
CALL CT_PushBtn_GetStatus(id1048,status) ! current button status
END SUB
SUB action_id1049
REM: What do you want to happen when the push button id1049 is clicked?
CALL CT_PushBtn_GetStatus(id1049,status) ! current button status
END SUB
SUB action_id1050
REM: What do you want to happen when the group box id1050 is clicked? (not the objects within the group box)
CALL TDX_message("Help","Order,Insert,save as:*.csv.","Continue|Quit",1,result)
END SUB

! *** END FORM_1 ***

! *** AUTO GENERATED CODE ENDS HERE ***

! *** USER SUB-ROUTINES ***
SUB get_array(array$(,))
MAT REDIM array$(0:25,7)
for a=0 to 25
for b=1 to 7
READ array$(a,b)
next b
next a
DATA Surname,First name,Middle name,Gender,UPN,DoB,Class
DATA Jones,Tom,Alan,M,777661,19951010,CLASS4K
DATA Alton,Mary,Jane,F,777662,19960504,CLASS4K
DATA Higgins,Henry,William,M,777663,19951215,CLASS4K
DATA Scott,David,Mark,M,777664,19960212,CLASS4K
DATA Cooper,Julie,May,F,777665,19951128,CLASS4K
DATA Biggs,Jason,Thomas,M,777666,19960110,CLASS4K
DATA Hammond,Sarah,Jane,F,777667,19960304,CLASS4K
DATA Crawley,Louise,Ann,F,777668,19960415,CLASS4K
DATA Craig,John,Ronald,M,777669,19960212,CLASS4K
DATA Williams,Victoria,Juliet,F,777671,19960528,CLASS4K
DATA Caraway,Amy,Marie,F,777672,19951001,CLASS4K
DATA Seabright,Candice,Ann,F,777673,19951127,CLASS4K
DATA Billings,Alison,June,F,777674,19960111,CLASS4K
DATA Mcdonald,Andrew,Lionel,M,777675,19960120,CLASS4K
DATA Watkins,Lily,Nina,F,777676,19960207,CLASS4K
DATA Bullock,Rose,Ann,F,777677,19960214,CLASS4K
DATA Conch,Steven,John,M,777678,19960425,CLASS4K
DATA Faraday,Shelly,Josephine,F,777679,19960611,CLASS4K
DATA Meakin,Andrew,John,M,777680,19951231,CLASS4K
DATA Huxley,James,Arthur,M,777681,19960714,CLASS4K
DATA Mallory,Timothy,John,M,777682,19960523,CLASS4K
DATA Soames,Nicholas,James,M,777683,19960722,CLASS4K
DATA Willis,William,Paul,M,777684,19960124,CLASS4K
DATA Khan,Miles,Jacob,M,777685,19951220,CLASS4K
DATA Griffiths,Hannah,Ann,F,777687,19960402,CLASS4K
END SUB

END

! *** UTILITIES ***

SUB splash(caption$,author$,version$,zero$(,))
REM: makes a decorative window announcing author and version
REM: allows user to show all windows created by DO_FORM
!***********************************************************
!*determines the size of the users screen *
!*calculates the mid point of the screen *
!*creates a window to fill the screen *
!*adds menu to window *
!*adds color and geometric decoration *
!*adds programe name, author and version number *
!***********************************************************

CALL TC_getscreensize(lscr,rscr,bscr,tscr)
LET midxscr=int((lscr+rscr)/2) ! mid x axis
LET midyscr=int((tscr+bscr)/2) ! mid y axis
CALL TC_setRect(0,lscr+4,rscr-4,bscr-36,tscr+44)
CALL TC_Win_SetTitle (0,caption$)
CALL TC_Menu_Set (0, zero$(,))

REM: set up logical window
ASK PIXELS xpix,ypix
SET WINDOW 0,xpix-1,ypix-1,0

REM: get window internal dimensions
CALL TC_getrect(0,wxl,wxr,wyb,wyt)
LET xs=wxr-wxl
LET x0=round(xs/2)
LET ys=wyb-wyt
LET y0=round(ys/2)
LET yq=round(y0/2)

REM: add main color blocks
SET COLOR 13
BOX AREA 1,xs,y0,0
SET COLOR -1
BOX AREA 1,xs,ys,y0

REM: add geometric decoration
SET COLOR 5
LET yp=int(yq/15)
LET m=0
FOR n=yp to 1 step-1
LET xn=n*10
LET m=m+1
BOX AREA 75,xs-75,y0+xn,y0+xn-m
BOX AREA 75,xs-75,y0-xn,y0-xn+m
NEXT n

REM: Main program title in Yellow
CALL TC_win_setfont(0,"TIMES",24,"BOLD")
SET COLOR 14
LET half=(STRWIDTH(0,caption$))/2
PLOT TEXT, AT x0-half,y0+10: caption$

REM: small print in white against black background
CALL TC_win_setfont(0,"SYSTEM",10,"BOLD")
SET COLOR 15
LET half=(STRWIDTH(0,version$))/2
PLOT TEXT, AT x0-half,(2*y0)-40: version$

CALL TC_win_setfont(0,"HELVETICA",8,"PLAIN")
SET COLOR 15
LET copy$="Copyright " & author$ & " " & date$[1:4]
LET half=(STRWIDTH(0,copy$))/2
PLOT TEXT, AT x0-half,(2*y0)-20: copy$
END SUB

SUB append_file(errorname$,anytext$)
REM: adds one line to an existing text file
CLOSE #11
OPEN #11: name errorname$, create newold, org text, access outin
RESET #11: end
SET #11: MARGIN maxnum
PRINT #11: anytext$
CLOSE #11
END SUB

DEF VALSTR(string$)

REM: converts string$ to a value without raising errors

LOCAL lens, temp$, hash, letter, negative, neg
LET lens = len(string$)
LET temp$ = ucase$(string$)
LET hash = cpos (temp$,"#")
IF hash > 0 then
LET temp$[hash:hash] = ""

END IF

LET letter = ncpos(temp$," 0123456789.-")

IF letter>1 then
LET temp$=temp$[1:letter-1]
LET letter=0
END IF

IF letter = 0 then
LET negative = 1
LET neg = cpos(temp$,"-")
IF neg > 0 then
LET negative = -1
LET temp$ = temp$[neg+1:lens]

END IF

LET temp$ = trim$(temp$)
IF len(temp$) = 0 then
LET valstr = 0
ELSE
LET valstr = val(temp$)*negative
END IF

ELSE
LET valstr = 0
END IF

END DEF

! *** END PROGRAM ***

REM: Untitled1