[comp.sys.handhelds] A workspace mannager for the HP48

frs@cube.rci.dk (Frederik Schroeder) (07/09/90)

                        HP48 Workspace manager version 1.00
                        (c) by Friedrich Schroeder june 1990


What is the Workspace manager ?

The Workspace manager is a shell with an organized set of functions to handle
and maintain your applications in an orderly and nice way. It is simply a
Workspace controller that gives you, among other things, the ability to build
application specific areas with the functions you need visible and the functions
you don't need (to see), hidden.



Tutor:

     How to invoke the Workspace manager

In the HOME directory press |WM|

The first time you do this you will se the following :

|    | |EXIT| |RESET| |BUILD| |CRUSH| |SIZE|
[NEXT] 
|SAVE| |LOAD|

This might change later on as you add labels to this directory.

Functions

Lets first look at the general functions. The maintenance functions are those
present in the Workspace manager making manipulation of the individual Workspaces
possible. If you by accident get out of the Workspace manager you are able to
get these functions back simply by pressing [CST].

EXIT                    ; takes nothing form the stack
Terminates the Workspace manager and enters the HOME directory.

RESET
Restores your favorite flags if in disorder or for convenience and clears the
stack.
You can change your favorite flags as follows :

     a)     Set your favorite flags and press |MAIN|
     b)     Then type RCLF 'FLAG' [STO]

BUILD                   ; Name of the workspace to build on level 1
Builds a Workspace with name defined by you.

SAVE                   ; Name of the workspace to save on level 1
Saves a Workspace to the PC (or any other kermit server) with name of Workspace
in stack level 1. This function works if the PC is running kermit server mode.

LOAD                   ; Name of the workspace to load on level 1
Opposite of save. Loads a Workspace from the PC (or any other kermit server)
with name of Workspace in stack level 1.

Size                   ; Name of the workspace to size on level 1
Returns the total size, in bytes, of the Workspace and associated functions
with the name in stack level 1.

CRUSH                   ; Name of the workspace to crush on level 1
Removes the Workspace with name in stack level 1. This function needs
verification with Y [ENTER].


Now lets try some of the maintenance functions.

Keys                    Display          Comments

'TEST [ENTER]          'TEST'           Enters the name of Workspace.
|BUILD|                                 The new Workspace is build.

The Workspace 'TEST' is now created. As you can see the name of the new
Workspace is added after the existing Workspaces, now we will activate it :

|TEST|                                  The Workspace is now active.

You will notice that the menu contains the global functions that is present
in all Workspaces, more about these later.

Lets exit the Workspace and remove it.

Keys                    Display          Comments

|MAIN|                                  Exits the Workspace TEST.
'TEST [ENTER]                           Put name of Workspace in stack level 1.
|CRUSH|                                 You are now asked to confirm the command.
Y [ENTER]                               The Workspace is now removed.

Now we will create a sample Workspace that can be of use.

Create the Workspace "FRAC"
'FRAC [ENTER] |BUILD|
and another one
'TEST [ENTER] |BUILD|

Enter the Workspace
|FRAC|

Now we have the Workspace "FRAC" activated with the general Workspace functions
available.

TIME
Returns the time of day. This is a examble of have a command as global label.

MAIN            ; take no input from the stack
Returns to the main menu in the workspace.

EXIT            ; take no input from the stack
Exit the Workspace manager and enter the HOME directory.

SPLBL           ; take a name or list of names from the stack
Create a specific label.

Press [NEXT]

GLLBL           ; take a name or list of names from the stack
Create a global label. All workspaces can see those labels.

NOLBL           ; take a name or list of names from the stack
Delete a specific/global label.

HIDE           ; take a name or list of names from the stack
Hide a variable.

LOCAL           ; take a name or list of names from the stack
Make a variable local.

GLOBL
Make a variable global.

Copy           ; take a name or list of names in level 2 and a name of
                 another workspace in level 1 from the stack
Copy a variable to another Workspace.

Press [NEXT]

MOVE           ; take a name or list of names in level 2 and a name of
                 another workspace in level 1 from the stack
Move a variable to another Workspace.

EXEC           ; take a name of a command in level 2 and a name of
                 another workspace in level 1 from the stack
Execute a program or function in another Workspace.


Now create tree variables named A,B and C with the contents 1,2 and 3.

3 [ENTER] 'C [STO]
2 [ENTER] 'B [STO]
1 [ENTER] 'A [STO]

You will see that the variables you just created is not visible in the general
Workspace menu. To see your variables simply press [VAR] and the menu with
your variables are made visible.
If at any time you would like to get hold of the general Workspace menu, all
you have to do is press [CST] and the general functions just discussed will
be at hand.

Now lets create a global variable named C.

'C [ENTER] [CST] [NEXT] |GLOBL|

