*-----------------------*
* Reference : Functions * Sat Sep 28 17:23:04 1991
*-----------------------*


============================== Introduction ==================================

This reference file contains all functions. Commands are not in this file.
Note that you can use these functions from ARexx. Simply use the same format
for normal commands :

   A function call in PowerVisor : res=if(a>b,1,2)
   How you must do this in ARexx : 'if a>b 1 2'
                                   res=result


================================= isbreak ====================================

   <result> = ISBREAK( <address> )


Test if there is a ¹breakpoint in the ³current debug task on <address>.
If true this function returns the ²breakpoint number and the
²breakpoint type in one longword, else it returns 0.

   <result> has the following format :

      NNNNTTTT

   with NNNN a word containing the breakpoint number
   and TTTT containing the breakpoint type

   The following types are supported :
      'T'   ²temporary breakpoint
      'N'   ²normal breakpoint
      'P'   ²profile breakpoint
      'C'   ²conditional breakpoint
      'A'   ²after breakpoint (timeout)
      's'   breakpoint used to skip a BSR or JSR (private breakpoint)


Related commands: debug break trace

Related functions: getdebug toppc botpc

Related lists: dbug

Related tutor file: Debug


================================ geterror ====================================

   <error> = GETERROR( <expression string> )


³Evaluate an expression and ³return the error. If there was no error, 0
is returned.


Example :

< disp geterror(7) <enter>
> 00000000 , 0

0 since 7 is a valid expression.

< disp geterror(7+) <enter>
> 00000010 , 16

returns 16 since there is a missing operand.

The following errors are defined (Note ! Some of these are obsolete and
will never appear) (Note ! you can change the errorstrings since this file
is located in ¹s:PowerVisor-errors) :

-6       Stack overflow !!!
-5       A program has crashed !!!
-4       A stack overflow was getting close !
-3       Quiting PowerVisor !
-2       PowerVisor has crashed !
-1       Break...
0        No error
1        Not enough memory !
2        Syntax Error !
3        This is not a device created with OpenDev !
4        Bad list element type !
5        Variable is a constant !
6        Only <B>yte, <W>ord or <L>ong !
7        Odd address error !
8        Could not Lock!
9        Bracket '(' expected !
10       To many arguments for library function !
11       Missing operand !
12       Lock is not a subdirectory !
13       Error while opening device !
14       Unknown list element !
15       Not implemented yet !
16       Unknown mode argument !
17       Unknown AddFunc argument !
18       This is not a process !
19       Node is not a task or process !
20       This task is not freezed !
21       This task is already freezed !
22       Node type is wrong !
23       Addressed element not found !
24       Window is not sizeable !
25       This is no supported library function !
26       No help available for this subject !
27       Error while opening file !
28       Error while reading file !
29       Not a resident module !
30       Not a lock !
31       Bad History value (2..1000)
32       Error opening trackdisk device !
33       DoIO returned with a non zero value !
34       There is no task to debug !
35       Unknown argument for trace !
36       Unknown argument for debug !
37       Address is in ROM ! Can't set breakpoint !
38       Not a debug node !
39       Bad '@' argument
40       LoadSeg error !
41       Unknown argument for dmode !
42       There is no current debug task !
43       Unknown argument for break !
44       Breakpoint does not exist !
45       There are no symbol hunks !
46       Symbol not found !
47       You can only remove variables !
48       You can not assign to a function !
49       You must use brackets with functions !
50       Unknown argument for symbol !
51       There are no symbols !
52       You can only realloc blocks smaller than 64K !
53       Your brackets are really out of order !
54       The debug task is busy, please try again later !
55       The task is not tracing !
56       File does not have the right format !
57       This is not a structure definition !
58       Bad argument value !
59       No colorchange allowed when PowerVisor is on a window !
60       Could not open font !
61       Can't execute script file in script file !
62       Refresh window is not open !
63       Unknown tag type !
64       No output allowed on debug logical window !
65       Error writing file !
66       Not a Tag file !
67       Bad tag list value (0 .. 15) !
68       Unknown or invalid register !
69       There is a more recent patch then this one installed !
70       There is no fd file loaded for this library !
71       Unknown logical window !
72       Resulting commandline too long after converting from alias string !
73       Missing left bracket '(' in fd file !
74       Missing right bracket ')' in fd file !
75       Bad '##bias' statement in fd file !
76       You can't close the 'Main' physical window !
77       You can't close the 'Main' logical window !
78       Bad argument for 'openlw' ! Arg must be one of 'r','l','d' or 'u' !
79       Brother logical window must be on same physical window !
80       Window is not movable !
81       There is no father for this box !
82       Unknown preferences argument !
83       Please close visitor windows first !
84       Divide by zero !
85       No group operators allowed for the debug task !
86       Error opening screen !
87       You can't remove the 'rc' and 'error' variables. These are private !
88       'LoadSeg' failed !
89       Variable names must start with a letter or an underscore !
90       Error opening physical window !
91       Error opening logical window !
92       Bracket ')' expected !
93       Bracket '}' expected !
94       Bus error !
95       Address error !
96       Illegal instruction !
97       Division by zero !
98       CHK instruction !
99       TRAPV instruction !
100      Privilege Violation !
101      Trace error !
102      Unimplemented 1010 opcode !
103      Unimplemented 1111 opcode !


