From d88-cwe@nada.kth.se Mon Apr 30 18:57:55 1990
From: d88-cwe@nada.kth.se (Christian Wettergren)
Newsgroups: comp.sys.handhelds
Subject: Re: LESS - a simple stringviewer for 28s
Date: 27 Apr 90 12:12:51 GMT
Reply-To: d88-cwe@nada.kth.se (Christian Wettergren)
Organization: Royal Institute of Technology, Stockholm, Sweden

In article <6752.2636037d@abo.fi>, oholm@abo.fi writes:
> Finally someone who hasn't sold his 28 and got a 48.
> I want MORE !

Ok, you've got it!

To begin with, what about some named flags ?

This is a short package of routines that makes it 
possible to manipulate the 32 userflags and the
32 machineflags in the HP28S by names. It should
not add too much overhead to the programs, especially
not if the names already exists. It is also easier
for different programs to use the flags without fear
of any conflict!

First, a routine that defines a flag.

'DFLG'
<< { HOME } JDIR -> N
   << IF
        N "Z" POS 1 ==
      THEN
        "INTERNAL FLAG, ABORTED" RDIR KILL
      END
      IF
        FLAGS N POS NOT
      THEN
        FLAGS 'o' POS -> I
        << IF 
              I
           THEN
              FLAGS 1 I 1 - SUB N FLAGS I 1 +
              33 SUB + + 'FLAGS' STO
           ELSE
              "DFLG ERROR, OUT OF FLAGS" RDIR KILL
           END
         >>
       END
    >> RDIR
>>

You should be able to undefine it too.

'UFLG'
<< { HOME} JDIR -> N
    <<
       IF
           N "Z" POS 1 ==
       THEN
           "INTERNAL FLAG, ABORTED" RDIR KILL
       END
       IF 
           FLAGS N POS
       THEN
           FLAGS N POS -> I
           << FLAGS 1 I 1 - SUB 'o' FLAGS I 1 +
              33 SUB + + 'FLAGS' STO
           >>
        END
     >> RDIR
>>


Change the value of a named flag. If the flag doesn't
exist, it is created.

'PFLG'
<< -> B N 
   << FLAGS N POS 
      IF 
        DUP NOT 
      THEN
        DROP N DFLG B N PFLG
      ELSE
        IF 
           B
        THEN
           SF
        ELSE
           CF
        END
      END
    >>
>>


Gets the current value of a flag.

'GFLG'
<< -> N
    << FLAGS N POS
       IF
          DUP NOT
       THEN
          DROP "GFLG ERROR, UNDEFINED FLAG" KILL
       ELSE
          FS?
       END
     >>
>>

To speed things up, use this. It gets the number
of the userflag. It can afterwards be used directly.

'IFLG'
<< -> N
   << FLAGS N POS
      IF
         DUP NOT
      THEN
         DROP "IFLG ERROR, UNDEFINED FLAG" KILL
      END
   >>
>>


Toggles the value of a flag.

'TFLG'
<< -> N
    << IF
         N GFLG
       THEN
         0 N PFLG
       ELSE
         1 N PFLG
       END
     >>
>>

Here's the datastructure that holds the names.
The flags beginning with Z is systemflags, and
can not be namechanged or deleted.

'FLAGS'
{ o o o o o o o o o o o o o o o o
  o o o o o o o o o o o o o o o o
  ZLAST ZTRACE ZAUTOCR ZGENSOL ZCONST ZRESCONST
  ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZZ ZML ZIDXWRAP Z2SPC
  ZRADIX ZBEEP ZPRTSPEED ZZ ZZ ZZ ZZ ZUFLWERR 
  ZOFLWERR ZINFERR ZANGLE ZUFLWP ZUFLWN ZOFLW
  ZINF }

The remaining part is a retake of some common
routines I use; ( ROOT is my userlevel directory )

'JDIR'
<< -> DP
   << PATH
      IF 
         DP TYPE 5 ==
      THEN
         DP CD
      ELSE
         IF 
            DP TYPE 6 ==
         THEN
            ROOT DP EVAL
         END
      END
      'TDIR' STO
    >>
>>

'RDIR'
<< IFERR 'TDIR' RCL 'TDIR' PURGE CD THEN DROP END >>

'CD'
<< ->STR 3 OVER SIZE 2 - SUB STR-> >>


If anyone is interested, I could post a short memoprog
that I usually bring up upon start of my HP28S.

Regards,
	Christian Wettergren

--------------------------------------------------------------------------
"Computer Science is not about computers, any more than astronomy is about
 telescopes" - Edgar Dijkstra
Christian Wettergren, d88-cwe@nada.kth.se, 08 - 36 96 92

