| Previous | Contents | Index |
The REMAP statement defines or redefines the position in the storage area of variables named in the MAP DYNAMIC statement.
In the FILL clause, (int-exp) represents a repeat count, not an array subscript. FILL (n), for example, represents n elements, not n + 1. |
100 MAP (DUMMY) STRING map_buffer = 50
MAP DYNAMIC (DUMMY) LONG A, STRING B, SINGLE C(7)
REMAP (DUMMY) B=14, A, C()
|
100 MAP (DUMMY) STRING FILL = 48
MAP DYNAMIC (DUMMY) LONG A, B(10)
REMAP (DUMMY) B(), B(0)
|
DECLARE LONG CONSTANT emp_fixed_info = 4 + 9 + 2
MAP (emp_buffer) LONG badge, &
STRING social_sec_num = 9, &
BYTE name_length, &
address_length, &
FILL (60)
MAP DYNAMIC (emp_buffer) STRING emp_name, &
emp_address
WHILE 1%
GET #1
REMAP (emp_buffer) STRING FILL = emp_fixed_info, &
emp_name = name_length, &
emp_address = address_length
PRINT emp_name
PRINT emp_address
PRINT
NEXT
END
|
SUB deblock (STRING input_rec, STRING item())
MAP DYNAMIC (input_rec) STRING A(1 TO 3)
REMAP (input_rec) &
A(1) = 5, &
A(2) = 3, &
A(3) = 4
FOR I = LBOUND(A) TO UBOUND(A)
item(I) = A(I)
NEXT I
END SUB
|
The RESET statement is a synonym for the RESTORE statement. See the RESTORE statement for more information.
The RESTORE statement resets the DATA pointer to the beginning of the DATA sequence, or sets the record pointer to the first record in a file.
RESTORE #7%, KEY #4% |
The RESUME statement marks an exit point from an ON ERROR error-handling routine. BASIC clears the error condition and returns program control to a specified line number or label or to the program block in which the error occurred.
The RESUME statement is supported for compatibility with other versions of BASIC. For new program development, it is recommended that you use WHEN blocks. |
Target must be a valid BASIC line number or label and must exist in the same program unit.
Error_routine:
IF ERR = 11
THEN
CLOSE #1
RESUME end_of_prog
ELSE
RESUME
END IF
end_of_prog: END
|
The RETRY statement clears an error condition and reexecutes the statement that caused the error inside a protected region of a WHEN block.
The RETRY statement must appear lexically inside of a handler associated with a WHEN block.
The following rules apply to errors that occur during execution of loop control statements (not the statements inside the loop body):
10 DECLARE LONG YOUR_AGE
WHEN ERROR IN
INPUT "Enter your age";your_age
USE
IF ERR = 50
THEN RETRY
ELSE EXIT HANDLER
END IF
END WHEN
|
The RETURN statement transfers control to the statement immediately following the most recently executed GOSUB or ON...GOSUB statement in the current program unit.
None
GOSUB subroutine_1 . . . subroutine_1: . . . RETURN |
The RIGHT$ function extracts a substring from a string's right side, leaving the string unchanged.
None
DECLARE STRING main_str, &
end_result
main_str = "1234567"
end_result = RIGHT$(main_str, 3)
PRINT end_result
|
Output
34567 |
The RMSSTATUS function returns the RMS status or the status value of the last I/O operation on a specified open I/O channel.
%TITLE "RMSSTATUS Example"
%SBTTL "Reference Manual Examples"
%IDENT "V1.0"
PROGRAM Demo_RMSSTATUS_function
OPTION CONSTANT TYPE = INTEGER
OPEN "DOES_NOT_EXIST.LIS" FOR OUTPUT AS 1, &
SEQUENTIAL VARIABLE, &
RECORDSIZE 80
WHEN ERROR IN
GET #1
USE
PRINT "GET Operation failed"
PRINT "RMS Status ="; RMSSTATUS(1,STATUS)
PRINT "RMS Status Value ="; RMSSTATUS(1,VALUE)
END WHEN
END PROGRAM
|
OPTION TYPE=EXPLICIT
EXTERNAL LONG CONSTANT RMS$_OK_DUP
MAP (ORDER) LONG ORD_ENTRY, STRING ORD_CUST_NO = 6%, &
STRING ORD_REMARK = 50%
OPEN "ORD_DB" FOR INPUT AS FILE 1%, &
ORGANIZATION INDEXED FIXED, &
MAP ORDER, &
PRIMARY ORD_ENTRY NODUPLICATES, &
ALTERNATE ORD_CUST_NO DUPLICATES
INPUT "Enter order number";ORD_ENTRY
INPUT "Enter customer number";ORD_CUST_NO
INPUT "Remark";ORD_REMARK
!
! Enter the order in the order database
! Check if the customer has other orders
!
PUT #1%
IF RMSSTATUS( 1%, STATUS ) = RMS$_OK_DUP
THEN
!
! The customer has other orders; compute the customer's
! discount for other orders
!
END IF
CLOSE 1%
END
|
The RND function returns a random number greater than or equal to zero and less than 1.
None
DECLARE REAL random_num
RANDOMIZE
FOR I = 1 TO 3 !FOR loop causes BASIC to print three random numbers
random_num = RND
PRINT random_num
NEXT I
|
Output
.865243 .477417 .734673 |
| Previous | Next | Contents | Index |