UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software UniBasic Commands Reference - Rocket Software

rocketsoftware.com
from rocketsoftware.com More from this publisher
11.04.2013 Views

Examples The following program statement eliminates the record with the ID of PEANUT from the default file: DELETE "PEANUT" The following program segment deletes the record whose ID is specified by the variable DEL_ID from the file previously opened to the PARTS variable: DEL_ID = "HOOK" DELETE PARTS, DEL_ID The following statement is invalid because the file variable is specified incorrectly in the DELETE statement: 1-203 UniBasic Commands Reference OPEN 'CUSTOMER' TO CUST ELSE STOP 'NO CUST' DELETE CUSTOMER, C.ID The following program segment is taken from “Appendix A, Sample Program” of Developing UniBasic Applications. The DELETE command deletes the record in the ORDERS file after the corresponding attribute is deleted from the CLIENTS file. Both steps are necessary to remove the order record itself, and to remove the reference to the order in the client record (the attribute in the CLIENTS file). DELETE_RECORD: * (Assuming the order #'s are on line 12) READVU ORDER_LINE FROM CLIENT_FILE,CLIENT_NUMBER,12 THEN LOCATE ORDER_NUMBER IN ORDER_LINE SETTING POSITION THEN DEL ORDER_LINE END WRITEV ORDER_LINE ON CLIENT_FILE, CLIENT_NUMBER, 12 END * DELETE ORDERS_FILE, ORDER_NUMBER RELEASE CLIENT_FILE,CLIENT_NUMBER RETURN Related Commands UniBasic DEL, DELETE, DELETEU

DELETE Syntax DELETE(dyn.array, attrib.expr[,val.expr [,subval.expr]]) Description The UniBasic DELETE function deletes an attribute, value, or subvalue from a dynamic array. The corresponding delimiter is also removed. The DELETE function and the DEL command perform the same action. Parameters The following table describes each parameter of the syntax. Parameter Description dyn.array.var Specifies the dynamic array from which to delete. attrib.expr Specifies which attribute of the dynamic array to delete. If val.expr is omitted, DELETE deletes the entire attribute, including all values and subvalues. ,val.expr Specifies which value of the dynamic array attribute to delete. If subval.expr is omitted, DELETE deletes the entire value, including all subvalues. ,subval.expr Specifies which subvalue of the dynamic array attribute value to delete. DELETE Parameters Examples In this first example, the program segment deletes the first attribute (125) and the attribute mark from the dynamic array ARRAY: ARRAY = 125:@AM:1:@VM:62:@VM:3:@AM:132:@VM:4:@VM:5:@SM:1 ARRAY=DELETE(ARRAY,1,0,0) DELETE 1-204

Examples<br />

The following program statement eliminates the record with the ID of PEANUT from<br />

the default file:<br />

DELETE "PEANUT"<br />

The following program segment deletes the record whose ID is specified by the<br />

variable DEL_ID from the file previously opened to the PARTS variable:<br />

DEL_ID = "HOOK"<br />

DELETE PARTS, DEL_ID<br />

The following statement is invalid because the file variable is specified incorrectly in<br />

the DELETE statement:<br />

1-203 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />

OPEN 'CUSTOMER' TO CUST ELSE STOP 'NO CUST'<br />

DELETE CUSTOMER, C.ID<br />

The following program segment is taken from “Appendix A, Sample Program” of<br />

Developing <strong>UniBasic</strong> Applications. The DELETE command deletes the record in the<br />

ORDERS file after the corresponding attribute is deleted from the CLIENTS file.<br />

Both steps are necessary to remove the order record itself, and to remove the<br />

reference to the order in the client record (the attribute in the CLIENTS file).<br />

DELETE_RECORD:<br />

* (Assuming the order #'s are on line 12)<br />

READVU ORDER_LINE FROM CLIENT_FILE,CLIENT_NUMBER,12 THEN<br />

LOCATE ORDER_NUMBER IN ORDER_LINE SETTING POSITION THEN<br />

DEL ORDER_LINE<br />

END<br />

WRITEV ORDER_LINE ON CLIENT_FILE, CLIENT_NUMBER, 12<br />

END<br />

*<br />

DELETE ORDERS_FILE, ORDER_NUMBER<br />

RELEASE CLIENT_FILE,CLIENT_NUMBER<br />

RETURN<br />

Related <strong>Commands</strong><br />

<strong>UniBasic</strong><br />

DEL, DELETE, DELETEU

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!