Related commands: error

Related tutor files: TheWizardCorner


================================ getstack ====================================

   <max stack> = GETSTACK( )


This function shows the maximum stack usage for the last task monitored with
the 'stack' command.


Related commands: stack


================================= getcol =====================================

   <columns> = GETCOL( <logical window> )


Get the real ³number of columns (or -1) for the ²logical window. Note that
this is not always equal to the visible number of columns. If <columns>
is not equal to -1 it is the total number of columns. If <columns> is equal
to -1 it means that the logical window is ¹autoscalable in horizontal
direction. To get the real number of columns (after scaling) you can use
the 'cols' function.

'getcol' uses ¹autodefault to the 'lwin' list for the first argument.


Related commands: colrow fit

Related functions: getrow cols lines getlwin getx gety

Related lists: lwin

Related tutor files: Screen


================================= getrow =====================================

   <rows> = GETROW( <logical window> )


Get the real ³number of rows (or -1) for the ²logical window. See the
explanation for 'getcol' to see what the -1 really means.

'getrow' uses ¹autodefault to the 'lwin' list for the first argument.


Related commands: colrow fit

Related functions: getcol cols lines getlwin getx gety

Related lists: lwin

Related tutor files: Screen


================================== eval ======================================

   <result> = EVAL( <string pointer> )


Evaluate the string at <string pointer> and return the result.
'eval' returns 0 if <string pointer> is 0.


Example :

< disp eval("1+2") <enter>
> 00000003 , 3

< scan <enter>
????< 4+4 <enter>
< disp eval(input) <enter>
> 00000008 , 8


Related commands: disp void

Related functions: if

Related tutor files: Expressions


=================================== if =======================================

   <result> = IF( <condition>,<expression 1>,<expression 2> )


If <condition> is true, evaluate <expression 1>, else evaluate
<expression 2>.


Example :

< d if(1,2,3) <enter>
> 00000002 , 2

< d if(0,2,3) <enter>
> 00000003 , 3

< a=1 <enter>
< b=2 <enter>
< c=3 <enter>
< d=4 <enter>
< e=5 <enter>
< d if(a,if(b,c,d),e) <enter>
> 00000003 , 3

< void if(a==1,{help functions},{help commands}) <enter>
> ...


Related commands: disp void

Related functions: eval

Related tutor files: Expressions


================================= taglist ====================================

   <taglist> = TAGLIST( )


Return the ³current tag list. This is a number between 0 and 15.
You can change the current tag list with the 'usetag' or 'tg' commands.


Related commands: usetag tg

Related tutor files: LookingAtThings


================================== peek ======================================

   <value> = PEEK( <structure pointer>,<struct def pointer>,<field name> )


Returns the value of <structure>.<field name>. <struct def pointer>
must be a pointer to a previously loaded ²structure definition. <structure
pointer> is the pointer to the ¹structure itself. <field name> must be defined
in the structure definition.

'peek' uses ¹autodefault to the 'stru' list for the second argument.


Related commands: addstruct interprete

Related functions: apeek stsize

Related lists: stru

Related tutor files: LookingAtThings


================================= stsize =====================================

   <size> = STSIZE( <struct def pointer> )


Return the size of the ¹structure represented by <struct def pointer>.
<struct def pointer> must be a ²structure definition loaded with 'addstruct'.

'stsize' uses ¹autodefault to the 'stru' list for the first argument.


Related commands: addstruct interprete

Related functions: peek apeek

Related lists: stru

Related tutor files: LookingAtThings


================================== apeek =====================================

   <address> = APEEK( <structure pointer>,<struct def pointer>,<field name> )


Returns the address of <structure>.<field name>. <struct def pointer>
must be a pointer to a previously loaded ²structure definition. <structure
pointer> is the pointer to the ¹structure itself. <field name> must be defined
in the structure definition.

'apeek' uses ¹autodefault to the 'stru' list for the second argument.


Related commands: addstruct interprete

Related functions: peek stsize

Related lists: stru

Related tutor files: LookingAtThings


================================== lines =====================================

   <lines> = LINES( <logwin> )


This function returns the maximum ³number of lines available on the
²logical window.

