they will test whether the X register contains an integer (Z?) or a non-negative integer (N?). (Yes I know that is technically N0? - but it's easier to subsequently test for 0 than the other way round).

Code: Select all

```
00 { 53-Byte Prgm }
01▸LBL "N?"
02 XEQ 10 @ integer?
03 STR? @ aff
04 RTNNO
05 X<0?
06 GTO 05
07 RTNYES
08▸LBL 10
09▸LBL "Z?"
10 REAL?
11 GTO 00
12 STR?
13 1
14 REAL?
15 X=0? @ aff
16 4
17 RTNNO
18▸LBL 00
19 IP
20 X=? ST L
21 RTNYES
22▸LBL 05
23 5
24 RTNNO
25 END
```

test for integers:

Code: Select all

```
00 XEQ "Z?"
00 STR? @ always false filler
00 RTNERR IND ST X
```

Code: Select all

```
00 XEQ "N?"
00 X<0? @ aff
00 RTNERR IND ST X
00 X=0?
00 RTNERR 5
```

Now, there is a tiny problem with these routines: I would like them to not disturb the stack when no error occurs, and to have the error number in X when an error does occur. I can't use FUNC 00, because that will always restore the stack. As it is, L is destroyed when no error occurs. I can solve this with a local variable, but that's clumsy. Suggestions welcome.

(and yes, to make it more elegant, the tests should be "^N?" and "^Z?", then the aff's would not be needed).

Cheers, Werner