Post Reply 
IFERR? Interception of an input error
03-10-2017, 04:39 PM
Post: #7
RE: IFERR? Interception of an input error
Here is a way to control the input to be only 4 letters within the spreadsheet. If you enter 4 letters that are not found in the spreadsheet they will turn red and you have to press the Del key to fix your entry.

PHP Code:
EXPORT Navigation()
BEGIN
LOCAL I
,A,B,C,D,E,F,G;
LOCAL H,K,Letter;
LOCAL Keys:={"-","-","-","-","-",
"-","-","-","-",
"-","-","-","-","-",
"A","B","C","D","E","Del",
"F","G","H","I","J","K",
"L","M","N","O","-",
"P","Q","R","S","T",
"-","U","V","W","X",
"-","Y","Z","-","-",
"-","-","-","-","-"};

STARTAPP("Flugplatz");

RECT_P(0,0,320,240,RGB(0,205,205));       //Clear screen

TEXTOUT_P("F l u g p l a t z",90,0,7);

H:=""I:=0;
WHILE 
I<OR POS(a:a,H)==DO            //Loop until we got 4 letters that are in the spreadsheet
 
Letter:="-";
 WHILE 
Letter=="-" DO                    //Loop until a letter or the Del key is pressed
   
K:=0
   WHILE 
K=DO K:=WAIT()+1END;      //Wait until a key is pressed and get the key code
   
Letter:=Keys(K);                      //Convert the keycode to a letter
 
END;
 IF 
Letter=="Del" THEN                   //If Del key has been pressed, clear text and remove one letter from H 
   
IF I>0 THEN TEXTOUT_P(H,90,40,4,RGB(0,205,205),90,RGB(0,205,205));IFTE(I=1,H:="",H:=LEFT(H,I-1));I:=I-1END;
 ELSE                                    
//Else it's a letter, 
   
IF I<4 THEN H:=H+Letter;I:=I+1END;  // add it to H and increase the number of letters if we have not yet 4 letters
 
END;
 IF 
I==AND POS(a:a,H)==0 THEN          //If we have 4 letters that are not in the spreadsheet ...
   
TEXTOUT_P(H,90,40,4,RGB(255,0,0),90,RGB(0,205,205));  // ... then print them in RED ...
 
ELSE
   
TEXTOUT_P(H,90,40,4);                 // .. else print current letters in black
 
END;
END;

I:=POS(a:a,H);

RECT_P(0,32,320,34);

//TEXTOUT_P((EXPR("A"+I)),90,40,4);
TEXTOUT_P((EXPR("B"+I)),90,70,4);
TEXTOUT_P((EXPR("C"+I)),90,100,4);
TEXTOUT_P((EXPR("D"+I)),90,130,4);
TEXTOUT_P((EXPR("E"+I)),90,160,4);

WAIT();
FREEZE;

STARTVIEW (-1);
END
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: IFERR? Interception of an input error - Didier Lachieze - 03-10-2017 04:39 PM



User(s) browsing this thread: 1 Guest(s)