'lines' uses ¹autodefault to the 'lwin' list for the first argument.


Example :

< disp lines(main) <enter>
> 00000033 , 51


Related commands: colrow fit

Related functions: cols getcols getrows getlwin getx gety

Related lists: lwin

Related tutor files: Screen


================================== cols ======================================

   <cols> = COLS( <logwin> )


This function returns the maximum ³number of columns available on the
²logical window.

'cols' uses ¹autodefault to the 'lwin' list for the first argument.


Example :

< disp cols(main) <enter>
> 00000056 , 86


Related commands: colrow fit

Related functions: lines getcols getrows getlwin getx gety

Related lists: lwin

Related tutor files: Screen


================================= getlwin ====================================

   <logwin> = GETLWIN( )


This function returns a pointer to the ³current logical window.
The current logical window is not the same as the ³active logical window.
The current logical window is the one that shows all output. The active
logical window is the one where you can ¹scroll with the keyboard.


Related commands: current on active

Related functions: getactive

Related lists: lwin

Related tutor files: Screen


================================ getactive ===================================

   <logwin> = GETACTIVE( )


This function returns a pointer to the ³active logical window. This
is the logical window where you can ¹scroll with the keyboard.
You can change the active logical window with the 'active' command or with
the ²<tab> key.


Related commands: active on current

Related functions: getlwin

Related lists: lwin

Related tutor files: Screen


================================== getx ======================================

   <current x position> = GETX( )


Get the current x ¹coordinate on the ³current logical window (in columns).


Related commands: locate home cls current

Related functions: gety getcols getrows cols lines getlwin getchar

Related lists: lwin

Related tutor files: Screen


================================== gety ======================================

   <current y position> = GETY( )


Get the current y ¹coordinate on the ³current logical window (in lines).


Related commands: locate home cls current

Related functions: getx getcols getrows cols lines getlwin getchar

Related lists: lwin

Related tutor files: Screen


================================= getchar ====================================

   <char> = GETCHAR( )


Get the ¹character at the ²current screenposition in the
³current logical window.


Example :

< {locate 10,10;a=getchar()} <enter>


Related commands: locate home cls current

Related functions: getx gety getcols getrows cols lines getlwin

Related lists: lwin

Related tutor files: Screen


================================= lastmem ====================================

   <memory> = LASTMEM( )


This function returns the address that 'memory', 'view' and 'unasm' will use
to ³continue their listing.


Related commands: memory view unasm

Related functions: lastfound lastbytes lastlines

Related tutor files: LookingAtThings


================================ lastbytes ===================================

   <last number of bytes> = LASTBYTES( )


This function returns the last number of bytes used by 'memory' or 'view'
(320 by default).


Related commands: memory view

Related functions: lastmem lastlines

Related tutor files: LookingAtThings


================================ lastlines ===================================

   <last number of lines> = LASTLINES( )


This function returns the last number of lines used by 'unasm'
(20 by default).


Related commands: unasm

Related functions: lastmem lastbytes

Related tutor files: LookingAtThings


================================ lastfound ===================================

   <last found> = LASTFOUND( )


This function returns the address of the second byte of the string found
with 'search' or 'next'. This is the address where 'next' will continue
with the search.


Related commands: search next

Related functions: lastmem


================================== alloc =====================================

   <memory> = ALLOC( ('n',<size>) | ('c',<size>) | ('s',<string>) )


Use this function for easy ²memory allocation.
Use the 'free' function to free this memory, use the 'getsize' function
to get the size of this memory and use the 'realloc' function to ¹reallocate
the memory.

The memory allocated with this function is guaranteed to contain
only 0 (except if the first argument is equal to 's').

Note that memory allocated with this command is automatically freed
when PowerVisor quits.

When the blocksize is smaller than 65533 bytes the result from this function
is a pointer after a word containing the size. This pointer is thus word
alligned but not longword alligned.
When the blocksize is bigger the result is a pointer after a longword
containing the size. This pointer is longword alligned.
Using word or longword allignment you can determine the size of a memory
block. An easier way to do this is to use the 'getsize' function.


Example :


To allocate 1000 bytes :

< a=alloc(n,1000) <enter>


To allocate 11 bytes and copy the string 'PowerVisor' to this memory use :

< a=alloc(s,'PowerVisor') <enter>


To allocate 1000 bytes in chip ram use :

< a=alloc(c,1000) <enter>



Related commands: cleanup showalloc

Related functions: free realloc getsize isalloc


================================= realloc ====================================

   <new pointer> = REALLOC( <memoryblock>,<new size> )


Use this function to ¹reallocate a ¹memoryblock allocated with the
'alloc' function. Only memoryblocks smaller than 64K are supported.


Related commands: cleanup showalloc

Related functions: alloc free getsize isalloc