The global is now created. This variable is now available in all old and newly
created Workspaces. If you press C [ENTER] the number three is returned.
Press [VAR] and you will see that the variable "C" is gone. It is simply
hidden but still available in all Workspaces.

Try it out, activate the TEST workspace
TEST
or
|MAIN| |TEST|
and evaluate C

go back to FRAC.

As you can see the label "C" is still gone in the USER menu FRAC. Now how do
you get rid of the GLOBAL.

To remove a GLOBAL simply make it LOCAL and delete it.

'C [ENTER] [CST] [NEXT] |LOCAL|

The variable "C" will now be available in the USER menu. Check it out !

[VAR]
As you see it is there. Try to delete it !

'C [PURGE]
And it is gone from USER, in fact it is gone forever.

This little exercise showed what LOCAL is doing as well as GLOBAL.

The next functions to recover are SPLBL, GLLBL and NOLBL.

These functions are used to manipulate labels that are in the CUSTOM menu in
any workspace.

SPLBL

Create a specific label.
This function is making a variable name specific for the workspace where it is
created. Try to create a specific label in the FRAC workspace !

  'B [ENTER] [CST] [NEXT] |SPLBL|

The "B" is now included in the CUSTOM menu as the first label in this menu.

Press | B |
The "B" contains the number two. So the specific label is added into the list
of workspace functions, but only in the specific workspace.

This is the general idea of the workspace. To make the programs available as
specific labels in the workspace, and keep the variables (the noise) hidden
for convenience or cosmetics.

GLLBL

Now create a build in command as global label

{ OFF } [ENTER] [NEXT] |GLLBL|

Press the |OFF| and see the calulator switch off.
Press on again.

This function is not included in the first row of menu labels, but in the second.
This is an indication that the label is global. To the right of this label,
you see one other label named TIME. These labels are made global at
start-up when installing the Workspace manager. The OFF label should appear in
all other workspaces as well.
Check it out in the TEST workspace.

NOLBL

If at any time you want to remove a specific or global label, all you have to do
is enter the name of the label to the stack and execute |NOLBL|.

Try to remove "B" in FRAC !

'B [ENTER] [NEXT] |NOLBL|

The label is removed from the specific label area in CUSTOM.

Now remove the OFF label !

{ OFF } [ENTER] [NEXT] |NOLBL|
And that one is also gone.

If you force yourself to use the SPLBL and GLLBL functions in your workspace,
you will learn yourself to use CST instead of VAR, and this way you will
get neat and clean way of presenting self-made programs and utilities to you
and your friends.

HIDE

The hide function is used whenever you want to hide a label in the specific
workspace. The way to get it back is to make it LOCAL.

MOVE

Copies e variable from the activ workspace to an other and deletes it in the
source workspace.

Lets move the "B" in FRAC to a variable named "B" in the TEST workspace.

'B [ENTER] 'TEST [ENTER] [CST] [NEXT] [NEXT] |MOVE|
The "B" is now moved. Lets check it out !

[USER] 'B [ENTER] 
It is gone.

[CST] |MAIN| |TEST| [USER]
And here it is !

COPY

Is basically the same as MOVE, but without deleting the variable in the source
workspace.

Now try for yourself to CRUSH the workspace FRAC and TEST .


ARGUMENTS

All the functions in the last pages are able to handle names and list of names
as well.
That is all about the Workspace. It might not get in place right away. 
Just remember that playing is learning !

________________________________________________________________________________



Installation of the workspace manager.

- Install PUTV and WSM.L in your HP48 HOME directory.
- Then put the contens of WSM.L on the stack and execute the PUTV programm.
- The following variables will be created in your HOME directory
        { WM CP MV SOB CD Purge GETV PUTV WS }.
- The list WSM.L can now be purged.
- Aktivate the workspace manager by press WM.

================== cut here and upload to the HP48 as PUTV =====================
@ PUTV                  ; put vars
%%HP: T(3)A(R)F(.);
\<< OBJ\-> 1
  START SWAP STO -2
  STEP
\>>

