' *** CHOICTBL.LST *** 2nd GFA-Manual, page 8-10 > PROCEDURE choice_table(line,VAR arr.table$(),arr.choice()) ' ' *** Choose from 2 or 3 choices for a number of items ' *** First call Procedure Choice_table_init to create the table arr.table$() ' *** Click with left mouse-button on choices ' *** Choices (0/1/2/3) for each item are returned in arr.choice&() ' *** Works in High or Medium resolution only! ' ' *** Standard: char.height& char.width& col.max& ' *** Procedure: Choice_table_init [call before using this Procedure!] ' LOCAL lines.max,choice1.col,choice2.col,choice3.col,text.col LOCAL k,len.sp,len.tk,len1,len2,len3,n,number,lin,standard LOCAL x,y,y1,y2,clicked!,ok!,choice1$,choice2$,choice3$,key$ DIM table.box$(3),table.x(6) lines.max=PRED(DIM?(arr.choice())) choice1.col=39 choice2.col=53 choice3.col=67 len.sp=12 len.tk=35 FOR n=1 TO lines.max lin=ADD(line,MUL(2,PRED(n))) choice1$=LEFT$(arr.table$(n,1),len.sp) len1=DIV(SUB(len.sp,LEN(choice1$)),2) choice1$=LEFT$(SPACE$(len1)+choice1$+SPACE$(SUCC(len1)),len.sp) choice2$=LEFT$(arr.table$(n,2),len.sp) len2=DIV(SUB(len.sp,LEN(choice2$)),2) choice2$=LEFT$(SPACE$(len2)+choice2$+SPACE$(SUCC(len2)),len.sp) choice3$=LEFT$(arr.table$(n,3),len.sp) len3=DIV(SUB(len.sp,LEN(choice3$)),2) choice3$=LEFT$(SPACE$(len3)+choice3$+SPACE$(SUCC(len3)),len.sp) text$=RIGHT$(SPACE$(len.tk)+arr.table$(n,0),len.tk) text.col=SUB(col.max,(ADD(LEN(text$),ADD(len.tk,char.width)))) standard=arr.choice(n) PRINT AT(text.col,lin);text$; PRINT AT(choice1.col,lin);choice1$; PRINT AT(choice2.col,lin);choice2$; table.x(1)=MUL(PRED(choice1.col),char.width) table.x(2)=MUL(ADD(choice1.col,PRED(LEN(choice1$))),char.width) table.x(3)=MUL(PRED(choice2.col),char.width) table.x(4)=MUL(ADD(choice2.col,PRED(LEN(choice2$))),char.width) table.x(5)=MUL(PRED(choice3.col),char.width) table.x(6)=MUL(ADD(choice3.col,PRED(LEN(choice3$))),char.width) y1=MUL(PRED(lin),char.height) y2=MUL(lin,char.height) BOX table.x(1),y1,table.x(2),y2 BOX table.x(3),y1,table.x(4),y2 GET table.x(1),y1,table.x(2),y2,table.box$(1) GET table.x(3),y1,table.x(4),y2,table.box$(2) IF arr.table$(n,3)>"" PRINT AT(choice3.col,lin);choice3$; BOX table.x(5),y1,table.x(6),y2 GET table.x(5),y1,table.x(6),y2,table.box$(3) ENDIF IF standard>0 PUT table.x(PRED(MUL(2,standard))),y1,table.box$(standard),8 ENDIF NEXT n PBOX SUB(MUL(33,char.width),3),SUB(MUL(23,char.height),3),ADD(MUL(45,char.width),2),ADD(MUL(24,char.height),2) PRINT AT(34,24);" OK "; SHOWM REPEAT REPEAT MOUSE x,y,k key$=INKEY$ IF key$=CHR$(13) ! , so we're ready ok!=TRUE PRINT AT(34,24);CHR$(27);"p";" OK ";CHR$(27);"q"; ENDIF EXIT IF ok! IF k=1 IF y>MUL(23,char.height) IF x>MUL(33,char.width) AND x clicked PRINT AT(34,24);CHR$(27);"p";" OK ";CHR$(27);"q"; ok!=TRUE ENDIF ELSE IF y>MUL(PRED(line),char.height) AND ytable.x(1) AND x"" PRINT AT(choice3.col,lin);choice3$; BOX table.x(5),MUL(PRED(lin),char.height),table.x(6),MUL(lin,char.height) ENDIF arr.choice(number)=1 clicked!=TRUE ELSE IF x>table.x(3) AND x"" PRINT AT(choice3.col,lin);choice3$; BOX table.x(5),MUL(PRED(lin),char.height),table.x(6),MUL(lin,char.height) ENDIF arr.choice(number)=2 clicked!=TRUE ELSE IF x>table.x(5) AND x"" PRINT AT(choice1.col,lin);choice1$; BOX table.x(1),MUL(PRED(lin),char.height),table.x(2),MUL(lin,char.height) PRINT AT(choice2.col,lin);choice2$; BOX table.x(3),MUL(PRED(lin),char.height),table.x(4),MUL(lin,char.height) PRINT AT(choice3.col,lin);CHR$(27);"p";choice3$;CHR$(27);"q"; arr.choice(number)=3 clicked!=TRUE ENDIF ENDIF ENDIF UNTIL clicked! OR ok! UNTIL ok! ERASE table.box$(),table.x() RETURN > PROCEDURE choice_table_init(VAR init.table$(),init.choice()) ' ' *** Call this Procedure before using Procedure Choice_table ' LOCAL n,i,lines.max,x$,standard RESTORE fill.table READ lines.max IF DIM?(init.table$()) ERASE init.table$(),init.choice() ENDIF DIM init.table$(lines.max,3),init.choice(lines.max) FOR n=1 TO lines.max i=0 DO READ x$ EXIT IF x$="*" init.table$(n,i)=x$ INC i LOOP READ standard init.choice(n)=standard NEXT n ' ' *** Number of items on first DATA-line ' *** Format of next lines: prompt,1st choice,2nd,[3rd],*,0/1/2/3 ' *** The '*' is a marker for the last choice (2 or 3 choices possible) ' *** Last digit is the default choice (0 is none) ' *** Prompt-string may be 35 characters long, the choice-strings 12 fill.table: DATA 3 DATA 1st line,1st choice,2nd choice,*,1 DATA 2nd question,first,second,third,*,0 DATA 3rd switch,on,off,*,2 RETURN ' ********* '