================================== free ======================================

   FREE( <pointer> )


Free a block previously allocated with 'alloc'.
Note that all memory allocated with 'alloc' is automatically freed when
PowerVisor quits or when you use 'cleanup'.


Related commands: cleanup showalloc

Related functions: alloc realloc getsize isalloc


================================= getsize ====================================

   <size> = GETSIZE( <memoryblock> )


This function determines the size of a ¹memoryblock allocated with the
'alloc' function or some other PowerVisor commands.


Related commands: cleanup showalloc

Related functions: alloc free isalloc realloc


================================= isalloc ====================================

   <pointer to pointer> = ISALLOC( <pointer> )


This function checks if <pointer> points to a ¹memoryblock allocated
with the 'alloc' function. If it is, 'isalloc' returns a pointer to
the pointer, otherwise 0.


Related commands: cleanup showalloc

Related functions: alloc free realloc getsize


================================= rfrate =====================================

   <refresh rate> = RFRATE( )


Return the current ²refresh rate installed with the 'refresh' command.


Related commands: refresh rwin

Related functions: rfcmd


================================== rfcmd =====================================

   <pointer to refresh command> = RFCMD( )


Return a pointer to the current ²refresh command (or 0).
This function returns a string if used from ¹ARexx.


Related commands: refresh rwin

Related functions: rfrate


================================= curlist ====================================

   <pointer to string> = CURLIST( )


Return a pointer to the name of the ²current list.
This function returns a string if used from ¹ARexx.

Note for experienced users only !
   The pointer to the string is actually a pointer into the infoblock
   for the current list. curlist()-24 points to the start of the infoblock.
   See 'TheWizardCorner' for more information about infoblocks (in the
   'info base').
   Note that if you want to use this feature in ARexx you have to call
   this function using 'void' or 'assign'. If you call it directly you
   will get a string and not a pointer in ARexx


Related tutor files: GettingStarted TheWizardCorner


=================================== key ======================================

   <vanillakey> = KEY( )


Wait for a key and return the ²ascii value.
This is especially useful in ¹scripts.


Related commands: scan request

Related functions: qual


================================== qual ======================================

   <qualifier> = QUAL( )


Return the ¹qualifier for the ³last pressed key (with 'key').


Example :

< a=key() <enter>
< disp qual() <enter>


Related commands: scan

Related functions: key


================================== toppc =====================================

   <programcounter> = TOPPC( )


This function returns the ²program counter visible at the top of the
³'Debug' logical window.
You can set this program counter using the 'dstart' or 'dscroll' commands.


Related commands: debug dwin dscroll dstart

Related functions: botpc isbreak getdebug

Related lists: dbug

Related tutor files: Debug


================================== botpc =====================================

   <programcounter> = BOTPC( )


This function returns the ²program counter visible at the bottom of the
³'Debug' logical window.
You can set this program counter using the 'dstart' or 'dscroll' commands.


Related commands: debug dwin dscroll dstart

Related functions: toppc isbreak getdebug

Related lists: dbug

Related tutor files: Debug


================================ getdebug ====================================

   <debug node> = GETDEBUG( )


Return the ³current debug node. You can set the current debug node with
'duse' and 'with'.


Related commands: duse with debug

Related functions: isbreak toppc botpc

Related lists: dbug

Related tutor files: Debug


================================== base ======================================

   <pointer> = BASE( )


This function returns the pointer to the ²first element in the ²current list.


Example :

Go to the task list :
< task <enter>

< list <enter>
> Task node name      : Node     Pri StackPtr  StackS Stat Command        Acc
> ---------------------------------------------------------------------------
> RAM                 : 00C20C68 00  00C2117A    1200 Rdy            PROC -
> golem.device        : 00C05C8A 05  00C064B6    2048 Wait           TASK -
> NEWCON              : 00C2CAA8 05  00C2DAA2    4000 Wait           PROC -
> ARP Shell Process   : 00C26180 00  00C270F2    4000 Wait           (03) -
> PowerVisor1.0.task  : 00C31C28 00  00C76132    1024 Wait           TASK -
> File System         : 00C16758 0A  00C16AF6     840 Wait           PROC -
> File System         : 00C172E8 0A  00C17686     840 Wait           PROC -
> trackdisk.device    : 00C068DE 05  00C09F2E     512 Wait           TASK -
> trackdisk.device    : 00C17846 05  00C17A5E     512 Wait           TASK -
> DH0                 : 00C0DF08 0A  00C0E356    1000 Wait           PROC -
> input.device        : 00C03BFA 14  00C04C00    4096 Wait           TASK -
> ARP Background She  : 00C66EB8 00  00C75CD2    4000 Run  pv        (01) -

< d base() <enter>
> 00C20C68 , 12717160


Related commands: list
