Enscribe Programmer's Guide
END
ELSE ! Some other error
BEGIN
status := ABORTTRANSACTION; !abort this transaction
RETURN -1;
END;
END ! Execute one dequeue operation
UNTIL 0;
END;
Example 4: Using KEYPOSITION for Generic Positioning
In this example, the queue file has a key-length of 10 bytes, so the user-key length is 2 bytes. Note
that you must open the queue file and specify a key range in key before calling GET^GENERIC.
INT QF^Num; ! Queue File number
STRING .QF^Name[0:33] := "$pub1.spl1111.qfile"; ! File name
LITERAL QF^NameLength = 19; ! Length in bytes of file name
INT QF^NameLen;
LITERAL Key^Length = 10; ! Key length (must be >= 8)
INT Key^Len;
STRING .Key[0:Key^Length - 9]; ! Application key
LITERAL Rec^Len = 100; ! Record length
INT Byte^Count; ! Number of bytes read/written
INT Length^Word; ! length-word parameter to
! KEYPOSITION
INT Error; ! Returned error code
INT Error^Item; ! Returned item-in-error
FIXED Trans^Tag; ! Transaction identifier
STRING .Buffer[0:Rec^Len - 1]; ! Record buffer
STRING .Data[0:Rec^Len - Key^Length - 1];
! Data being enqueued/dequeued
!
?SOURCE $SYSTEM.SYSTEM.EXTDECS0 (FILE_OPEN_,
? READ,
? WRITE,
? KEYPOSITION
? FILE_CREATE_,
? FILE_CREATELIST_
? ABORTTRANSACTION,
? BEGINTRANSACTION,
? ENDTRANSACTION
? FILEINFO,
? READUPDATELOCK,
? MYTERM,
? STOP,
? DEBUG
? OPEN,
? CLOSE);
!
! Dequeue a record within a generic key range
!
INT PROC GET^GENERIC(Error); ! Returns # bytes in queue
! entry, returned
INT .Error; ! error code, zero, or
BEGIN ! -1 if an error occurred.
Error := 0; ! Clear error code
Length^Word := 2; ! Select key-length = 2, and
Length^Word.<0:7> := 2; ! compare-length = 2.
CALL KEYPOSITION(
QF^Num, ! filenum
Key, ! key-value
0, ! key-specifier (must be zero)
Length^Word, ! length-word
120 Queue Files