================== cut here and upload to the HP48 as WSM.L ====================
@ WSM.L                 ; list of the workspace manager
%%HP: T(3)A(R)F(.);
{

WM                      @ activated the workspace manager
\<< WS MAIN
\>>

CP                      @ copy variables from source path to destination
\<< PATH 4 ROLLD SWAP
CD SWAP GETV SWAP
CD PUTV CD
\>>

MV                      @ move variables form source path to destination
\<< PATH 4 ROLLD SWAP
CD SWAP DUP GETV
SWAP Purge SWAP CD
PUTV CD
\>>

SOB                     @ size of objects ( take a list of vars as arg. )
\<< { } + DUP SIZE \->
l s
  \<< 0
    IF s
    THEN 1 s
      FOR i l i GET
BYTES SWAP DROP +
      NEXT
    END
  \>>
\>>

CD                      @ change directory
\<< 1
  DO GETI EVAL
  UNTIL -64 FS?
  END DROP2
\>>

Purge                   @ purge both vars and dirs
\<< { } + DUP SIZE \->
l s
  \<< RCLF -55 CF
    IF s
    THEN 1 s
      FOR i l i GET
        IFERR PURGE
        THEN PGDIR
        END
      NEXT
    END STOF
  \>>
\>>

GETV                    @ get variables
\<< { } + DUP SIZE \->
l s
  \<<
    IF s
    THEN 1 s
      FOR i l i GET
DUP RCL
      NEXT
    END s 2 * \->LIST
  \>>
\>>

PUTV                    @ put variables
\<< OBJ\-> 1
  START SWAP STO -2
  STEP
\>>

WS                      @ the workspace directory
DIR
  WSU
    DIR
      GLOB { TIME }
    END
  CST { { } { EXIT
    \<< HOME 2 MENU
    \>> } { RESET
    \<< CLEAR FLAG
STOF
    \>> } BUILD CRUSH
Size SAVE LOAD }
  WS { }
  GUTIL { { EXIT
    \<< HOME 2 MENU
    \>> } { RESET
    \<< CLEAR FLAG
STOF
    \>> } BUILD CRUSH
Size SAVE LOAD }
  SUTIL { MAIN {
EXIT
    \<< HOME 2 MENU
    \>> } SPLBL GLLBL
NOLBL HIDE LOCAL
GLOBL COPY MOVE
EXEC }
  MAIN
    \<< HOME WS WS {
{ } } + GUTIL +
MENU
    \>>
  STRT
    \<< HOME WS WSU
EVAL VARS
      IF 'RUN' POS
      THEN RUN
      ELSE SMENU
      END
    \>>
  SMENU
    \<< SPEC { { } }
+ GLOB + { { } } +
SUTIL + MENU WRK
    \>>
  LOAD
    \<< \-> n
      \<<
        IF WS n POS
        THEN
"Name used" DOERR
        ELSE WSU n
          IFERR
KGET
          THEN
          ELSE
UPDIR 'WS' DUP EVAL
n + SWAP STO "\<<'" n
+ "' STRT" + OBJ\-> n
STO
          END MAIN
        END
      \>>
    \>>
  SAVE
    \<< HOME WS
      IF WS OVER
POS
      THEN WSU
        IFERR SEND
        THEN
        END
      END MAIN
    \>>
  Size
    \<< HOME WS
      IF WS OVER
POS
      THEN WSU SOB
      END MAIN
    \>>
  BUILD
    \<< \-> n
      \<<
        IF WS n POS
        THEN
"Name used" DOERR
        ELSE 'WS'
DUP EVAL n + SWAP
STO "\<<'" n +
"' STRT" + OBJ\-> n
STO WSU n DUP CRDIR
EVAL 'WRK' CRDIR {
} SPEC STO MAIN
        END
      \>>
    \>>
  CRUSH
    \<< HOME WS DUP
\->STR
", REALY(Y/N) ?" +
{ \Ga } INPUT
      IF "Y" ==
      THEN
        IF WS OVER
POS
        THEN DUP
PURGE DUP 'WS' DELL
WSU Purge MAIN
        END
      END
    \>>
  DELL
    \<< SWAP { } + \->
ln v
      \<< 1 v SIZE
        FOR j ln
RCL DUP v j GET POS
DUP 1 - 3 PICK SWAP
1 SWAP SUB SWAP 1 +
ROT SWAP OVER SIZE
SUB + ln STO
        NEXT
      \>>
    \>>
  MOVE
    \<< PATH SWAP
OVER 1 3 SUB SWAP +
'WRK' + MV
    \>>
  COPY
    \<< PATH SWAP
OVER 1 3 SUB SWAP +
'WRK' + CP
    \>>
  EXEC
    \<< PATH \-> p
      \<< EVAL WRK
EVAL p CD
      \>>
    \>>
  GLOBL
    \<< PATH DUP 1 3
SUB MV
    \>>
  LOCAL
    \<< DUP GETV SWAP
PATH DUP 1 4 SUB CD
OVER PURGE UPDIR
SWAP PURGE CD PUTV
    \>>
  HIDE
    \<< PATH DUP 1 4
SUB MV
    \>>
  GLLBL
    \<< GLOB + PATH
SWAP WSU 'GLOB' STO
DUP CD WRK UPDIR
SMENU CD
    \>>
  NOLBL
    \<< \-> l
      \<< PATH WRK
UPDIR l 'SPEC' DELL
PATH UPDIR l 'GLOB'
DELL CD SMENU CD
      \>>
    \>>
  SPLBL
    \<< SPEC + PATH
SWAP WRK UPDIR
'SPEC' STO SMENU CD
    \>>
END
}