IFERR? Interception of an input error
|
03-10-2017, 08:25 AM
(This post was last modified: 03-10-2017 09:01 AM by Onieh.)
Post: #1
|
|||
|
|||
IFERR? Interception of an input error
Hello,
I would not want which falls that programme if I ENTER presses without giving before 4 letters. for example, EDUS or EDAX etc. Even if I figures give the programme should not fall, sonder as long as wait to me 4 letters has given. Addition: if I enter four letters and the is not there, the program should not crash, but the MSGBOX notify that the letters are not in the spreadsheet! i.e. ABCD EXPORT Navigation() BEGIN LOCAL I,A,B,C,D,E,F,G; LOCAL H; STARTAPP("Flugplatz"); INPUT({{H,[2]}},"Flugplatzkennung"); //INPUT Airfield i.e. EDUS RECT_P(0,0,320,240,RGB(0,205,205)); I:=POS(a:a,H); TEXTOUT_P("F l u g p l a t z",90,0,7); 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; |
|||
03-10-2017, 12:47 PM
Post: #2
|
|||
|
|||
RE: IFERR? Interception of an input error | |||
03-10-2017, 01:01 PM
Post: #3
|
|||
|
|||
RE: IFERR? Interception of an input error
(03-10-2017 12:47 PM)EdDereDdE Wrote:(03-10-2017 08:25 AM)Onieh Wrote: INPUT({{H,[2]}},"Flugplatzkennung"); //INPUT Airfield i.e. EDUS Hallo, sorry mein Englisch ist nicht so gut. Also, sofern die Flugplatzkennung, das sind in der Regel 4 Buchstaben, z.B. EDAX noch nicht eingegeben worden sind und man Enter druck stürzt das Programm ab. Das gleich gilt wenn ich Zahlen eingebe. Ich benötige eine Routine, die erst dann im Programm weiter mach, wenn die Kennung richtig eingegeben worden ist. Sollte jedoch ABCD eingegeben werden, soll eine Dialogbox erscheinen, die besagt, dass es diese Kennung nicht gibt. |
|||
03-10-2017, 02:01 PM
Post: #4
|
|||
|
|||
RE: IFERR? Interception of an input error
Naja, das ist wie bei einem PC-Programm:
Du bettest den Input in eine Schleife ein, die solange nicht verlasssen wird, wie die Eingabe nicht im erwarteteten Rahmen liegt. Abstract: PHP Code: OK := 0; PHP Code: is_numeric(H) |
|||
03-10-2017, 02:25 PM
Post: #5
|
|||
|
|||
RE: IFERR? Interception of an input error
(03-10-2017 02:01 PM)EdDereDdE Wrote: Naja, das ist wie bei einem PC-Programm: Danke, ich werde das mal ausprobieren. Das mit dem ABCD war nur ein Beispiel. Kann auch cccc od. fefe od. tttt, etc, sein. Auf jeden Fall ein Ausdruck der nicht im Spreadsheet enthalten ist! Im Spreadsheet fangen die meisten mit ED.. an, z. B. EDKA od. EDHO, oder EDBT, etc. |
|||
03-10-2017, 03:08 PM
Post: #6
|
|||
|
|||
RE: IFERR? Interception of an input error
(03-10-2017 02:01 PM)EdDereDdE Wrote: There is a bug in your code. Num would be non-zero as long as the last character is numeric. Your IF statement should be: IF (num == 0) THEN RETURN(0); END; There is no need for CONTINUE, since there is no code to skip after the IF statement. In fact, the current IF statement doesn't actually do anything when you trace the logic. Also, as an alternative to POS(), you could use: num:=(ASC(H(c)) > 46) AND (ASC(H(c)) < 58); (The latter suggestion is only pertinent for speed, and when testing for a larger range since POS() could in theory check all the way to the last item in the list.) Graph 3D | QPI | SolveSys |
|||
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() |
|||
03-10-2017, 05:06 PM
Post: #8
|
|||
|
|||
RE: IFERR? Interception of an input error
(03-10-2017 04:39 PM)Didier Lachieze Wrote: 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. Wow, it's a very good INPUT. Thank you very much!!! |
|||
03-10-2017, 07:51 PM
Post: #9
|
|||
|
|||
RE: IFERR? Interception of an input error
(03-10-2017 03:08 PM)Han Wrote: There is a bug in your code. Num would be non-zero as long as the last character is numeric. Your IF statement should be: IF (num == 0) THEN RETURN(0); END; Right Han, i was meaning "BREAK", but a direct RETURN works as well. I was typing this "on the go" on my tablet, neither on Emulator nor "real" calculator |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)