EPOC   SDK Home Glossary   Previous Next Up

RADRND


Contents


RAD — Converts from degrees to radians

Usage:      r=RAD(x)

Converts x from degrees to radians.

All the trigonometric functions assume angles are specified in radians, but it may be easier for you to enter angles in degrees and then convert with RAD.

Example:

    PROC xcosine:
          LOCAL angle
          PRINT "Angle (degrees)?:";
          INPUT angle
          PRINT "COS of",angle,"is",
          angle=RAD(angle)
          PRINT COS(angle)
          GET
    ENDP

(The formula used is (PI*x)/180).

To convert from radians to degrees use DEG.


RAISE — Raises an error

Usage:      RAISE x%

Raises an error.

The error raised is error number x%. This may be one of the errors listed in OPL error values, or a new error number defined by you.

The error is handled by the error processing mechanism currently in use — either OPL’s own, which stops the program and displays an error message, or the ONERR handler if you have ONERR on.


RANDOMIZE — Seeds the random number generator

Usage: RANDOMIZE x&

Gives a ‘seed’ (start-value) for RND.

Successive calls of the RND function produce a sequence of pseudo-random numbers. If you use RANDOMIZE to set the seed back to what it was at the beginning of the sequence, the same sequence will be repeated.

For example, you might want to use the same ‘random’ values to test new versions of a procedure. To do this, precede the RND statement with the statement RANDOMIZE value. Then to repeat the sequence, use RANDOMIZE value again.

Example:

    PROC SEQ:
          LOCAL g$(1)
          WHILE 1
                PRINT "S: set seed to 1"
                PRINT "Q: quit"
                PRINT "other key: continue"
                g$=UPPER$(GET$)
                IF g$="Q"
                      BREAK
                ELSEIF g$="S"
                      PRINT "Setting seed to 1"
                      RANDOMIZE 1
                      PRINT "First random no:"
                ELSE
                      PRINT "Next random no:"
                ENDIF
                PRINT RND
          ENDWH
    ENDP

REALLOC — Changes the size of a previously allocated cell

Usage:      pcelln&=REALLOC(pcell&,size&)

Change the size of a previously allocated cell at pcell& to size&, returning the new cell address or zero if there is not enough memory.

See also SETFLAGS if you require the 64K limit to be enforced. If the flag is set to restrict the limit, pcelln& is guaranteed to fit into an integer.

See also Dynamic memory allocation.

ARM

Cells are allocated lengths that are the smallest multiple of four greater than the size requested because the ARM processor requires a four-byte word alignment for its memory allocation. The ARM processor is used in the Psion Series 5 and other EPOC devices.


REM — Comment marker

Usage: REM text

Precedes a remark you include to explain how a program works. All text after the REM up to the end of the line is ignored.

When you use REM at the end of a line you need only precede it with a space, not a space and a colon.

Examples:

    INPUT a :b=a*.175  REM b=TAX
    INPUT a :b=a*.175  : REM b=TAX

RENAME — Renames files

Usage:      RENAME file1$,file2$

Renames file1$ as file2$. You can rename any type of file.

You cannot use wildcards.

You can rename across directories RENAME "\dat\xyz.abc","\xyz.abc" is OK. If you do this, you can choose whether or not to change the name of the file.

Example:

    PRINT "Old name:" :INPUT a$
    PRINT "New name:" :INPUT b$
    RENAME a$,b$

REPT$ — Repeats a string

Usage:      r$=REPT$(a$,x%)

Returns a string comprising x% repetitions of a$.

For example, if a$="ex", r$=REPT$(a$,5) returns exexexexex.


RETURN — Returns from a procedure

Usage:      RETURN
or      RETURN variable

Terminates the execution of a procedure and returns control to the point where that procedure was called (ENDP does this automatically).

RETURN variable does this as well, but also passes the value of variable back to the calling procedure. The variable may be of any type. You can return the value of any single array element - for example RETURN x%(3). You can only return one variable.

RETURN on its own, and the default return through ENDP, causes the procedure to return the value 0 or a null string.

Example:


RIGHT$ — Gets the rightmost characters of string

Usage:      r$=RIGHT$(a$,x%)

Returns the rightmost x% characters of a$.

Example:

    PRINT "Enter name/ref",
    INPUT c$
    ref$=RIGHT$(c$,4)
    name$=LEFT$(c$,LEN(c$)-4)

ROLLBACK — Cancels the current transaction on the current view

Usage:       ROLLBACK

Cancels the current transaction on the current view. Changes made to the database with respect to this particular view since BEGINTRANS was called will be discarded.

See also BEGINTRANS, COMMITTRANS.


RMDIR — Removes directories

Usage:      RMDIR str$

Removes the directory given by str$. You can only remove empty directories.


RND — Gets a pseudo-random floating point number

Usage:      r=RND

Returns a pseudo-random floating-point number in the range 0 (inclusive) to 1 (exclusive).

To produce random numbers between 1 and n e.g. between 1 and 6 for a dice use the following statement: f%=1+INT(RND*n)

RND produces a different number every time it is called within a program. A fixed sequence can be generated by using RANDOMIZE. You might begin by using RANDOMIZE with an argument generated from MINUTE and SECOND (or similar), to seed the sequence differently each time.

Example:

    PROC rndvals:
          LOCAL i%
          PRINT "Random test values:"
          DO
                PRINT RND
                i%=i%+1
                GET
          UNTIL i%=10
    ENDP
EPOC       SDK Home Glossary   Previous Next Up