home *** CD-ROM | disk | FTP | other *** search
-
- UTILS a FORTRAN general utilities subroutine library. 18 Nov 1991
-
- ************************************************************************
- C O P Y R I G H T N O T I C E
-
- Copyright D.J & K.M. Crennell,
- P.O. Box 64, Didcot, Oxon, OX11 0TH.
-
- This software is in the Public Domain and may not be sold or included in any
- program that will be sold, without written permission from the authors.
-
- The authors must be given credit in any publications using this software.
-
- The software may be copied and distributed as long as no changes are made
- and this copyright notice is included. Please send any suggested
- improvements to the authors.
-
- In no circumstances shall the authors be liable for any damage, loss of
- profits, or any indirect or consequential loss arising out of the use of
- this software or inability to use this software, even if they have been
- advised of the possibility of such loss.
-
- The authors do their best to ensure that this library is distributed virus
- free.
- ************************************************************************
-
- The source of this library is assembler, and is not included.
- The library is %.lib.utils
-
- Updates
- 18 Jun 1992: SWIF77 no longer writes over its own code.
- 30 Aug 1992: CDATE added
- 02 Nov 1992: SWIF77 corrected to run under RISC-OS 3.10
-
- CHARACTER FUNCTION CDATE()
- Returns the current date and time as a CHARACTER variable (of length at
- least 25, otherwise the function does nothing). The string is of the form:
- ddd,nn mmm yyyy.hh:mm:ss<Return>
- E.g. Sun,30 Aug 1992.10:22:47
-
- FUNCTION IGET()
- Emulates the BASIC command GET:
- waits for a key press & returns an ASCII character
-
- FUNCTION INKEY(NUM)
- Emulates the BASIC command INKEY:
- If NUM>= 0 returns an ASCII character of a key pressed within NUM
- centiseconds. If NUM <0 checks whether this key (or mouse button is
- currently pressed. (see BASIC manual Appendix C page 411 for INKEY values)
-
- FUNCTION LNBLNK(STRING)
- Returns the index to the last non-blank character in CHARACTER STRING
-
- FUNCTION LOC(VAR)
- Returns the memory address of variable VAR in BYTES
-
- FUNCTION LOCC(CHARAC)
- Returns the memory address of character string CHARAC in BYTES
-
- MOUSE(MX,MY,MBUTN)
- Emulates the BASIC command MOUSE X%,Y%,B%:
- where MX,MY are the mouse pointer co-ordinates and MBUTN shows which mouse
- button is pressed, 1=adjust, 2=menu, 4=select
-
- QSORTD(D,INDEX,N)
- QSORTI(I,INDEX,N)
- QSORTR(R,INDEX,N)
- Quicksort of the index to an array of DoublePrecision, Integer or Real
- variables.
- N is the dimension of the array to sort;
- D, I, or R is the array of variables;
- INDEX is an array of pointers which must span the whole of the array of
- variables. Normally this will be the integers 1 to N in any order. However,
- if the array to sort is multilply dimensioned (E.g. DIMENSION XYZ(3,10) for
- the x, y & z of 10 points), then INDEX could have other values
- (= 3,6,9 .. 30 for the previous example if you want to sort on z).
- After the sort, the pointers in INDEX are ordered so that they address
- the array to give algebraically increasing values.
- Note, this sort does not use the FPEmulator, and hence is extremely
- fast. E.g. 100,000 real numbers are sorted in 2.4 seconds with ARM3.
-
- SWIERR(IERR,REPORT,LEN)
- Returns the error number in IERR, and the report in character variable
- REPORT after an errror detected by SWIF77. The length of the report is in
- LEN, but it may get truncated if REPORT is too small.
-
- LOGICAL FUNCTION SWIF77(NUMB,IREGS,IFLAG)
- Performs the SWI number NUMB. IREGS(0:7) must contain the register values
- for input, and will contain the values output. It must be at least 8 words
- long even if the particular SWI uses less, because copies of registers 0 to
- 7 are always returned.
- IFLAG returns the flags N Z C V in bits 3 2 1 0
- The function returns .FALSE. if SWI is OK, otherwise .TRUE., when the error
- can be found from SUBROUTINE SWIERR.
-
- Example:
-
- C readĀ file names in directory $.LIBRARY using SWI OS_GBPB
- C
- DIMENSION IREGS(0:7)
- CHARACTER*11 FILE
- C
- C N countsĀ files
- N=0
- C OS_GBPB type 9 reads only file names from directory
- IREGS(0)=9
- C location of directory name as null terminated string
- IREGS(1)=LOCC('$.LIBRARY'//?H00)
- C location in memory for answer (Character variable FILE)
- IREGS(2)=LOCC(FILE)
- C one name to read at a time
- IREGS(3)=1
- C initialize index of name to read
- IREGS(4)=0
- C maximum size for output name
- C (FILE is CHARACTER*11 to include the null terminator)
- IREGS(5)=11
- C no wild-carded name to match
- IREGS(6)=0
- WRITE(*,*)' files in $.LIBRARY are:'
- C do SWI to OS_GBPB (SWI &0C)
- 2 IF(SWIF77(?I0C,IREGS,IFLAG)) CALL ERROR
- C check if finished
- IF(IREGS(4).LT.0.OR.IREGS(3).LE.0) GO TO 4
- C count names
- N=N+1
- C find length of name from null termination
- I=INDEX(FILE,?H00)
- C print name
- WRITE(*,*)' ',FILE(1:I-1)
- C look for next name
- GO TO 2
- C come here when finished
- 4 WRITE(*,*)' number of files = ',N
-