UniBasic Commands Reference - Rocket Software
UniBasic Commands Reference - Rocket Software
UniBasic Commands Reference - Rocket Software
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRTITL.fm<br />
March 5, 2010 4:03 pm<br />
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />
Beta Beta Beta Beta<br />
UniData<br />
<strong>UniBasic</strong> <strong>Commands</strong><br />
<strong>Reference</strong><br />
UDT-720-BASR-1
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRTITL.fm<br />
March 5, 2010 4:03 pm<br />
ii <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />
Notices<br />
Edition<br />
Publication date: July 2008<br />
Book number: UDT-720-BASR-1<br />
Product version: UniData 7.2<br />
Copyright<br />
© <strong>Rocket</strong> <strong>Software</strong>, Inc. 1988-2008. All Rights Reserved.<br />
Trademarks<br />
The following trademarks appear in this publication:<br />
Trademark Trademark Owner<br />
<strong>Rocket</strong> <strong>Software</strong><br />
<strong>Rocket</strong> <strong>Software</strong>, Inc.<br />
Dynamic Connect® <strong>Rocket</strong> <strong>Software</strong>, Inc.<br />
RedBack®<br />
SystemBuilder<br />
UniData®<br />
UniVerse<br />
U2<br />
U2.NET<br />
U2 Web Development Environment<br />
<strong>Rocket</strong> <strong>Software</strong>, Inc.<br />
<strong>Rocket</strong> <strong>Software</strong>, Inc.<br />
<strong>Rocket</strong> <strong>Software</strong>, Inc.<br />
<strong>Rocket</strong> <strong>Software</strong>, Inc.<br />
<strong>Rocket</strong> <strong>Software</strong>, Inc.<br />
<strong>Rocket</strong> <strong>Software</strong>, Inc.<br />
<strong>Rocket</strong> <strong>Software</strong>, Inc.<br />
wIntegrate® <strong>Rocket</strong> <strong>Software</strong>, Inc.<br />
Microsoft® .NET<br />
Microsoft® Office Excel®, Outlook®, Word<br />
Windows®<br />
Windows® 7<br />
Windows Vista®<br />
Java and all Java-based trademarks and logos<br />
UNIX®<br />
Microsoft Corporation<br />
Microsoft Corporation<br />
Microsoft Corporation<br />
Microsoft Corporation<br />
Microsoft Corporation<br />
Sun Microsystems, Inc.<br />
X/Open Company Limited
The above trademarks are property of the specified companies in the United States,<br />
other countries, or both. All other products or services mentioned in this document<br />
may be covered by the trademarks, service marks, or product names as designated<br />
by the companies who own or market them.<br />
License agreement<br />
This software and the associated documentation are proprietary and confidential to<br />
<strong>Rocket</strong> <strong>Software</strong>, Inc., are furnished under license, and may be used and copied only<br />
in accordance with the terms of such license and with the inclusion of the copyright<br />
notice. This software and any copies thereof may not be provided or otherwise made<br />
available to any other person. No title to or ownership of the software and associated<br />
documentation is hereby transferred. Any unauthorized use or reproduction of this<br />
software or documentation may be subject to civil or criminal liability. The information<br />
in the software and documentation is subject to change and should not be construed<br />
as a commitment by <strong>Rocket</strong> <strong>Software</strong>, Inc.<br />
Restricted rights notice for license to the U.S. Government: Use, reproduction, or<br />
disclosure is subject to restrictions as stated in the “Rights in Technical Data-<br />
General” clause (alternate III), in FAR section 52.222-14. All title and ownership in<br />
this computer software remain with <strong>Rocket</strong> <strong>Software</strong>, Inc.<br />
Note<br />
This product may contain encryption technology. Many countries prohibit or restrict<br />
the use, import, or export of encryption technologies, and current use, import, and<br />
export regulations should be followed when exporting this product.<br />
Please be aware: Any images or indications reflecting ownership or branding of the<br />
product(s) documented herein may or may not reflect the current legal ownership of<br />
the intellectual property rights associated with such product(s). All right and title to<br />
the product(s) documented herein belong solely to <strong>Rocket</strong> <strong>Software</strong>, Inc. and its<br />
subsidiaries, notwithstanding any notices (including screen captures) or any other<br />
indications to the contrary.<br />
Contact information<br />
<strong>Rocket</strong> <strong>Software</strong><br />
275 Grove Street Suite 3-410<br />
Newton, MA 02466-2272<br />
USA<br />
Tel: (617) 614-4321 Fax: (617) 630-7100<br />
Web Site: www.rocketsoftware.com<br />
<strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong> iii
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />
Table of Contents<br />
Elements of Syntax Statements . . . . . . . . . . . . . . . 1-23<br />
! . . . . . . . . . . . . . . . . . . . . . . . . 1-24<br />
# . . . . . . . . . . . . . . . . . . . . . . . . 1-25<br />
#< . . . . . . . . . . . . . . . . . . . . . . . . 1-26<br />
#> . . . . . . . . . . . . . . . . . . . . . . . . 1-27<br />
$BASICTYPE . . . . . . . . . . . . . . . . . . . . 1-28<br />
$DEFINE . . . . . . . . . . . . . . . . . . . . . 1-30<br />
$IFDEF . . . . . . . . . . . . . . . . . . . . . . 1-31<br />
$IFNDEF . . . . . . . . . . . . . . . . . . . . . 1-33<br />
$INCLUDE . . . . . . . . . . . . . . . . . . . . . 1-35<br />
$INSERT. . . . . . . . . . . . . . . . . . . . . . 1-37<br />
$UNDEFINE . . . . . . . . . . . . . . . . . . . . 1-38<br />
& . . . . . . . . . . . . . . . . . . . . . . . . 1-39<br />
* . . . . . . . . . . . . . . . . . . . . . . . . 1-40<br />
** . . . . . . . . . . . . . . . . . . . . . . . . 1-41<br />
*= . . . . . . . . . . . . . . . . . . . . . . . . 1-42<br />
+ . . . . . . . . . . . . . . . . . . . . . . . . 1-43<br />
+= . . . . . . . . . . . . . . . . . . . . . . . . 1-44<br />
- . . . . . . . . . . . . . . . . . . . . . . . . 1-45<br />
-= . . . . . . . . . . . . . . . . . . . . . . . . 1-46<br />
/ . . . . . . . . . . . . . . . . . . . . . . . . 1-47<br />
/= . . . . . . . . . . . . . . . . . . . . . . . . 1-48<br />
: . . . . . . . . . . . . . . . . . . . . . . . . 1-49<br />
^ . . . . . . . . . . . . . . . . . . . . . . . . 1-50<br />
:= . . . . . . . . . . . . . . . . . . . . . . . . 1-51<br />
< . . . . . . . . . . . . . . . . . . . . . . . . 1-52<br />
. . . . . . . . . . . . . . . . . . . . . . . . 1-56<br />
=< . . . . . . . . . . . . . . . . . . . . . . . . 1-57<br />
>< . . . . . . . . . . . . . . . . . . . . . . . . 1-58<br />
\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRTOC.fm (bookTOC.template)<br />
Table of<br />
Contents
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRTOC.fm<br />
(bookTOC.template)<br />
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />
v <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
> . . . . . . . . . . . . . . . . . . . . . . . . 1-59<br />
>= . . . . . . . . . . . . . . . . . . . . . . . 1-60<br />
@ . . . . . . . . . . . . . . . . . . . . . . . . 1-61<br />
[] . . . . . . . . . . . . . . . . . . . . . . . . 1-67<br />
{}. . . . . . . . . . . . . . . . . . . . . . . . 1-69<br />
ABORT . . . . . . . . . . . . . . . . . . . . . . 1-71<br />
ABS . . . . . . . . . . . . . . . . . . . . . . . 1-74<br />
acceptConnection . . . . . . . . . . . . . . . . . . . 1-75<br />
ACOS . . . . . . . . . . . . . . . . . . . . . . 1-77<br />
addAuthenticationRule . . . . . . . . . . . . . . . . . 1-81<br />
addCertificate . . . . . . . . . . . . . . . . . . . . 1-83<br />
addRequestParameter . . . . . . . . . . . . . . . . . 1-85<br />
ALPHA . . . . . . . . . . . . . . . . . . . . . . 1-87<br />
amInitialize. . . . . . . . . . . . . . . . . . . . . 1-88<br />
amReceiveMsg . . . . . . . . . . . . . . . . . . . 1-90<br />
amReceiveRequest . . . . . . . . . . . . . . . . . . 1-92<br />
amSendMsg . . . . . . . . . . . . . . . . . . . . 1-94<br />
amSendRequest . . . . . . . . . . . . . . . . . . . 1-96<br />
amSendResponse . . . . . . . . . . . . . . . . . . . 1-98<br />
amTerminate . . . . . . . . . . . . . . . . . . . . 1-100<br />
analyzeCertificate. . . . . . . . . . . . . . . . . . . 1-102<br />
AND . . . . . . . . . . . . . . . . . . . . . . . 1-104<br />
ASCII . . . . . . . . . . . . . . . . . . . . . . 1-105<br />
ASIN . . . . . . . . . . . . . . . . . . . . . . 1-106<br />
ATAN . . . . . . . . . . . . . . . . . . . . . . 1-109<br />
BITAND . . . . . . . . . . . . . . . . . . . . . 1-107<br />
BITNOT . . . . . . . . . . . . . . . . . . . . . 1-108<br />
BITOR . . . . . . . . . . . . . . . . . . . . . . 1-109<br />
BITXOR . . . . . . . . . . . . . . . . . . . . . 1-110<br />
BPIOCP. . . . . . . . . . . . . . . . . . . . . . 1-111<br />
BPIOCPN . . . . . . . . . . . . . . . . . . . . . 1-113<br />
BREAK . . . . . . . . . . . . . . . . . . . . . . 1-115<br />
BYTELEN . . . . . . . . . . . . . . . . . . . . . 1-117<br />
CALCULATE . . . . . . . . . . . . . . . . . . . . 1-118<br />
CALL . . . . . . . . . . . . . . . . . . . . . . 1-120<br />
CALLC . . . . . . . . . . . . . . . . . . . . . . 1-123<br />
CASE . . . . . . . . . . . . . . . . . . . . . . 1-125<br />
CAT . . . . . . . . . . . . . . . . . . . . . . . 1-128<br />
CATS . . . . . . . . . . . . . . . . . . . . . . 1-130<br />
CHAIN . . . . . . . . . . . . . . . . . . . . . . 1-131<br />
CHANGE . . . . . . . . . . . . . . . . . . . . . 1-133<br />
CHAR . . . . . . . . . . . . . . . . . . . . . . 1-135
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRTOC.fm<br />
(bookTOC.template)<br />
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />
vi <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
CHARLEN. . . . . . . . . . . . . . . . . . . . . 1-137<br />
CHARS . . . . . . . . . . . . . . . . . . . . . . 1-138<br />
CHECKSUM . . . . . . . . . . . . . . . . . . . . 1-139<br />
CLEAR . . . . . . . . . . . . . . . . . . . . . . 1-140<br />
CLEARCOMMON . . . . . . . . . . . . . . . . . . 1-142<br />
CLEARDATA . . . . . . . . . . . . . . . . . . . . 1-144<br />
CLEARFILE . . . . . . . . . . . . . . . . . . . . 1-145<br />
CLEARINPUT . . . . . . . . . . . . . . . . . . . 1-147<br />
CLEARSQL . . . . . . . . . . . . . . . . . . . . 1-150<br />
CLOSE . . . . . . . . . . . . . . . . . . . . . . 1-151<br />
CLOSESEQ . . . . . . . . . . . . . . . . . . . . 1-153<br />
closeSocket. . . . . . . . . . . . . . . . . . . . . 1-155<br />
CloseXMLData . . . . . . . . . . . . . . . . . . . 1-156<br />
COL1 . . . . . . . . . . . . . . . . . . . . . . 1-157<br />
COL2 . . . . . . . . . . . . . . . . . . . . . . 1-158<br />
COMMON . . . . . . . . . . . . . . . . . . . . . 1-159<br />
CONTINUE . . . . . . . . . . . . . . . . . . . . 1-164<br />
CONVERT . . . . . . . . . . . . . . . . . . . . . 1-166<br />
CONVERT . . . . . . . . . . . . . . . . . . . . . 1-168<br />
COS . . . . . . . . . . . . . . . . . . . . . . . 1-170<br />
COUNT. . . . . . . . . . . . . . . . . . . . . . 1-171<br />
createCertificate . . . . . . . . . . . . . . . . . . . 1-175<br />
createCertRequest . . . . . . . . . . . . . . . . . . 1-177<br />
createRequest. . . . . . . . . . . . . . . . . . . . 1-180<br />
createSecureRequest . . . . . . . . . . . . . . . . . . 1-183<br />
createSecurityContext . . . . . . . . . . . . . . . . . 1-186<br />
DATA . . . . . . . . . . . . . . . . . . . . . . 1-187<br />
DATE . . . . . . . . . . . . . . . . . . . . . . 1-188<br />
DBTOXML . . . . . . . . . . . . . . . . . . . . 1-189<br />
DCOUNT . . . . . . . . . . . . . . . . . . . . . 1-191<br />
DEACTIVATEKEY . . . . . . . . . . . . . . . . . . 1-193<br />
DEBUG. . . . . . . . . . . . . . . . . . . . . . 1-196<br />
DEFFUN . . . . . . . . . . . . . . . . . . . . . 1-197<br />
DEL . . . . . . . . . . . . . . . . . . . . . . . 1-200<br />
DELETE . . . . . . . . . . . . . . . . . . . . . 1-202<br />
DELETE . . . . . . . . . . . . . . . . . . . . . 1-204<br />
DELETELIST . . . . . . . . . . . . . . . . . . . . 1-206<br />
DELETEU . . . . . . . . . . . . . . . . . . . . . 1-208<br />
DIM . . . . . . . . . . . . . . . . . . . . . . . 1-210<br />
DIGEST. . . . . . . . . . . . . . . . . . . . . . 1-213<br />
DIR . . . . . . . . . . . . . . . . . . . . . . . 1-215<br />
DISPLAY . . . . . . . . . . . . . . . . . . . . . 1-218
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRTOC.fm<br />
(bookTOC.template)<br />
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />
vii <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
DISPLAYWIDTH . . . . . . . . . . . . . . . . . . 1-219<br />
DOWNCASE . . . . . . . . . . . . . . . . . . . . 1-220<br />
DQUOTE . . . . . . . . . . . . . . . . . . . . . 1-221<br />
DROUND . . . . . . . . . . . . . . . . . . . . . 1-222<br />
EBCDIC . . . . . . . . . . . . . . . . . . . . . 1-217<br />
ECHO . . . . . . . . . . . . . . . . . . . . . . 1-218<br />
EDADRV_Cleanup . . . . . . . . . . . . . . . . . . 1-219<br />
EDADRV_CloseStmt . . . . . . . . . . . . . . . . . 1-220<br />
EDADRV_Connect . . . . . . . . . . . . . . . . . . 1-222<br />
EDADRV_Disconnect . . . . . . . . . . . . . . . . . 1-224<br />
EDADRV_DropStmt. . . . . . . . . . . . . . . . . . 1-225<br />
EDADRV_EndTransaction . . . . . . . . . . . . . . . . 1-227<br />
EDADRV_ExecuteStmt . . . . . . . . . . . . . . . . . 1-229<br />
EDADRV_FetchStmt . . . . . . . . . . . . . . . . . 1-231<br />
EDADRV_FreeResult . . . . . . . . . . . . . . . . . 1-233<br />
EDADRV_GetDBInfo . . . . . . . . . . . . . . . . . 1-234<br />
EDADRV_GetErrmsg . . . . . . . . . . . . . . . . . 1-238<br />
EDADRV_GetSpecialInfo . . . . . . . . . . . . . . . . 1-239<br />
EDADRV_LoadSymbols . . . . . . . . . . . . . . . . 1-242<br />
EDADRV_Perform . . . . . . . . . . . . . . . . . . 1-245<br />
EDADRV_PrepareStmt . . . . . . . . . . . . . . . . . 1-247<br />
ENABLEDEC. . . . . . . . . . . . . . . . . . . . 1-249<br />
ENCODE . . . . . . . . . . . . . . . . . . . . . 1-251<br />
ENCRYPT . . . . . . . . . . . . . . . . . . . . . 1-253<br />
END . . . . . . . . . . . . . . . . . . . . . . . 1-256<br />
ENTER . . . . . . . . . . . . . . . . . . . . . . 1-257<br />
EQ . . . . . . . . . . . . . . . . . . . . . . . 1-259<br />
EQS . . . . . . . . . . . . . . . . . . . . . . . 1-261<br />
EQU . . . . . . . . . . . . . . . . . . . . . . . 1-262<br />
EREPLACE . . . . . . . . . . . . . . . . . . . . 1-265<br />
EXECUTE . . . . . . . . . . . . . . . . . . . . . 1-266<br />
EXECUTESQL . . . . . . . . . . . . . . . . . . . 1-271<br />
EXIT. . . . . . . . . . . . . . . . . . . . . . . 1-275<br />
EXP . . . . . . . . . . . . . . . . . . . . . . . 1-276<br />
EXTRACT . . . . . . . . . . . . . . . . . . . . . 1-277<br />
FIELD . . . . . . . . . . . . . . . . . . . . . . 1-247<br />
FIELDSTORE. . . . . . . . . . . . . . . . . . . . 1-249<br />
FILEINFO . . . . . . . . . . . . . . . . . . . . . 1-252<br />
FILELOCK . . . . . . . . . . . . . . . . . . . . 1-256<br />
FILEUNLOCK . . . . . . . . . . . . . . . . . . . 1-258<br />
FIND . . . . . . . . . . . . . . . . . . . . . . 1-260<br />
FINDSTR . . . . . . . . . . . . . . . . . . . . . 1-263
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRTOC.fm<br />
(bookTOC.template)<br />
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />
viii <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
FLUSH . . . . . . . . . . . . . . . . . . . . . . 1-265<br />
FMT . . . . . . . . . . . . . . . . . . . . . . . 1-266<br />
FOOTING . . . . . . . . . . . . . . . . . . . . . 1-270<br />
FORMLIST . . . . . . . . . . . . . . . . . . . . 1-273<br />
FOR/NEXT . . . . . . . . . . . . . . . . . . . . 1-275<br />
FUNCTION . . . . . . . . . . . . . . . . . . . . 1-278<br />
GARBAGECOLLECT . . . . . . . . . . . . . . . . . 1-281<br />
GE . . . . . . . . . . . . . . . . . . . . . . . 1-282<br />
generateKey . . . . . . . . . . . . . . . . . . . . 1-284<br />
GES . . . . . . . . . . . . . . . . . . . . . . . 1-287<br />
GET . . . . . . . . . . . . . . . . . . . . . . . 1-288<br />
getCipherSuite. . . . . . . . . . . . . . . . . . . . 1-291<br />
GETENV . . . . . . . . . . . . . . . . . . . . . 1-293<br />
getHTTPDefault . . . . . . . . . . . . . . . . . . . 1-294<br />
GETLIST . . . . . . . . . . . . . . . . . . . . . 1-296<br />
GETPTR . . . . . . . . . . . . . . . . . . . . . 1-299<br />
GETPU . . . . . . . . . . . . . . . . . . . . . . 1-301<br />
GETQUEUE . . . . . . . . . . . . . . . . . . . . 1-302<br />
GETREADU . . . . . . . . . . . . . . . . . . . . 1-304<br />
getResponseHeader . . . . . . . . . . . . . . . . . . 1-306<br />
getSocketInformation . . . . . . . . . . . . . . . . . 1-307<br />
getSocketOptions . . . . . . . . . . . . . . . . . . . 1-309<br />
GETUSERGROUP . . . . . . . . . . . . . . . . . . 1-312<br />
GETUSERID . . . . . . . . . . . . . . . . . . . . 1-313<br />
GETUSERNAME . . . . . . . . . . . . . . . . . . 1-314<br />
GOSUB . . . . . . . . . . . . . . . . . . . . . . 1-315<br />
GOTO . . . . . . . . . . . . . . . . . . . . . . 1-317<br />
GROUP . . . . . . . . . . . . . . . . . . . . . . 1-319<br />
GROUPSTORE . . . . . . . . . . . . . . . . . . . 1-321<br />
GT . . . . . . . . . . . . . . . . . . . . . . . 1-325<br />
GTS . . . . . . . . . . . . . . . . . . . . . . . 1-327<br />
HASH . . . . . . . . . . . . . . . . . . . . . . 1-327<br />
HEADING . . . . . . . . . . . . . . . . . . . . . 1-328<br />
HUSH . . . . . . . . . . . . . . . . . . . . . . 1-331<br />
ICONV . . . . . . . . . . . . . . . . . . . . . . 1-333<br />
ICONV Date (D) . . . . . . . . . . . . . . . . . . . 1-336<br />
ICONV Group (G) . . . . . . . . . . . . . . . . . . 1-340<br />
ICONV Length (L) . . . . . . . . . . . . . . . . . . 1-342<br />
ICONV Masked Character (MC) . . . . . . . . . . . . . . 1-344<br />
ICONV Masked Decimal (MD) . . . . . . . . . . . . . . 1-346<br />
ICONV Left Justify (ML) . . . . . . . . . . . . . . . . 1-348<br />
ICONV Packed Decimal (MP). . . . . . . . . . . . . . . 1-350
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRTOC.fm<br />
(bookTOC.template)<br />
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />
ix <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ICONV Packed Decimal (MP1) . . . . . . . . . . . . . . 1-351<br />
ICONV Right Justify (MR). . . . . . . . . . . . . . . . 1-352<br />
ICONV Time (MT) . . . . . . . . . . . . . . . . . . 1-354<br />
ICONV Hex (MX | HEX), Octal (MO), Binary (MB) . . . . . . . 1-356<br />
ICONV Pattern Match (P) . . . . . . . . . . . . . . . . 1-359<br />
ICONV Range (R) . . . . . . . . . . . . . . . . . . 1-360<br />
ICONV SOUNDEX (S) . . . . . . . . . . . . . . . . . 1-362<br />
ICONV Text Extraction (T) . . . . . . . . . . . . . . . 1-363<br />
ICONV File Translation (Tfile) . . . . . . . . . . . . . . 1-365<br />
ICONVS . . . . . . . . . . . . . . . . . . . . . 1-366<br />
IF/THEN/ELSE . . . . . . . . . . . . . . . . . . . 1-368<br />
IN. . . . . . . . . . . . . . . . . . . . . . . . 1-370<br />
INDEX . . . . . . . . . . . . . . . . . . . . . . 1-371<br />
INDICES . . . . . . . . . . . . . . . . . . . . . 1-373<br />
initSecureServerSocket function . . . . . . . . . . . . . . 1-375<br />
initServerSocket . . . . . . . . . . . . . . . . . . . 1-377<br />
INMAT . . . . . . . . . . . . . . . . . . . . . . 1-379<br />
INPUT . . . . . . . . . . . . . . . . . . . . . . 1-382<br />
INPUT @ . . . . . . . . . . . . . . . . . . . . . 1-386<br />
INPUTCLEAR . . . . . . . . . . . . . . . . . . . 1-390<br />
INPUTERR . . . . . . . . . . . . . . . . . . . . 1-391<br />
INPUTIF . . . . . . . . . . . . . . . . . . . . . 1-393<br />
INPUTNULL . . . . . . . . . . . . . . . . . . . . 1-394<br />
INPUTTRAP . . . . . . . . . . . . . . . . . . . . 1-395<br />
INS . . . . . . . . . . . . . . . . . . . . . . . 1-397<br />
INSERT. . . . . . . . . . . . . . . . . . . . . . 1-399<br />
INT . . . . . . . . . . . . . . . . . . . . . . . 1-401<br />
ISMB . . . . . . . . . . . . . . . . . . . . . . 1-402<br />
ISNV . . . . . . . . . . . . . . . . . . . . . . 1-403<br />
ISNVS . . . . . . . . . . . . . . . . . . . . . . 1-405<br />
ITYPE . . . . . . . . . . . . . . . . . . . . . . 1-407<br />
LE . . . . . . . . . . . . . . . . . . . . . . . 1-408<br />
LEN . . . . . . . . . . . . . . . . . . . . . . . 1-410<br />
LENS . . . . . . . . . . . . . . . . . . . . . . 1-412<br />
LES . . . . . . . . . . . . . . . . . . . . . . . 1-413<br />
LISTUSER . . . . . . . . . . . . . . . . . . . . . 1-414<br />
LN . . . . . . . . . . . . . . . . . . . . . . . 1-416<br />
loadSecurityContext . . . . . . . . . . . . . . . . . . 1-417<br />
LOCATE . . . . . . . . . . . . . . . . . . . . . 1-419<br />
LOCK . . . . . . . . . . . . . . . . . . . . . . 1-425<br />
LOOP/REPEAT . . . . . . . . . . . . . . . . . . . 1-428<br />
LOWER. . . . . . . . . . . . . . . . . . . . . . 1-432
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRTOC.fm<br />
(bookTOC.template)<br />
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />
x <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
LT . . . . . . . . . . . . . . . . . . . . . . . 1-433<br />
LTS . . . . . . . . . . . . . . . . . . . . . . . 1-435<br />
MAT . . . . . . . . . . . . . . . . . . . . . . . 1-436<br />
MATBUILD . . . . . . . . . . . . . . . . . . . . 1-439<br />
MATCH. . . . . . . . . . . . . . . . . . . . . . 1-442<br />
MATCHFIELD . . . . . . . . . . . . . . . . . . . 1-444<br />
MATPARSE . . . . . . . . . . . . . . . . . . . . 1-446<br />
MATREAD . . . . . . . . . . . . . . . . . . . . 1-449<br />
MATREADL . . . . . . . . . . . . . . . . . . . . 1-452<br />
MATREADU . . . . . . . . . . . . . . . . . . . . 1-455<br />
MATWRITE . . . . . . . . . . . . . . . . . . . . 1-459<br />
MATWRITEU. . . . . . . . . . . . . . . . . . . . 1-462<br />
MAXIMUM . . . . . . . . . . . . . . . . . . . . 1-464<br />
MBLEN. . . . . . . . . . . . . . . . . . . . . . 1-465<br />
MDPERFORM . . . . . . . . . . . . . . . . . . . 1-466<br />
MINIMUM. . . . . . . . . . . . . . . . . . . . . 1-470<br />
MOD . . . . . . . . . . . . . . . . . . . . . . 1-471<br />
NE . . . . . . . . . . . . . . . . . . . . . . . 1-474<br />
NEG . . . . . . . . . . . . . . . . . . . . . . . 1-476<br />
NES . . . . . . . . . . . . . . . . . . . . . . . 1-477<br />
NFAUSER . . . . . . . . . . . . . . . . . . . . . 1-478<br />
NOCONVERT . . . . . . . . . . . . . . . . . . . 1-479<br />
NOT . . . . . . . . . . . . . . . . . . . . . . . 1-481<br />
NOTS . . . . . . . . . . . . . . . . . . . . . . 1-482<br />
NULL . . . . . . . . . . . . . . . . . . . . . . 1-483<br />
NUM . . . . . . . . . . . . . . . . . . . . . . 1-484<br />
NUMS . . . . . . . . . . . . . . . . . . . . . . 1-486<br />
OCONV. . . . . . . . . . . . . . . . . . . . . . 1-487<br />
OCONV Date (D) . . . . . . . . . . . . . . . . . . 1-489<br />
OCONV Group (G) . . . . . . . . . . . . . . . . . . 1-494<br />
OCONV Length (L) . . . . . . . . . . . . . . . . . . 1-496<br />
OCONV Masked Character (MC) . . . . . . . . . . . . . 1-498<br />
OCONV Masked Decimal (MD) . . . . . . . . . . . . . . 1-501<br />
OCONV Left Justify (ML) . . . . . . . . . . . . . . . . 1-504<br />
OCONV Packed Decimal (MP) . . . . . . . . . . . . . . 1-507<br />
OCONV Packed Decimal (MP1) . . . . . . . . . . . . . . 1-508<br />
OCONV Right Justify (MR) . . . . . . . . . . . . . . . 1-509<br />
OCONV Time (MT) . . . . . . . . . . . . . . . . . . 1-512<br />
OCONV Hex (MX | HEX), Octal (MO), Binary (MB) . . . . . . . 1-514<br />
OCONV Pattern Match (P) . . . . . . . . . . . . . . . . 1-517<br />
OCONV Range (R) . . . . . . . . . . . . . . . . . . 1-519<br />
OCONV SOUNDEX (S) . . . . . . . . . . . . . . . . 1-521
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRTOC.fm<br />
(bookTOC.template)<br />
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />
xi <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
OCONV Text Extraction (T) . . . . . . . . . . . . . . . 1-523<br />
OCONV File Translation (Tfile) . . . . . . . . . . . . . . 1-525<br />
OCONVS . . . . . . . . . . . . . . . . . . . . . 1-527<br />
ON/GOSUB . . . . . . . . . . . . . . . . . . . . 1-529<br />
ON/GOTO . . . . . . . . . . . . . . . . . . . . . 1-532<br />
OPEN . . . . . . . . . . . . . . . . . . . . . . 1-534<br />
openSecureSocket function. . . . . . . . . . . . . . . . 1-537<br />
OPENSEQ . . . . . . . . . . . . . . . . . . . . . 1-539<br />
openSocket . . . . . . . . . . . . . . . . . . . . . 1-542<br />
OpenXMLData . . . . . . . . . . . . . . . . . . . 1-544<br />
OR . . . . . . . . . . . . . . . . . . . . . . . 1-546<br />
OSBREAD . . . . . . . . . . . . . . . . . . . . . 1-547<br />
OSBWRITE . . . . . . . . . . . . . . . . . . . . 1-550<br />
OSCLOSE . . . . . . . . . . . . . . . . . . . . . 1-554<br />
OSDELETE . . . . . . . . . . . . . . . . . . . . 1-556<br />
OSOPEN . . . . . . . . . . . . . . . . . . . . . 1-558<br />
OSREAD . . . . . . . . . . . . . . . . . . . . . 1-561<br />
OSWRITE . . . . . . . . . . . . . . . . . . . . . 1-563<br />
PAGE . . . . . . . . . . . . . . . . . . . . . . 1-563<br />
PAUSE . . . . . . . . . . . . . . . . . . . . . . 1-565<br />
PCPERFORM . . . . . . . . . . . . . . . . . . . . 1-567<br />
PERFORM . . . . . . . . . . . . . . . . . . . . . 1-569<br />
PRECISION . . . . . . . . . . . . . . . . . . . . 1-570<br />
PrepareXML . . . . . . . . . . . . . . . . . . . . 1-572<br />
PRINT . . . . . . . . . . . . . . . . . . . . . . 1-574<br />
PRINTER . . . . . . . . . . . . . . . . . . . . . 1-577<br />
PRINTER CLOSE . . . . . . . . . . . . . . . . . . 1-578<br />
PRINTERR . . . . . . . . . . . . . . . . . . . . 1-579<br />
PROCREAD . . . . . . . . . . . . . . . . . . . . 1-583<br />
PROCWRITE . . . . . . . . . . . . . . . . . . . . 1-587<br />
PROGRAM . . . . . . . . . . . . . . . . . . . . 1-588<br />
PROMPT . . . . . . . . . . . . . . . . . . . . . 1-589<br />
protocolLogging . . . . . . . . . . . . . . . . . . . 1-591<br />
PWR . . . . . . . . . . . . . . . . . . . . . . . 1-593<br />
QUOTE . . . . . . . . . . . . . . . . . . . . . . 1-593<br />
RAISE . . . . . . . . . . . . . . . . . . . . . . 1-595<br />
READ . . . . . . . . . . . . . . . . . . . . . . 1-596<br />
READBCK. . . . . . . . . . . . . . . . . . . . . 1-599<br />
READBCKL . . . . . . . . . . . . . . . . . . . . 1-602<br />
READBCKU . . . . . . . . . . . . . . . . . . . . 1-606<br />
READFWD . . . . . . . . . . . . . . . . . . . . 1-610<br />
READFWDL . . . . . . . . . . . . . . . . . . . . 1-613
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRTOC.fm<br />
(bookTOC.template)<br />
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />
xii <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
READFWDU . . . . . . . . . . . . . . . . . . . . 1-617<br />
READL . . . . . . . . . . . . . . . . . . . . . . 1-621<br />
READLIST . . . . . . . . . . . . . . . . . . . . 1-625<br />
READNEXT . . . . . . . . . . . . . . . . . . . . 1-628<br />
READNEXTTUPLE. . . . . . . . . . . . . . . . . . 1-632<br />
READSELECT . . . . . . . . . . . . . . . . . . . 1-635<br />
READSEQ . . . . . . . . . . . . . . . . . . . . . 1-636<br />
readSocket . . . . . . . . . . . . . . . . . . . . . 1-638<br />
READT . . . . . . . . . . . . . . . . . . . . . . 1-640<br />
READU. . . . . . . . . . . . . . . . . . . . . . 1-643<br />
READV. . . . . . . . . . . . . . . . . . . . . . 1-647<br />
READVL . . . . . . . . . . . . . . . . . . . . . 1-650<br />
READVU . . . . . . . . . . . . . . . . . . . . . 1-653<br />
READXBCK . . . . . . . . . . . . . . . . . . . . 1-656<br />
READXFWD . . . . . . . . . . . . . . . . . . . . 1-658<br />
ReadXMLData . . . . . . . . . . . . . . . . . . . 1-660<br />
RECORDLOCKED . . . . . . . . . . . . . . . . . . 1-662<br />
RECORDLOCKL . . . . . . . . . . . . . . . . . . 1-665<br />
RECORDLOCKU . . . . . . . . . . . . . . . . . . 1-668<br />
RELEASE . . . . . . . . . . . . . . . . . . . . . 1-670<br />
ReleaseXML . . . . . . . . . . . . . . . . . . . . 1-672<br />
REM . . . . . . . . . . . . . . . . . . . . . . . 1-673<br />
REMOVE . . . . . . . . . . . . . . . . . . . . . 1-675<br />
REMOVE . . . . . . . . . . . . . . . . . . . . . 1-680<br />
REPLACE . . . . . . . . . . . . . . . . . . . . . 1-682<br />
RESIZET . . . . . . . . . . . . . . . . . . . . . 1-686<br />
RETURN . . . . . . . . . . . . . . . . . . . . . 1-688<br />
REUSE . . . . . . . . . . . . . . . . . . . . . . 1-689<br />
REWIND . . . . . . . . . . . . . . . . . . . . . 1-691<br />
RND . . . . . . . . . . . . . . . . . . . . . . . 1-693<br />
RNDSEED . . . . . . . . . . . . . . . . . . . . . 1-694<br />
RQM. . . . . . . . . . . . . . . . . . . . . . . 1-695<br />
SADD . . . . . . . . . . . . . . . . . . . . . . 1-696<br />
saveSecurityContext . . . . . . . . . . . . . . . . . . 1-697<br />
SCMP . . . . . . . . . . . . . . . . . . . . . . 1-699<br />
SDIV . . . . . . . . . . . . . . . . . . . . . . 1-701<br />
SELECT . . . . . . . . . . . . . . . . . . . . . 1-702<br />
SELECTINDEX . . . . . . . . . . . . . . . . . . . 1-706<br />
SELECTINFO. . . . . . . . . . . . . . . . . . . . 1-709<br />
SEND . . . . . . . . . . . . . . . . . . . . . . 1-711<br />
SEQ . . . . . . . . . . . . . . . . . . . . . . . 1-713<br />
SEQS . . . . . . . . . . . . . . . . . . . . . . 1-714
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRTOC.fm<br />
(bookTOC.template)<br />
Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta<br />
xiii <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
setAuthenticationDepth . . . . . . . . . . . . . . . . . 1-715<br />
setCipherSuite . . . . . . . . . . . . . . . . . . . . 1-717<br />
setClientAuthentication . . . . . . . . . . . . . . . . . 1-719<br />
SETENV . . . . . . . . . . . . . . . . . . . . . 1-721<br />
setHTTPDefault . . . . . . . . . . . . . . . . . . . 1-722<br />
SETINDEX . . . . . . . . . . . . . . . . . . . . 1-725<br />
setPrivateKey . . . . . . . . . . . . . . . . . . . . 1-730<br />
setRandomSeed . . . . . . . . . . . . . . . . . . . 1-732<br />
setRequestHeader. . . . . . . . . . . . . . . . . . . 1-734<br />
setSocketOptions . . . . . . . . . . . . . . . . . . . 1-736<br />
showSecurityContext . . . . . . . . . . . . . . . . . 1-738<br />
SIGNATURE . . . . . . . . . . . . . . . . . . . . 1-740<br />
SIN . . . . . . . . . . . . . . . . . . . . . . . 1-743<br />
SLEEP . . . . . . . . . . . . . . . . . . . . . . 1-744<br />
SMUL . . . . . . . . . . . . . . . . . . . . . . 1-746<br />
SOAPCreateRequest . . . . . . . . . . . . . . . . . . 1-747<br />
SOAPCreateSecureRequest . . . . . . . . . . . . . . . 1-749<br />
SOAPGetDefault . . . . . . . . . . . . . . . . . . . 1-752<br />
SOAPGetFault. . . . . . . . . . . . . . . . . . . . 1-754<br />
SOAPGetResponseHeader . . . . . . . . . . . . . . . . 1-756<br />
SOAPRequestWrite . . . . . . . . . . . . . . . . . . 1-758<br />
SOAPSetParameters . . . . . . . . . . . . . . . . . . 1-763<br />
SOAPSetRequestBody . . . . . . . . . . . . . . . . . 1-765<br />
SOAPSetRequestContent . . . . . . . . . . . . . . . . 1-767<br />
SOAPSetRequestHeader . . . . . . . . . . . . . . . . 1-769<br />
SOAPSubmitRequest . . . . . . . . . . . . . . . . . 1-771<br />
SORT . . . . . . . . . . . . . . . . . . . . . . 1-773<br />
SOUNDEX. . . . . . . . . . . . . . . . . . . . . 1-774<br />
SPACE . . . . . . . . . . . . . . . . . . . . . . 1-776<br />
SPACES . . . . . . . . . . . . . . . . . . . . . 1-777<br />
SPLICE . . . . . . . . . . . . . . . . . . . . . . 1-778<br />
SQLAllocConnect . . . . . . . . . . . . . . . . . . 1-780<br />
SQLAllocEnv . . . . . . . . . . . . . . . . . . . . 1-782<br />
SQLAllocStmt. . . . . . . . . . . . . . . . . . . . 1-784<br />
SQLBindCol . . . . . . . . . . . . . . . . . . . . 1-786<br />
SQLBindParameter . . . . . . . . . . . . . . . . . . 1-788<br />
SQLCancel . . . . . . . . . . . . . . . . . . . . . 1-792<br />
SQLColAttributes . . . . . . . . . . . . . . . . . . 1-794<br />
SQLColumns . . . . . . . . . . . . . . . . . . . . 1-798<br />
SQLConnect . . . . . . . . . . . . . . . . . . . . 1-801<br />
SQLDescribeCol . . . . . . . . . . . . . . . . . . . 1-803<br />
SQLDisconnect . . . . . . . . . . . . . . . . . . . 1-805
xiv <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
SQLError . . . . . . . . . . . . . . . . . . . . . 1-807<br />
SQLExecDirect . . . . . . . . . . . . . . . . . . . 1-810<br />
SQLExecute . . . . . . . . . . . . . . . . . . . . 1-813<br />
SQLFetch . . . . . . . . . . . . . . . . . . . . . 1-815<br />
SQLFreeConnect . . . . . . . . . . . . . . . . . . . 1-817<br />
SQLFreeEnv . . . . . . . . . . . . . . . . . . . . 1-819<br />
SQLFreeStmt . . . . . . . . . . . . . . . . . . . . 1-821<br />
SQLGetInfo . . . . . . . . . . . . . . . . . . . . 1-824<br />
SQLGetTypeInfo . . . . . . . . . . . . . . . . . . . 1-829<br />
SQLNumParams . . . . . . . . . . . . . . . . . . . 1-834<br />
SQLNumResultCols . . . . . . . . . . . . . . . . . . 1-836<br />
SQLParamOptions . . . . . . . . . . . . . . . . . . 1-838<br />
SQLPrepare . . . . . . . . . . . . . . . . . . . . 1-841<br />
SQLRowCount . . . . . . . . . . . . . . . . . . . 1-844<br />
SQLSetConnectOption . . . . . . . . . . . . . . . . . 1-846<br />
SQLSetParam . . . . . . . . . . . . . . . . . . . . 1-850<br />
SQLSpecialColumns. . . . . . . . . . . . . . . . . . 1-851<br />
SQLStatistics . . . . . . . . . . . . . . . . . . . . 1-855<br />
SQLTables . . . . . . . . . . . . . . . . . . . . . 1-860<br />
SQLTransact . . . . . . . . . . . . . . . . . . . . 1-863<br />
SQRT . . . . . . . . . . . . . . . . . . . . . . 1-866<br />
SQUOTE . . . . . . . . . . . . . . . . . . . . . 1-867<br />
SSUB . . . . . . . . . . . . . . . . . . . . . . 1-868<br />
STATUS . . . . . . . . . . . . . . . . . . . . . 1-869<br />
STOP . . . . . . . . . . . . . . . . . . . . . . 1-870<br />
STR . . . . . . . . . . . . . . . . . . . . . . . 1-872<br />
STRS . . . . . . . . . . . . . . . . . . . . . . 1-874<br />
submitRequest. . . . . . . . . . . . . . . . . . . . 1-875<br />
SUBROUTINE . . . . . . . . . . . . . . . . . . . 1-878<br />
SUBROUTINE (Update Trigger) . . . . . . . . . . . . . . 1-880<br />
SUBROUTINE (Delete Trigger) . . . . . . . . . . . . . . 1-884<br />
SUBSTRINGS . . . . . . . . . . . . . . . . . . . 1-887<br />
SUM . . . . . . . . . . . . . . . . . . . . . . . 1-889<br />
SWAP . . . . . . . . . . . . . . . . . . . . . . 1-891<br />
SYSTEM . . . . . . . . . . . . . . . . . . . . . 1-893<br />
TAN . . . . . . . . . . . . . . . . . . . . . . . 1-871<br />
TIME . . . . . . . . . . . . . . . . . . . . . . 1-872<br />
TIMEDATE . . . . . . . . . . . . . . . . . . . . 1-873<br />
TRANSACTION ABORT . . . . . . . . . . . . . . . . 1-874<br />
TRANSACTION COMMIT . . . . . . . . . . . . . . . 1-876<br />
TRANSACTION START . . . . . . . . . . . . . . . . 1-879<br />
TRIM . . . . . . . . . . . . . . . . . . . . . . 1-881
TRIMB . . . . . . . . . . . . . . . . . . . . . . 1-884<br />
TRIMF . . . . . . . . . . . . . . . . . . . . . . 1-885<br />
TRIMS . . . . . . . . . . . . . . . . . . . . . . 1-886<br />
UDTEXECUTE. . . . . . . . . . . . . . . . . . . . 1-889<br />
UNASSIGNED . . . . . . . . . . . . . . . . . . . . 1-891<br />
UNLOCK . . . . . . . . . . . . . . . . . . . . . 1-892<br />
UPCASE . . . . . . . . . . . . . . . . . . . . . . 1-894<br />
WAKE. . . . . . . . . . . . . . . . . . . . . . . 1-896<br />
WEOF. . . . . . . . . . . . . . . . . . . . . . . 1-898<br />
WEOFSEQ . . . . . . . . . . . . . . . . . . . . . 1-900<br />
WRITE . . . . . . . . . . . . . . . . . . . . . . 1-902<br />
WRITELIST. . . . . . . . . . . . . . . . . . . . . 1-906<br />
WRITESEQ . . . . . . . . . . . . . . . . . . . . . 1-908<br />
WRITESEQF . . . . . . . . . . . . . . . . . . . . 1-910<br />
writeSocket . . . . . . . . . . . . . . . . . . . . . 1-912<br />
WRITET . . . . . . . . . . . . . . . . . . . . . . 1-914<br />
WRITEU . . . . . . . . . . . . . . . . . . . . . . 1-917<br />
WRITEV . . . . . . . . . . . . . . . . . . . . . . 1-920<br />
WRITEVU . . . . . . . . . . . . . . . . . . . . . 1-924<br />
XDOMAddChild . . . . . . . . . . . . . . . . . . . 1-928<br />
XDOMAppend . . . . . . . . . . . . . . . . . . . . 1-931<br />
XDOMClone . . . . . . . . . . . . . . . . . . . . 1-933<br />
XDOMClose. . . . . . . . . . . . . . . . . . . . . 1-935<br />
XDOMCreateNode. . . . . . . . . . . . . . . . . . . 1-936<br />
XDOMCreateRoot . . . . . . . . . . . . . . . . . . . 1-939<br />
XDOMEvaluate. . . . . . . . . . . . . . . . . . . . 1-942<br />
XDOMGetAttribute . . . . . . . . . . . . . . . . . . 1-945<br />
XDOMGetNodeName. . . . . . . . . . . . . . . . . . 1-947<br />
XDOMGetNodeType . . . . . . . . . . . . . . . . . . 1-949<br />
XDOMGetNodeValue . . . . . . . . . . . . . . . . . . 1-950<br />
XDOMGetOwnerDocument . . . . . . . . . . . . . . . . 1-952<br />
XDOMGetUserData . . . . . . . . . . . . . . . . . . 1-953<br />
XDOMInsert. . . . . . . . . . . . . . . . . . . . . 1-958<br />
XDOMLocate . . . . . . . . . . . . . . . . . . . . 1-961<br />
XDOMLocateNode . . . . . . . . . . . . . . . . . . 1-964<br />
XDOMOpen . . . . . . . . . . . . . . . . . . . . . 1-967<br />
XDOMRemove . . . . . . . . . . . . . . . . . . . . 1-969<br />
XDOMReplace . . . . . . . . . . . . . . . . . . . . 1-972<br />
XDOMSetNodeValue . . . . . . . . . . . . . . . . . . 1-974<br />
XDOMSetUserData . . . . . . . . . . . . . . . . . . 1-976<br />
XDOMTransform . . . . . . . . . . . . . . . . . . . 1-977<br />
XDOMValidate . . . . . . . . . . . . . . . . . . . . 1-979<br />
Table of Contents xv
xvi <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
XDOMValidateDom . . . . . . . . . . . . . . . . . . 1-981<br />
XDOMWrite . . . . . . . . . . . . . . . . . . . . 1-983<br />
XLATE . . . . . . . . . . . . . . . . . . . . . . 1-986<br />
XMAPClose . . . . . . . . . . . . . . . . . . . . 1-990<br />
XMAPCreate . . . . . . . . . . . . . . . . . . . . 1-991<br />
XMAPOpen . . . . . . . . . . . . . . . . . . . . 1-993<br />
XMAPReadNext . . . . . . . . . . . . . . . . . . . 1-995<br />
XMAPToXMLDoc . . . . . . . . . . . . . . . . . . 1-997<br />
XMLError . . . . . . . . . . . . . . . . . . . . . 1-1000<br />
XMLExecute . . . . . . . . . . . . . . . . . . . . 1-1001<br />
XMLGetError . . . . . . . . . . . . . . . . . . . . 1-1004<br />
XMLGetOptions . . . . . . . . . . . . . . . . . . . 1-1005<br />
XMLGetOptionValue . . . . . . . . . . . . . . . . . 1-1007<br />
XMLSetOptions . . . . . . . . . . . . . . . . . . . 1-1009<br />
XMLTODB . . . . . . . . . . . . . . . . . . . . 1-1011<br />
Appendix A ASCII Character Codes<br />
Appendix B <strong>UniBasic</strong>@variables<br />
@variables . . . . . . . . . . . . . . . . . . . . . B-2<br />
Delimiter @variables . . . . . . . . . . . . . . . . . B-6<br />
@SYSTEM.RETURN.CODE Values . . . . . . . . . . . . B-7<br />
Appendix C Operators in <strong>UniBasic</strong><br />
Arithmetic Operators. . . . . . . . . . . . . . . . . . C-2<br />
Boolean Operators . . . . . . . . . . . . . . . . . . C-4<br />
Relational Operators . . . . . . . . . . . . . . . . . . C-5<br />
Appendix D Reserved Words<br />
Appendix E <strong>Commands</strong> Affected by BASICTYPEs and UDT.OPTIONS<br />
Appendix F <strong>Commands</strong> That Set STATUS() Return Values
<strong>UniBasic</strong> <strong>Commands</strong> and Functions<br />
This section contains a detailed alphabetic listing of <strong>UniBasic</strong> commands, functions,<br />
and operators that include descriptions and working examples.<br />
Functions perform specialized operations that augment and enhance commands. You<br />
always use functions as expressions or in expressions following a command.<br />
1-22
1-23 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Elements of Syntax Statements<br />
This reference manual uses a common method to present syntax for UniData<br />
commands. The syntax statement includes the command name, required arguments,<br />
and options you can use with the command. Italics represents a variable you can<br />
replace with any valid option. The following figure illustrates the elements of a<br />
syntax statement.<br />
command names<br />
appear in boldface<br />
no brackets or braces<br />
indicates a required<br />
argument<br />
square brackets indicate<br />
an optional argument<br />
a vertical line indicates that<br />
you can choose between<br />
the given arguments<br />
COMMAND required [option] [option1 | option2]<br />
{option1 | option2} required... "string"<br />
quotation marks<br />
must enclose a<br />
literal string<br />
braces indicate that you<br />
must choose between<br />
the given arguments<br />
an ellipsis indicates that<br />
you can enter more than<br />
one argument
!<br />
! is a synonym for the * and REM commands, which you can use to create comments.<br />
It also is a synonym for the OR operator. For information about creating comments,<br />
see REM. For information about the OR operator, see OR.<br />
Synonyms<br />
*, REM, OR<br />
! 1-24
#<br />
1-25 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
# is a synonym for the NE relational operator. For more information, see NE.<br />
Synonyms<br />
, >
#<<br />
#< is a synonym for the GE relational operator. For more information, see GE.<br />
Synonyms<br />
>=, =>, GE<br />
#< 1-26
#><br />
1-27 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
#> is a synonym for the LE relational operator. For more information, see LE.<br />
Synonyms<br />
$BASICTYPE<br />
Syntax<br />
$BASICTYPE "param"<br />
Description<br />
The <strong>UniBasic</strong> $BASICTYPE command compiles data in a specified BASICTYPE.<br />
The $BASICTYPE statement must be the first noncomment statement in the program<br />
or subroutine.<br />
You can include only one $BASICTYPE statement per file (main program or<br />
subroutine), but you can split a program into separately cataloged subroutines for the<br />
purpose of changing BASICTYPE.<br />
If you do not specify $BASICTYPE, UniData compiles the program in the<br />
BASICTYPE specified in the ECL BASICTYPE command. The default type is U.<br />
Note: The BASICTYPE param must be in quotation marks.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
U <strong>UniBasic</strong><br />
P Pick ® BASIC<br />
R Advanced Revelation ® BASIC<br />
M McDonnell Douglas BASIC/ Reality ® BASIC<br />
$BASICTYPE Parameters<br />
$BASICTYPE 1-28
Related Command<br />
UniData<br />
BASICTYPE – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
1-29 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
$DEFINE<br />
Syntax<br />
$DEFINE var<br />
Description<br />
The <strong>UniBasic</strong> $DEFINE command defines a control variable you can use later to<br />
direct compilation.<br />
Tip: Keep $DEFINE statements in a separate INCLUDE file to facilitate recompiling<br />
programs with different definitions.<br />
Example<br />
In the following example, SMALL is defined when the program segment is<br />
compiled, and UniData defines array1 as a 10-element array initialized with 0:<br />
$DEFINE SMALL<br />
$IFDEF SMALL<br />
DIM array1(10)<br />
MAT array1 = 0<br />
$ENDIF<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
$UNDEFINE, EQU<br />
$DEFINE 1-30
$IFDEF<br />
Syntax<br />
1-31 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
$IFDEF var statements1 [$ELSE statements2] $ENDIF<br />
Description<br />
The <strong>UniBasic</strong> $IFDEF command conditionally compiles <strong>UniBasic</strong> statements<br />
depending on the existence of a variable definition. Variables are defined by<br />
$DEFINE.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
var Specifies variable to check to determine whether to compile statements1<br />
or statements2.<br />
statements1 Specifies statements to compile if var is defined.<br />
statements2 Specifies optional statements to compile if var is not defined.<br />
$IFDEF Parameters<br />
Examples<br />
In the following example, when you compile the program segment, the system<br />
defines array1 as a 10-element array initialized with 0:<br />
$DEFINE SMALL<br />
$IFDEF SMALL<br />
DIM array1(10)<br />
MAT array1 = 0<br />
$ENDIF
In the next example, when you compile the program segment, the system defines<br />
array1 as a 100-element array and initializes it with 1:<br />
$UNDEFINE SMALL<br />
$IFDEF SMALL<br />
PRINT 'SMALL was defined'<br />
$ELSE<br />
DIM array1(100)<br />
MAT array1 = 1<br />
$ENDIF<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
$DEFINE, $IFNDEF<br />
$IFDEF 1-32
$IFNDEF<br />
Syntax<br />
1-33 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
$IFNDEF var statements1 [$ELSE statements2] $ENDIF<br />
Description<br />
The <strong>UniBasic</strong> $IFNDEF command conditionally compiles <strong>UniBasic</strong> statements<br />
depending on the absence of a variable definition. Variables are defined by<br />
$DEFINE.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
var Specifies variable to check to determine whether to compile statements1<br />
or statements2.<br />
statements1 Specifies statements to compile if var is not defined.<br />
statements2 Specifies optional statements to compile if var is defined.<br />
$IFNDEF Parameters
Example<br />
In the following example, the program segment nests the $IFDEF and $IFNDEF<br />
statements. Upon compilation of this program, the size of array A might be 1000, 10,<br />
or 100 depending on whether LARGE or SMALL is defined. If both are undefined,<br />
the size of A is 100 elements, and the initialized value of array A might be 1 or 0,<br />
depending on whether ONE is defined.<br />
$IFDEF LARGE<br />
DIM A(1000)<br />
$IFDEF ONE<br />
MAT A = 1<br />
$ELSE<br />
MAT A = 0<br />
$ENDIF<br />
$ELSE<br />
$IFNDEF SMALL<br />
DIM A(100)<br />
$ELSE<br />
DIM A(10)<br />
$ENDIF<br />
$IFDEF ONE<br />
MAT A = 1<br />
$ELSE<br />
MAT A = 0<br />
$ENDIF<br />
$ENDIF<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
$DEFINE, $IFDEF<br />
$IFNDEF 1-34
$INCLUDE<br />
Syntax<br />
1-35 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
$INCLUDE record [FROM [DICT] filename]<br />
$INCLUDE filename {, | | > } record<br />
$INCLUDE [pathname {, | | > }] seq.filename<br />
Synonym<br />
$INSERT<br />
Description<br />
The <strong>UniBasic</strong> $INCLUDE and $INSERT commands insert <strong>UniBasic</strong> source code<br />
from the file you specify into the program being compiled.<br />
The third form of the syntax inserts code from a UNIX, or Windows platform<br />
sequential file.<br />
Note: In $BASICTYPEs P and M, you can enter $INCLUDE or INCLUDE.
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
record Specifies the record that contains the code you want to insert.<br />
filename Specifies the name of a UniData directory containing the record. If you do<br />
not specify filename, the system searches for record in the current file<br />
where the program being compiled resides.<br />
pathname Specifies the directory containing seq.filename. If you do not specify<br />
pathname, the system searches for seq.filename in the current directory.<br />
The delimiter between the path and the file or record can be a space, comma<br />
(,) or a greater than sign (>).<br />
seq.filename Specifies the name of an operating system sequential file.<br />
$INCLUDE Parameters<br />
Note: filename can identify a remote file as determined by the VOC entry. The code<br />
to be inserted can also contain $INCLUDE or $INSERT statements.<br />
Examples<br />
In the following example, the program statement inserts into the program being<br />
compiled the code contained in file code_seg1 in directory BP:<br />
$INCLUDE code_seg1 FROM BP<br />
The next example demonstrates the use of the $INCLUDE command in UniData for<br />
UNIX. The program statement inserts into the program being compiled the code<br />
contained in sequential file my_code in directory /usr/ud/mydir:<br />
$INCLUDE /usr/ud/mydir/my_code<br />
$INCLUDE 1-36
$INSERT<br />
$INSERT is a synonym for the $INCLUDE command. For more information, see<br />
$INCLUDE.<br />
Synonym<br />
$INCLUDE<br />
1-37 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
$UNDEFINE<br />
Syntax<br />
$UNDEFINE var<br />
Description<br />
The <strong>UniBasic</strong> $UNDEFINE command deletes the definition of var previously<br />
defined by $DEFINE.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
$DEFINE, EQU<br />
$UNDEFINE 1-38
&<br />
1-39 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
& is a synonym for the AND Boolean operator. For more information, see AND.<br />
Synonym<br />
AND
*<br />
Syntax<br />
expr * expr<br />
Synonyms<br />
!, REM<br />
Description<br />
The * arithmetic operator multiplies the expressions on either side of the operator.<br />
The asterisk (*) also is a synonym for the ! and REM commands, which you can use<br />
to create comments. For information about creating comments, see REM.<br />
Note: You must include the REUSE function to apply arithmetic operations to all<br />
elements of a dynamic array.<br />
Example<br />
The following program segment uses the * operator to multiply VAR1 and VAR2:<br />
X = VAR1 * VAR2<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
REM, SMUL<br />
* 1-40
**<br />
1-41 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
** is a synonym for the ^ arithmetic operator. For more information, see ^.<br />
Synonym<br />
^
*=<br />
Syntax<br />
var *= expr<br />
Description<br />
The *= arithmetic operator multiplies the value of a variable by the number you<br />
specify.<br />
Tip: Using the *= operator is a more efficient way of multiplying a variable. For<br />
example, LINES *= 2 is more efficient than LINES = LINES * 2.<br />
Note: You must include the REUSE function to apply arithmetic operations to all<br />
elements of a dynamic array.<br />
Example<br />
In the following example, the variable LINES is multiplied by 2, which sets LINES<br />
equal to 14:<br />
LINES = 7<br />
LINES *= 2<br />
*= 1-42
+<br />
Syntax<br />
expr + expr<br />
+expr<br />
Description<br />
In the first version of the syntax, the + arithmetic operator adds the two numbers on<br />
either side of the operator.<br />
In the second version of the syntax, + acts as a unary plus operator (same as multiplying<br />
by +1).<br />
Example<br />
The following program segment is taken from the sample program in “Appendix A -<br />
Sample Program” in Developing <strong>UniBasic</strong> Applications. The third statement places<br />
the cursor at the location computed by 9+ENTRY, then the program displays the<br />
seventh element of the array ORDER.REC at that location.<br />
1-43 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
FOR ENTRY = 1 TO NUM_ENTRIES<br />
NEW.PRICE = ""<br />
DISPLAY @(10,9+ENTRY):OCONV(ORDER.REC,"MR2$,"):<br />
INPUT @(45,9+ENTRY):NEW.PRICE<br />
NEW.PRICE = OCONV(NEW.PRICE,"MCN")<br />
IF NEW.PRICE # '' AND NUM(NEW.PRICE) THEN<br />
ORDER.REC = NEW.PRICE<br />
NEED.TO.WRITE = 1<br />
END<br />
NEXT ENTRY<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
ABS, NEG, SADD, SUM
+=<br />
Syntax<br />
var += expr<br />
Description<br />
The += arithmetic operator increments the value of a variable by the number you<br />
specify.<br />
Tip: Using the += operator is a more efficient way of incrementing a variable. For<br />
example, LINES += 1 is more efficient than LINES = LINES + 1.<br />
Example<br />
In the following example, the variable LINES is incremented by 1, which sets LINES<br />
equal to 8:<br />
LINES = 7<br />
LINES += 1<br />
+= 1-44
1-45 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
-<br />
Syntax<br />
expr -expr<br />
-expr<br />
Description<br />
In the first version of the syntax, the - arithmetic operator subtracts the expr on the<br />
right from the expr on the left of the operator.<br />
In the second version of the syntax, - acts as a unary minus operator, which produces<br />
the same result as multiplying by -1.<br />
Examples<br />
In the following example, VAR2 is subtracted from VAR1 and the result is assigned<br />
to the variable X:<br />
X = VAR1 - VAR2<br />
In the next example, the - operator is used as the unary minus and changes the sign<br />
of VAR:<br />
VAR = -VAR<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
ABS, NEG
-=<br />
Syntax<br />
var -= expr<br />
Description<br />
The -= arithmetic operator decrements the value of a variable by the number you<br />
specify.<br />
Tip: Using the -= operator is a more efficient way to decrement a variable. For<br />
example, LINES -= 1 is more efficient than LINES = LINES -1.<br />
Example<br />
In the following example, the variable LINES is decremented by 1, which sets LINES<br />
equal to 6:<br />
LINES = 7<br />
LINES -= 1<br />
-= 1-46
1-47 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
/<br />
Syntax<br />
expr1 / expr2<br />
Description<br />
The / arithmetic operator divides the two numbers on either side of the operator.<br />
Example<br />
The following statement divides price by cost to determine quantity:<br />
PRICE / COST = QUANTITY<br />
Related Command<br />
<strong>UniBasic</strong><br />
SDIV
=<br />
Syntax<br />
var /= expr<br />
Description<br />
The /= arithmetic operator divides the value of a variable by the number you specify.<br />
Tip: Using the /= operator is a more efficient way of dividing a variable. For<br />
example, LINES /= 2 is more efficient than LINES = LINES/2.<br />
Example<br />
In the following example, the variable LINES is divided by 2, which sets LINES<br />
equal to 10:<br />
LINES = 20<br />
LINES /= 2<br />
/= 1-48
1-49 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
:<br />
: is a synonym for the CAT function. For more information, see CAT.<br />
Synonym<br />
CAT
^<br />
Syntax<br />
expr1^expr2<br />
Synonym<br />
**<br />
Description<br />
The ^ arithmetic operator raises expr1 to the power of expr2.<br />
Example<br />
In the following example, the program segment raises variable X to the power of 3,<br />
first using an exponentiation operator **, second using the PWR function, and last<br />
using the exponentiation operator ^. The results are identical.<br />
X = 2<br />
PRINT X**3<br />
PRINT PWR(X,3)<br />
PRINT X^3<br />
Related Command<br />
<strong>UniBasic</strong><br />
PWR<br />
^ 1-50
:=<br />
Syntax<br />
var := expr<br />
Description<br />
1-51 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
The := arithmetic operator concatenates the value of an expression to a variable.<br />
Tip: Using the := operator is a more efficient way of concatenating a variable. For<br />
example, LINES := 0 is more efficient than LINES = LINES CAT 0.<br />
Example<br />
In the following example, the variable LINES is concatenated with 0, which sets<br />
LINES equal to 100:<br />
LINES = 10<br />
LINES := 0
< is a synonym for the LT (less than) relational operator. For more information, see<br />
LT.<br />
Synonym<br />
LT<br />
< 1-52
The <strong>UniBasic</strong> function retrieves, inserts, or replaces elements in a dynamic array.<br />
It also acts as the not equal to relational operator. For information about retrieving,<br />
see EXTRACT. For information about inserting and replacing, see REPLACE. For<br />
information about the not equal to relational operator, see NE.<br />
Synonyms<br />
#, >
=<br />
1-55 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
= is a synonym for the EQ relational operator. For more information, see EQ.<br />
Synonym<br />
EQ
=><br />
=> is a synonym for the GE relational operator. For more information, see GE.<br />
Synonyms<br />
#=, GE<br />
=> 1-56
=<<br />
1-57 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
=< is a synonym for the LE relational operator. For more information, see LE.<br />
Synonyms<br />
#>,
>< is a synonym for NE relational operator. For more information, see NE.<br />
Synonyms<br />
#, , NE<br />
>< 1-58
1-59 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
> is a synonym for the GT relational operator. For more information, see GT.<br />
Synonym<br />
GT
=<br />
>= is a synonym for the GE relational operator. For more information, see GE.<br />
Synonyms<br />
#, GE<br />
>= 1-60
@<br />
Syntax<br />
@(col.expr [,row.expr])<br />
@(-num.expr)<br />
Description<br />
The <strong>UniBasic</strong> @ function positions the cursor on the video screen. In the first form,<br />
the system positions the cursor at the column and row you specify.<br />
1-61 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
In the second form, you can specify various terminal functions by num.expr.<br />
Any reference to @ functions turns off automatic screen pagination.<br />
Tip: Assign @ functions to variables if you expect to use the @ function more than<br />
once.<br />
Use the @ function in a PRINT statement to direct the terminal to take some action<br />
before printing.
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
col.expr Specifies the column position to place the cursor.<br />
Can be a literal value or variable.<br />
Must be a positive numeric value.<br />
Value 0 is the leftmost column on the screen. For most terminals, col.expr<br />
can range from 0 to 79 (the right-hand side of the screen).<br />
,row.expr Specifies the row at which to place the cursor. Defaults to the current row.<br />
Can be either a literal value or variable.<br />
Must be a positive value.<br />
Value 0 is the top of the screen. For most terminals, row.expr can range<br />
from 0 to 23 (the last row on the screen).<br />
-num.expr Specifies an @ terminal function. For valid @ terminal functions and their<br />
effects, see the next table.<br />
@ Parameters<br />
Tip: Use PRINT, DISPLAY, and CRT in combination with the <strong>UniBasic</strong> @ function<br />
to position the cursor on the screen before printing or to execute other terminal<br />
functions. Execute the ECL REUSE.ROW command to determine whether a line feed<br />
is executed when the <strong>UniBasic</strong> PRINT @ function references column only. For<br />
example, PRINT @(10) rather than PRINT @(3,10).<br />
@ Function Options<br />
The following @ function options direct the terminal to take an action.<br />
Option Description<br />
-1 Clear screen, home cursor.<br />
-2 Home cursor.<br />
-3 Clear from cursor to end of screen.<br />
@ Function Options<br />
@ 1-62
1-63 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Option Description<br />
-4 Clear from cursor to end of line.<br />
-5 Enter blink mode.<br />
-6 Stop blink mode.<br />
-7 Enter protected mode.<br />
-8 Stop protected mode.<br />
-9 Backspace one character.<br />
-10 Move cursor up one line.<br />
-11 Enter half-intensity mode.<br />
-12 Stop half-intensity mode.<br />
-13 Enter reverse video mode.<br />
-14 Stop reverse video mode.<br />
-15 Enter underlining mode.<br />
-16 Stop underlining mode.<br />
-17 Down one line.<br />
-18 Nondestructive space (cursor right).<br />
-19 Audible signal (bell).<br />
-20 Delete character.<br />
-21 Insert character.<br />
-22 Delete line.<br />
-23 Add new blank line.<br />
-24 Turn on the printer.<br />
-25 Turn off the printer.<br />
-26 Print contents of the screen.<br />
-27 Start alternate character set.<br />
@ Function Options (continued)
Option Description<br />
-28 End alternate character set.<br />
-29 to -49 Reserved for color combinations.<br />
-50 Sent by the backspace key.<br />
-51 Sent by the clear screen or erase key.<br />
-52 Sent by the delete character key.<br />
-53 Sent by the insert character key.<br />
-54 Sent by the delete line key.<br />
-55 Sent by the insert line key.<br />
-56 Sent by the home key.<br />
-57 Sent by the left arrow key.<br />
-58 Sent by the up arrow key.<br />
-59 Sent by the down arrow key.<br />
-60 Sent by the right arrow key.<br />
-61 Sent by the clear-to-end-of-line key.<br />
-62 Sent by the clear-to-end-of-screen key.<br />
-63 Sent by function key F0.<br />
-64 Sent by function key F1.<br />
-65 Sent by function key F2.<br />
-66 Sent by function key F3.<br />
-67 Sent by function key F4.<br />
-68 Sent by function key F5.<br />
-69 Sent by function key F6.<br />
-70 Sent by function key F7.<br />
-71 Sent by function key F8.<br />
@ Function Options (continued)<br />
@ 1-64
Examples<br />
In the following example, the statement prints the message HI in the fifth column<br />
from the left of the screen and the tenth row down from the top:<br />
PRINT @(5,10):"HI"<br />
In the next example, the program segment prints two messages at different points on<br />
the screen:<br />
1-65 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Option Description<br />
-72 Sent by function key F9.<br />
-73 Sent by function key F10.<br />
-74 Sent by the next-page key.<br />
-75 Sent by the previous-page key.<br />
-76 Sent by the scroll forward/down key.<br />
-77 Sent by the scroll backward/up key.<br />
-78 Sent by the set-tab key.<br />
-79 Sent by the terminal up arrow key.<br />
-80 Out of “keypad transmit” key.<br />
-81 Turn bold on.<br />
-82 Turn bold off.<br />
-83 Turn standout on.<br />
-84 Turn standout off.<br />
ROW = 0 ; COL = 0<br />
PRINT @(COL,ROW):"TOP":@(COL,ROW+21):"BOTTOM"<br />
In the next example, the program segment initiates reverse video mode, prints a<br />
prompt, and then stops reverse video mode:<br />
PRINT @(-13)<br />
PRINT "ENTER NAME:":<br />
PRINT @(-14)<br />
@ Function Options (continued)
In the next example, the program segment clears the screen and places the cursor in<br />
the home position (0,0):<br />
CLS = @(-1)<br />
PRINT CLS<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
@variables – For information, see Appendix B, “<strong>UniBasic</strong>@variables.”<br />
UniData<br />
REUSE.ROW – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
@ 1-66
[]<br />
Syntax<br />
1-67 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
string.expr [num.expr1,num.expr2] = expr<br />
expr = string.expr [num.expr1, num.expr2]<br />
Description<br />
The <strong>UniBasic</strong> [] (square brackets) function extracts or replaces strings.<br />
Null Value Handling<br />
With null value handling on, when <strong>UniBasic</strong> encounters the null value in a command<br />
parameter where a number is expected (num.expr1, num.expr2), it displays a warning<br />
message and uses 0.<br />
Note: In BASICTYPE M and P, the [] (square brackets) function can remove a<br />
substring entirely and can also remove parts of the substring.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
string.expr In the first form, the function replaces part or all of string.expr. In the<br />
second form, the function extracts part or all of string.expr.<br />
num.expr1 Indicates the starting position for the operation. It refers to the character<br />
position where the replacement or extraction operation occurs.<br />
num.expr2 Indicates the number of characters involved in the operation. If UniData<br />
performs an extraction, it returns that number of characters. If UniData<br />
performs a replacement, it replaces that number of characters.<br />
[ ] Parameters
Examples<br />
In the following example, the program segment extracts the first character of the<br />
variable LAST.NAME (in this case, an S):<br />
LAST.NAME = 'Smith'<br />
L.INITIAL = LAST.NAME[1,1]<br />
In the next example, the program segment changes the first letter of the word Bind in<br />
the variable TITLE to W. The resulting string is “Gone with the Wind”.<br />
TITLE = 'Gone with the Bind'<br />
TITLE[15,1] = 'W'<br />
In the next example, the program segment changes the substring 234 spaces:<br />
A = "12345"<br />
A[2,3] = ""<br />
In BASICTYPE U, system output is as follows:<br />
A = "1 5"<br />
In BASICTYPEs M and P, the substring is extracted as follows:<br />
A = "15"<br />
The following program inserts the null value into string X, which contains 12345, and<br />
then prints this element before and after converting @NULL to the printable string<br />
“@NULL”:<br />
X=12345<br />
X[3,1]=@NULL<br />
PRINT "X[3,1] is printed on the next line."<br />
PRINT X[3,1]<br />
X = CHANGE(X[3,1], @NULL,"@NULL")<br />
PRINT "X[3,1] is printed on the next line."<br />
PRINT X<br />
This program prints the following text:<br />
X[3,1] is printed on the next line.<br />
X[3,1] is printed on the next line.<br />
@NULL<br />
[] 1-68
{}<br />
{} is a synonym for the CALCULATE function. For more information, see<br />
CALCULATE.<br />
Synonym<br />
CALCULATE<br />
1-69 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
ABORT<br />
Syntax<br />
ABORT [expr]<br />
Description<br />
The <strong>UniBasic</strong> ABORT command terminates the program or subroutine in progress,<br />
returning the user to the UniData system level. ABORT returns the user to the<br />
UniData prompt, whether the aborted program was called by another program or<br />
executed through a UniData menu or paragraph. ABORT can include an optional<br />
string expr to display when the program aborts. The expression can contain variables,<br />
functions, and/or arithmetic or string operators.<br />
The <strong>UniBasic</strong> commands ABORT and PRINTERR return the system message whose<br />
ID you specify in the command. You can also retrieve system messages using a<br />
<strong>UniBasic</strong> program by opening the system message file and reading a message record<br />
by ID.<br />
Note: ENGLISH.MSG is the default system message file that is activated when you<br />
install UniData. If you execute udtlang.config to select a language group, a different<br />
system message file could be activated. To find out which language is installed on<br />
your system, execute the ECL command SET.LANG CURRENT. For more<br />
information, see UniData International.<br />
The ABORT command in BASICTYPE P provides additional functions. ABORT<br />
prints either a user-defined message specified by the string expr, or a UniData system<br />
message identified by message-id:<br />
ABORT [message-id]<br />
ABORT [expr,...]<br />
In the first form of the syntax, the message-id must be a variable that evaluates to a<br />
key contained in the UniData message file. If no message exists, the number entered<br />
in message-id is returned. In the second form of the above syntax, you can specify<br />
more than one expr.<br />
ABORT 1-71
Note: You can use the ECL ON.ABORT command so that ABORT does not terminate<br />
the process. For information about the ECL ON.ABORT command, see the UniData<br />
<strong>Commands</strong> <strong>Reference</strong>.<br />
Examples<br />
In the following program segment, the user is prompted if an error flag ERR.FLAG<br />
has been set. The user’s input is read into the variable “answer”. If “answer” equals<br />
“Y”, the program aborts.<br />
1-72 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ERR.FLAG = 1<br />
IF ERR.FLAG THEN<br />
PRINT "ABORT PROGRAM?"<br />
INPUT answer<br />
IF ANS = "Y" THEN ABORT<br />
...<br />
In the next example, in BASICTYPE P, an error message prints and the program<br />
terminates when CLIENTS cannot be opened:<br />
EID = "Error Message Text."<br />
ERR_MSG = "CAN'T OPEN FILE"<br />
OPEN "CLIENTS" TO CLIENTS.FILE ELSE<br />
ABORT ERR_MSG, EID<br />
END<br />
In the next example, in BASICTYPE P, the program segment prints the error message<br />
from record 10075 in the error message file if the program aborts:<br />
$BASICTYPE "P"<br />
OPEN 'CLIENTS' TO CLIENT.FILE ELSE STOP "CANNOT OPEN"<br />
READ REC FROM CLIENT.FILE, "99" ELSE ABORT 10075<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
PRINTERR, STOP<br />
UniData<br />
ON.ABORT, CLEAR.ONABORT – For information, see the UniData <strong>Commands</strong><br />
<strong>Reference</strong>.
Error Message File – For information, see Administering UniData on UNIX or<br />
Administering UniData on Windows Platforms.<br />
ABORT 1-73
ABS<br />
Syntax<br />
ABS(expr)<br />
Description<br />
The <strong>UniBasic</strong> ABS function returns the positive numeric value (absolute value) of<br />
the argument. expr can be any numeric expression.<br />
Examples<br />
In the following example, the program segment prints the absolute value of the<br />
variable NUM, which is 999:<br />
NUM = -999<br />
PRINT ABS(NUM)<br />
In the next example, the program statement replaces the variable NUM with its<br />
absolute value:<br />
NUM = ABS(NUM)<br />
Related Command<br />
<strong>UniBasic</strong><br />
NEG<br />
1-74 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
acceptConnection<br />
Syntax<br />
acceptConnection(svr_socket, blocking_mode, timeout, in_addr, in_name,<br />
socket_handle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Use the acceptConnection function to accept an incoming connection attempt on the<br />
server side socket.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
svr_socket The handle to the server side socket returned by initServerSocket().<br />
blocking_mode 0 - default (blocking)<br />
1 - blocking. In this mode and the current blocking mode of svr_socket<br />
is set to blocking, acceptConnection() blocks the caller until a<br />
connection request is received or the specfied time_out has expired.<br />
2 - non-blocking. In this mode if there are no pending connections<br />
present on the queue, acceptConnection() returns an error status code.<br />
In this mode, time_out is ignored.<br />
time_out Timeout in milliseconds.<br />
acceptConnection Parameters<br />
acceptConnection 1-75
Parameter Description<br />
1-76 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
in_addr The buffer that receives the address of the incoming connection. If<br />
NULL, it will return nothing.<br />
in_name The variable that receives the name of the incoming connection. If<br />
NULL, it will return nothing.<br />
socket_handle The handle to the newly created socket on which the actual connection<br />
will be made. The server will use readSocket(), writeSocket(), and so<br />
forth, with this handle to commuinicate with the client.<br />
The following table describes the status of each return code.<br />
Return Code Status<br />
0 Success.<br />
acceptConnection Parameters (continued)<br />
Non-zero See Socket Function Error Return Codes.<br />
acceptConnection Return Codes
ACOS<br />
Syntax<br />
ACOS(expr)<br />
Description<br />
The <strong>UniBasic</strong> ACOS function returns the trigonometric arc cosine (inverse cosine)<br />
of a numeric expression in degrees. expr must be a value between -1 and +1. ACOS<br />
returns a value expressed as the degree of the arc cosine of the input, which ranges<br />
from 0 to 180. If expr evaluates to a value outside the range of -1 to +1, UniData<br />
displays an error message and returns 0 as the result.<br />
With null value handling on, the result of any mathematical operation, function, or<br />
comparison involving the null value is the null value. Therefore, ACOS returns the<br />
null value when expr is the null value.<br />
Examples<br />
In the following example, the program statement assigns 60, the arc cosine of 0.5, to<br />
ARCCOS:<br />
ARCCOS = ACOS(0.5)<br />
In the next example, the program statement prints out the arc cosine of -0.5, which is<br />
120:<br />
PRINT ACOS(-0.5)<br />
Related <strong>Commands</strong><br />
ASIN, ATAN, COS, SIN, TAN<br />
ACOS 1-77
ACTIVATEKEY<br />
Syntax<br />
ACTIVATEKEY , [ON ] [ON ERROR<br />
]<br />
Description<br />
Use the ACTIVATEKEY command to activate a key or wallet. It is necessary to<br />
activate a key if you want to supply a password for key protection.<br />
Note: You can activate only keys with password protection with this command. Keys<br />
that do not have password protection are automatically activated.<br />
Parameters<br />
1-78 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
key.id The key ID or wallet ID to activate. If you provide a Wallet ID,<br />
UniData activates all keys in the wallet.<br />
ACTIVATEKEY Parameters
Parameter Description<br />
password The password corresponding to key.id.<br />
ON NFA_SERVER The name of the NFA_SERVER on which you want to activate<br />
the encryption key. The syntax for NFA_SERVER can be either:<br />
STATUS Codes<br />
@domain.var where domain.var specifies the ID for a VOC<br />
entry that contains the NFA server connection parameters.<br />
OR<br />
“MACHINE PORT [, UDTHOME<br />
]”<br />
NFA files are always encrypted and decrypted on the remote<br />
machine by the NFA server.<br />
ON ERROR statements If you specify ON ERROR statements and an error occurs,<br />
UniData executes the statements following the ON ERROR<br />
clause. Otherwise, UniData executes the next statement.<br />
The ACTIVATEKEY statement rerurns the following STATUS codes regarding<br />
wallet operations:<br />
STATUS<br />
Code<br />
Description<br />
0 Operation successful<br />
ACTIVATEKEY Parameters (continued)<br />
1 Key is already activated or deactivated. This applies to a single key, not<br />
a wallet operation<br />
2 Operation failed. This applies to a single key, not a wallet operation<br />
3 Invalid wallet ID or password<br />
4 No access to wallet<br />
ACTIVATEKEY STATUS Codes<br />
ACOS 1-79
STATUS<br />
Code<br />
Example<br />
1-80 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Description<br />
5 Invalid key ID or password<br />
6 No access to one of the keys in the wallet<br />
9 Other error<br />
ACTIVATEKEY STATUS Codes (continued)<br />
The following example illustrates how to activate an encryption key:<br />
ACTIVATEKEY "test","myunidata" ON ERROR PRINT "Unable to activate key"
addAuthenticationRule<br />
Syntax<br />
addAuthenticationRule(context, serverOrClient, rule, ruleString)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The addAuthenticationRule function adds an authentication rule to a security<br />
context. The rules are used during SSL negotiation to determine whether or not the<br />
peer is to be trusted.<br />
UniData currently supports the following rules:<br />
Verification Strength rule – The rule governs the SSL negotiation and<br />
determines whether or not an authentication process is considered<br />
successful. There are two levels of security, generous and strict. If you<br />
specify generous, the certificate need only contain the subject name<br />
(common name) that matches the one you specify by “Peer Name” to be<br />
considered valid. If you specify strict, the incoming certificate must pass a<br />
number of checks, including signature check, expiry check, purpose check,<br />
and issuer check.<br />
PeerName rule – If you specify the PeerName rule and provide common<br />
names separated by attributes marks in ruleString, UniData stores trust<br />
server/client names in the context.<br />
For more information about the addAuthenticationRule function, see <strong>UniBasic</strong><br />
Extensions.<br />
addAuthenticationRule 1-81
Parameters<br />
1-82 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
context The Security Context handle.<br />
ServerOrClient Flag 1 – Server<br />
Flag 2 – Client<br />
UniData treats any other value as a value of 1.<br />
Rule The rule name string. Valid settings are PeerName or<br />
VerificationStrength.<br />
RuleString Rule content string. May be attribute mark separated.<br />
addAuthenticationRule Parameters<br />
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success<br />
1 Invalid Security Context handle<br />
2 Invalid rule name<br />
3 Invalid rule content<br />
addAuthenticationRule Return Codes
addCertificate<br />
Syntax<br />
addCertificate(certPath, usedAs, format, algorithm, context)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The addCertificate function loads a certificate, or multiple certificates, into a<br />
security context for UniData to use as a server or client certificate. Alternatively, this<br />
function can specify a directory which contains the certificates that are either used as<br />
CA (Certificate Authority) certificates to authenticate incoming certificates, or act as<br />
a Revocation list to check against expired or revoked certificates.<br />
For detailed information about the addCertificate function, see <strong>UniBasic</strong><br />
Extensions.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
certPath A string containing the name of the OS-level file that holds the certificate,<br />
or the directory containing certificates.<br />
usedAs 1– Used as a client/server certificate.<br />
2 – Used as an issuer certificate.<br />
3 – Used as a Certificate Revocation List (CRL)<br />
addCertificate Parameters<br />
addCertificate 1-83
Parameter Description<br />
format 1 – PEM format<br />
2 – DER format<br />
algorithm 1 – RSA key<br />
2 – DSA key<br />
1-84 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
context The Security context handle.<br />
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success<br />
addCertificate Parameters (continued)<br />
1 Invalid Security Context handle.<br />
2 Certificate file could not be opened or directory does not exist.<br />
3 Unrecognized format.<br />
4 Corrupted or unrecognized certificate contents.<br />
5 Invalid parameter value(s).<br />
addCertificate Return Codes
addRequestParameter<br />
Syntax<br />
addRequestParameter(request_handle, parameter_name, parameter_value,<br />
content_handling)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The addRequestParameter function adds a parameter to the request.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
request_handle The handle to the request.<br />
parameter_name The name of the parameter.<br />
parameter_value The value of the parameter.<br />
content_handling The dynamic MIME type for the parameter value.<br />
addRequestParameter Parameters<br />
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success.<br />
addRequestParameter Return Codes<br />
addRequestParameter 1-85
1-86 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return<br />
Code Status<br />
1 Invalid request handle.<br />
2 Invalid parameter.<br />
3 Bad content type.<br />
addRequestParameter Return Codes (continued)<br />
Note: For a GET request, content_handling is ignored.<br />
For a POST request with default content type, the default for content_handling is<br />
“Content-Type:text/plain” if content_handling is not specified. For a POST request<br />
with “Multipart/*” content-type, content_handling is a dynamic array containing<br />
Content-* strings separated by field marks (@FM). They will be included in the<br />
multipart message before the data contained in parameter_value is sent. An example<br />
of content_handling:<br />
Content-Type: application/XML @FM<br />
Content-Dispostion: attachment; file=”C:\drive\test.dat” @FM<br />
Content-Length: 1923<br />
Specifically, for a POST request with content type “multipart/form-data”, a<br />
“Content-Dispostion: form-data” header will be created (or, in the case of Content-<br />
Dispostion already in content_handling, “form-data” will be added to it).<br />
For both a GET and a POST request with either no content type specified or specified<br />
as “application/x-www-form-urlencoded”, as described in createRequest(), URL<br />
encoding is performed on data in parameter_value automatically. Basically, any<br />
character other than alpha-numeric is considered “unsafe” and will be replaced by<br />
%HH where HH is the ASCII value of the character in question. For example, ‘#’ is<br />
replaced by %23, and ‘/’ is replaced by %2F, etc.. One exception is that by<br />
convention, spaces (‘ ‘) are converted into ‘+’.<br />
For a POST method with other MIME-type specified, no encoding is done on data<br />
contained in parameter_value.
ALPHA<br />
Syntax<br />
ALPHA("str.expr")<br />
Description<br />
The <strong>UniBasic</strong> ALPHA function tests a string to see if it is composed entirely of<br />
alphabetic characters. If str.expr is made entirely of alphabetic characters (not special<br />
characters, escape sequences, or the null value), the function returns 1. If numeric or<br />
other characters are present in str.expr, or if str.expr evaluates to an empty string or<br />
the null value, the function returns 0.<br />
Because <strong>UniBasic</strong> does not recognize multibyte characters as alphabetic, ALPHA<br />
returns 0 instead of converting them.<br />
Examples<br />
In the following example, the program statement prints 0 because the literal string<br />
contains the numeric character 2:<br />
PRINT ALPHA("ABCDEFGHIJK2")<br />
In the next example, the program segment prints 1 because the string ALPHA<br />
contains only alphabetic characters:<br />
ALPHA.T=ALPHA("CORONA")<br />
PRINT ALPHA.T<br />
In the next example, the program statement prints 0 because the string does not<br />
contain any characters. An empty string is not considered to be an alphabetic<br />
character.<br />
PRINT ALPHA("")<br />
ALPHA 1-87
amInitialize<br />
Syntax<br />
1-88 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
amInitialize(hSession,appName, policyName, reasonCode)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The amInitialize function creates and opens an AMI session. The output parameter,<br />
hsession, is a session handle that is valid until the session is terminated. This function<br />
returns a status code indicating success, warning, or failure.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
hSession Upon successful return, holds a handle to a session. You can then use the<br />
handle in other UniData WebSphere MQ API calls. [OUT]<br />
appName An optional name that you can use to identify the session. [IN]<br />
policyName The name of a policy. If you specify ““ (null), UniData uses the system<br />
default policy name. [IN]<br />
reasonCode Holds an AMI Reason Code when the function returns a status indicating<br />
an AMI warning, or an AMI error occurred. You can use the AMI Reason<br />
Code to obtain more information about the cause of the warning or error.<br />
See the MQSeries Application Messaging Interface manual for a list of<br />
AMI Reason Codes and their descriptions. [OUT]<br />
amInitialize Parameters
The following table describes the status of each return code.<br />
Return Code Status<br />
0 – AMCC_SUCCESS Function completed successfully.<br />
1 – AMCC_WARNING A warning was returned from AMI. The<br />
reasonCode output parameter contains an<br />
AMI reason code with further details about<br />
the warning.<br />
2 – AMCC_FAILED An error was returned from AMI. The<br />
reasonCode output parameter contains an<br />
AMI reason code with further details about<br />
the error.<br />
115 – U2AMI_ERR_SESSION_IN_USE An active session already exists (under a<br />
different hSession variable than the one being<br />
passed in).<br />
Other A non-AMI error occurred.<br />
amInitialize Return Codes<br />
amInitialize 1-89
amReceiveMsg<br />
Syntax<br />
amReceiveMsg(hSession,receiverName,policyName, selMsgName, maxMsgLen,<br />
dataLen, data, rcvMsgName, reasonCode)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
1-90 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
The amReceiveMsg function receives a message sent by the amSendMsg function.<br />
For detailed information about amReceiveMsg, see <strong>UniBasic</strong> Extensions.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
hSession The session handle returned by amInitialize. [IN]<br />
receiverName The name of a receiver service. If you do not specify a name, UniData<br />
uses the system default receiver name. [IN]<br />
policyName The name of a policy. If you do not specify a name, UniData uses the<br />
system default policy name. [IN]<br />
selMsgName Optional parameter specifying the name of a message object containing<br />
information (such as a Correl ID) that UniData uses to retrieve the<br />
required message fromthe queue. See <strong>UniBasic</strong> Extensions for detailed<br />
information about this parameter. [IN]<br />
maxMsgLen The maximum message length the application will accept. Specify as -<br />
1 to accept messages of any length. See <strong>UniBasic</strong> Extensions for<br />
detailed information about this parameter. [IN]<br />
amReceiveMsg Parameters
Parameter Description<br />
dataLen The length of the retrieved message data, in bytes. Specify ““ (null) if<br />
not required. [OUT]<br />
data The received message data. [OUT]<br />
rcvMsgName The name of a message object for the retrieved message. You can<br />
specify ““ (null) for this parameter, in which case UniData uses the<br />
system default name (constant AMSD_RCV_MSG). See <strong>UniBasic</strong><br />
Extensions for detailed information about this parameter. [IN]<br />
reasonCode Holds an AMI reason code when the function returns a status indicating<br />
an AMI warning or an AMI error occurred. You can use the AMI reason<br />
code to obtain more information about the cause of the warning or error.<br />
See the MQSeries Application Messaging Interface manual for a list of<br />
AMI reason codes and their descriptions. [OUT]<br />
The following table describes the status of each return code.<br />
Return Code Status<br />
amReceiveMsg Parameters (continued)<br />
0 – AMCC_SUCCESS Function complete successfully.<br />
1 – AMCC_WARNING A warning was returned from AMI. The reasonCode output<br />
parameter contains an AMI reason code with further details<br />
about the warning.<br />
2 – AMCC_FAILED An error was returned from AMI. The reasonCode output<br />
parameter contains an AMI reason code with further details<br />
about the error.<br />
Other A non-AMI error occurred.<br />
amReceiveMsg Return Codes<br />
amReceiveMsg 1-91
amReceiveRequest<br />
Syntax<br />
amReceiveRequest(hSession, receiverName, policyName, maxMsgLen, dataLen,<br />
data, rcvMsgName, senderName, reasonCode)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
1-92 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
The amReceiveRequest function receives a request message.<br />
For detailed information about this function, see <strong>UniBasic</strong> Extensions.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
hSession The session handle returned by the amInitialize function. [IN]<br />
receiverName The name of a receiver service. If you specify ““ (null), UniData uses the<br />
system default receiver name. [IN]<br />
policyName The name of a policy. If you do not specify a policy name, UniData uses<br />
the system default policy name. [IN]<br />
maxMsgLen The maximum message length the application will accept. Specify -1 to<br />
accept messages of any length. See <strong>UniBasic</strong> Extensions for detailed<br />
information about this parameter. [IN]<br />
dataLen The length of the message data, in bytes. Specify ““(null) if this is not<br />
required. [OUT]<br />
data The received message data. [OUT]<br />
amReceiveRequest Parameters
Parameter Description<br />
rcvMsgName The name of the message object for the received message. If you specify<br />
““(null) for this parameter, UniData uses the system default receiver<br />
name. UniData uses the value for rcvMsgName in the subsequent call to<br />
the amSendResponse function. [IN]<br />
senderName The name of a special type of sender service known as a response sender,<br />
to which the response message will be sent. This sender name must not<br />
be defined in the repository. If you do not specify a name, UniData uses<br />
the system default response sender service. [IN]<br />
reasonCode Holds an AMI reason code when the function returns a status indicating<br />
an AMI warning or an AMI error occurred. You can use the AMI reason<br />
code to obtain more information about the cause of the warning or error.<br />
See the MQSeries Application Messaging Interface manual for a list of<br />
AMI reason codes and their descriptions. [OUT]<br />
The following table describes the status of each return code.<br />
Return Code Status<br />
amReceiveRequest Parameters (continued)<br />
0 – AMCC_SUCCESS Function completed successfully.<br />
1 – AMCC_WARNING A warning was returned from AMI. The reasonCode output<br />
parameter contains an AMI reason code with further details<br />
about the warning.<br />
2 – AMCC_FAILED An error was returned from AMI. The reason code output<br />
parameter contains an AMI reason code with further details<br />
about the error.<br />
Other A non-AMI error occurred.<br />
amReceiveRequest Return Codes<br />
amReceiveRequest 1-93
amSendMsg<br />
Syntax<br />
1-94 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
amSendMsg(hSession, senderName, policyName, data, sndMsgName, reasonCode)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The amSendMsg function sends a datagram (send and forget) message.<br />
For detailed information about this function, see <strong>UniBasic</strong> Extensions.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
hSession The session handle returned by the amInitialize function. [IN]<br />
senderName The name of a sender service. If you specify ““(null), UniData uses the<br />
system default receiver name. [IN]<br />
policyName The name of a policy. If you specify ““(null), UniData uses the system<br />
default policy name. [IN]<br />
data The message data to be sent. [IN]<br />
sndMsgName The name of a message object for the message being sent. If you specify<br />
““(null), UniData uses the system default policy name. [IN]<br />
reasonCode Holds an AMI reason code when the function returns a status indicating<br />
an AMI warning or an AMI error occurred. You can use the AMI reason<br />
code to obtain more information about the cause of the warning or error.<br />
See the MQSeries Application Messaging Interface manual for a list of<br />
AMI reason codes and their descriptions. [OUT]<br />
amSendMsg Parameters
The following table describes the status of each return code.<br />
Return Code Status<br />
0 – AMCC_SUCCESS Function completed successfully.<br />
1 – AMCC_WARNING A warning was returned from AMI. The reasonCode output<br />
parameter contains an AMI reason code with further details<br />
about the warning.<br />
2 – AMCC_FAILED An error was returned from AMI. The reasonCode output<br />
parameter contains an AMI reason code with further details<br />
about the error.<br />
Other A non-AMI error occurred.<br />
amSendMsg Return Codes<br />
amSendMsg 1-95
amSendRequest<br />
Syntax<br />
amSendRequest(hSession, senderName, policyName, data, sndMsgName,<br />
reasonCode)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
1-96 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
The amSendRequest function sends a request message.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
hSession The session handle returned by the amInitialize function. [IN]<br />
senderName The name of a sender service. If you specify ““(null), UniData uses the<br />
system default sender name. [IN]<br />
policyName The name of a policy. If you specify ““(null), UniData uses the system<br />
default policy name. [IN]<br />
responseName The name of the receiver service to which the response to this send<br />
request should be sent. Specify ““(null) if you do not require a response.<br />
[IN]<br />
dataLen The length of the message data, in bytes. [IN]<br />
amSendRequest Parameters
Parameter Description<br />
data The message data to be sent. [IN]<br />
sndMsgName The name of a message object for the message being sent. If you specify<br />
““(null), UniData uses the system default message name (constant<br />
AMSD_SND_MSG). [IN]<br />
reasonCode Holds an AMI reason code when the functions returns a status indicating<br />
an AMI warning or an AMI error occurred. You can use the AMI reason<br />
code to obtain more information about the cause of the warning or error.<br />
See the MQSeries Application Messaging Interface manual for a list of<br />
AMI reason codes and their descriptions. [OUT]<br />
The following table describes the status of each return code.<br />
Return Code Status<br />
amSendRequest Parameters (continued)<br />
0 – AMCC_SUCCESS Function completed successfully.<br />
1 – AMCC_WARNING A warning was returned from AMI. The reasonCode output<br />
parameter contains an AMI reason code with further details<br />
about the warning.<br />
2 – AMCC_FAILED An error was returned from AMI. The reasonCode output<br />
parameter contains an AMI reason code with further details<br />
about the error.<br />
Other A non-AMI error occurred.<br />
amSendRequest Return Codes<br />
amSendRequest 1-97
amSendResponse<br />
Syntax<br />
amSendResponse(hSession, senderName, policyName, rcvMsgName, data, sndMsgName,<br />
reasonCode)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
1-98 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
The amSendResponse function sends a request message.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
hSession The session handle returned by amInitialize. [IN]<br />
senderName The name of the sender service. It must be set to the senderName you<br />
specify for the amReceiveRequest function. [IN]<br />
policyName The name of a policy. If you specify ““(null), UniData uses the default<br />
policy name.<br />
rcvMsgName The name of the received message to which this message is a response.<br />
It must be set to the rcvMsgName you specify for the amReceiveRequest<br />
function. [IN]<br />
dataLen The length of the message data, in bytes. [IN]<br />
amSendResponse Parameters
Parameter Description<br />
data The message data to be sent. [IN]<br />
sndMsgName The name of a message object for the message being sent. If you specify<br />
““(null), UniData uses the system default message name (constant<br />
AMSD_SND_MSG).<br />
reasonCode Holds an AMI reason code when the function returns a status indicating<br />
an AMI warning or an AMI error occurred. You can use the AMI reason<br />
code to obtain more information about the cause of the warning or error.<br />
[OUT]<br />
The following table describes the status of each return code.<br />
Return Code Status<br />
amSendResponse Parameters (continued)<br />
0 – AMCC_SUCCESS Function completed successfully.<br />
1 – AMCC_WARNING A warning was returned from AMI. The reasonCode output<br />
parameter contains an AMI reason code with further details<br />
about the warning.<br />
2 – AMCC_FAILED An error was returned from AMI. The reasonCode output<br />
parameter contains an AMI reason code with further details<br />
about the error.<br />
Other A non-AMI error occurred.<br />
amSendResponse Return Codes<br />
amSendResponse 1-99
amTerminate<br />
Syntax<br />
amTerminate(hSession, policyName, reasonCode)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The amTerminate function closes a session.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-100 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
hSession The session handle returned by amInitialize. [IN/OUT]<br />
policyName The name of a policy. If you specify ““(null), UniData uses the system<br />
default policy name. [IN]<br />
reasonCode Holds an AMI reason code when the function returns a status indicating<br />
an AMI warning or an AMI error occurred. You can use the AMI reason<br />
code to obtain more information about the cause of the warning or error.<br />
See the MQSeries Application Messaging Interface manual for a list of<br />
AMI reason codes and their descriptions.<br />
amTerminate Parameters
The following table describes the status of each return code.<br />
Return Code Status<br />
0 – AMCC_SUCCESS Function completed successfully.<br />
1– AMCC_WARNING A warning was returned from AMI. The reasonCode output<br />
parameter contains an AMI reason code with further details<br />
about the warning.<br />
2 – AMCC_FAILED An error was returned from AMI. The reasoncode output<br />
parameter contains an AMI reason code with further details<br />
about the error.<br />
Other A non-AMI error occurred.<br />
Return Code Status<br />
amTerminate 1-101
analyzeCertificate<br />
Syntax<br />
analyzeCertificate(cert, format, result)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The analyzeCertficate function decodes a certificate and inputs plain text in the<br />
result parameter. The result parameter then contains such information as the subject<br />
name, location, institute, issuer, public key, other extensions, and the signature of the<br />
issuer.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Paramet<br />
er Description<br />
1-102 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
cert A string containing the certificate file name.<br />
format 1 – PEM<br />
2 – DER<br />
result A dynamic array containing parsed cert data, in ASCII format.<br />
analyzeCertificate Parameters
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success<br />
1 Failed to open cert file<br />
2 Invalid format<br />
3 Unrecognized cert<br />
4 Other errors<br />
analyzeCertificate Return Codes<br />
analyzeCertificate 1-103
AND<br />
Syntax<br />
expr1 AND expr2<br />
Synonym<br />
&<br />
Description<br />
The AND Boolean operator combines a set of expressions. If expr1 or expr2 is false,<br />
the combined expression is false. Both expressions must be true for a true condition.<br />
Example<br />
In the following example, the program segment combines two expressions (X < Y)<br />
and (Y < Z). Both expressions must be true for the program to call subroutine<br />
RETRY.<br />
1-104 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
X = 1 ; Y = 2 ; z = 3<br />
IF (X < Y) AND (Y < Z) THEN GOSUB RETRY:<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
NOT, OR
ASCII<br />
Syntax<br />
ASCII(expr)<br />
Description<br />
The <strong>UniBasic</strong> ASCII (American Standard Code for Information Interchange)<br />
function converts a string in EBCDIC (Extended Binary Coded Decimal Information<br />
Code) format to the corresponding ASCII values. Even though the ASCII function<br />
works with data in any format, its results are meaningful only when it is applied to<br />
EBCDIC data.<br />
For more information about ASCII character codes, see Appendix A, “ASCII<br />
Character Codes.”<br />
Note: Use the <strong>UniBasic</strong> commands CHAR and SEQ to convert between ASCII<br />
character and decimal value.<br />
Example<br />
In the following example, the program statement converts the EBCDIC data in the<br />
variable E.VAR to ASCII format and assigns the value to the variable A.VAR:<br />
A.VAR=ASCII(E.VAR)<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CHAR, CHARS, EBCDIC, SEQ<br />
ASCII 1-105
ASIN<br />
Syntax<br />
ASIN(expr)<br />
Description<br />
The <strong>UniBasic</strong> ASIN function returns the trigonometric arc sine (inverse sine) of a<br />
numeric expression. expr must be a value between -1 and +1. ASIN returns a value<br />
expressed as the degree of the arc sine of the input, which ranges from -90 to +90. If<br />
expr evaluates to a value outside the range of -1 and +1, the UniData displays an error<br />
message and returns 0 as the result.<br />
With null value handling on, the result of any mathematical operation, function, or<br />
comparison involving the null value is the null value. Therefore, ASIN returns the<br />
null value when expr is the null value.<br />
Examples<br />
In the following example, the program statement assigns 30, the arc sine of 0.5, to<br />
ARCSIN:<br />
ARCSIN = ASIN(0.5)<br />
In the next example, the program statement prints -30, the arc sine of -0.5:<br />
PRINT ASIN(-0.5)<br />
Related <strong>Commands</strong><br />
ACOS, ATAN, COS, SIN, TAN<br />
1-106 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
ASSIGN<br />
Syntax<br />
ASSIGN expr TO SYSTEM(option)<br />
Description<br />
The <strong>UniBasic</strong> ASSIGN command redefines some system-level parameters. The<br />
value in option changes to the value you specify with expr.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
For parameters 2, 3, and 5, expr must be numeric. For parameter 7, expr must be a<br />
string representing a valid terminal type and must be enclosed in quotation marks.<br />
Example<br />
Parameter Description<br />
2 Page width<br />
3 Page length<br />
5 Page number<br />
7 Terminal type<br />
ASSIGN Parameters<br />
In the following example, the program resets the page width to 40, page length to 30,<br />
and terminal type to vt100:<br />
ASSIGN 40 TO SYSTEM(2)<br />
ASSIGN 30 TO SYSTEM(3)<br />
ASSIGN "vt100" TO SYSTEM(7)<br />
ASIN 1-107
Related Command<br />
UniData<br />
TERM – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
1-108 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
ATAN<br />
Syntax<br />
ATAN(expr)<br />
Description<br />
The <strong>UniBasic</strong> ATAN function returns the trigonometric arc tangent (inverse tangent)<br />
of a numeric expression expr in degrees.<br />
With null value handling on, the result of any mathematical operation, function, or<br />
comparison involving the null value is the null value. Therefore, ATAN returns the<br />
null value when expr is the null value.<br />
Example<br />
In the following example, the program segment prints the arc tangent of the variable<br />
VAL. VAL is set to 45.<br />
VAL = 1<br />
PRINT ATAN(VAL)<br />
Related <strong>Commands</strong><br />
ACOS, ASIN, COS, SIN, TAN<br />
ATAN 1-109
BITAND<br />
Syntax<br />
BITAND(num.expr1,num.expr2)<br />
Description<br />
The <strong>UniBasic</strong> BITAND function performs the bit-wise AND logical function on the<br />
arguments num.expr1 and num.expr2.<br />
With null value handling on, the result of any mathematical operation, function, or<br />
comparison involving the null value is the null value. BITAND returns the null value<br />
when num.expr1 or num.expr2 is the null value.<br />
The following table shows the results of the BITAND function on various sets of<br />
input.<br />
Example<br />
In the following example, the program statement prints a 0:<br />
PRINT BITAND(0,1)<br />
1-107 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
num.expr1<br />
num.expr<br />
2 Result<br />
0 0 0<br />
0 1 0<br />
1 0 0<br />
1 1 1<br />
3 9 1<br />
23 87 23<br />
BITAND Function Operation Results
BITNOT<br />
Syntax<br />
BITNOT(num.expr)<br />
Description<br />
The <strong>UniBasic</strong> BITNOT function performs the bit-wise NOT logical function on the<br />
argument num.expr.<br />
With null value handling on, the result of any mathematical operation, function, or<br />
comparison involving the null value is the null value. Therefore, BITNOT returns the<br />
null value when num.expr is the null value.<br />
The following table shows the results of the BITNOT function on the valid input: 0<br />
and 1.<br />
Example<br />
In the following example, the program statement prints 1:<br />
PRINT BITNOT(0)<br />
num.expr Results<br />
0 1<br />
1 0<br />
BITNOT Function Operation Results<br />
BITNOT 1-108
BITOR<br />
Syntax<br />
BITOR(num.expr1,num.expr2)<br />
Description<br />
The <strong>UniBasic</strong> BITOR function performs the bit-wise OR logical function on the<br />
arguments num.expr1 and num.expr2.<br />
With null value handling on, the result of any mathematical operation, function, or<br />
comparison involving the null value is the null value. Therefore, BITOR returns the<br />
null value when num.expr1 or num.expr2 is the null value.<br />
The following table shows the results of the BITOR function on various sets of input.<br />
Example<br />
In the following example, the program statement prints a 1:<br />
PRINT BITOR(0,1)<br />
1-109 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
num.expr1 num.expr2 Result<br />
0 0 0<br />
0 1 1<br />
1 0 1<br />
1 1 1<br />
3 9 11<br />
23 87 87<br />
BITOR Function Operation Results
BITXOR<br />
Syntax<br />
BITXOR(num.expr1,num.expr2)<br />
Description<br />
The <strong>UniBasic</strong> BITXOR function performs the bit-wise XOR logical function on the<br />
arguments num.expr1 and num.expr2.<br />
With null value handling on, the result of any mathematical operation, function, or<br />
comparison involving the null value is the null value. Therefore, BITXOR returns the<br />
null value when num.expr1 or num.expr2 is the null value.<br />
The following table shows the results of the BITXOR function on various sets of<br />
input.<br />
Example<br />
In the following example, the program statement prints 1:<br />
PRINT BITXOR(0,1)<br />
num.expr1 num.expr2 Result<br />
0 0 0<br />
0 1 1<br />
1 0 1<br />
1 1 0<br />
3 9 10<br />
23 87 64<br />
BITXOR Function Operation Results<br />
BITXOR 1-110
BPIOCP<br />
Syntax<br />
BPIOCP<br />
Description<br />
The <strong>UniBasic</strong> BPIOCP command turns automatic pagination on. With pagination<br />
on, printing to a terminal (without using cursor addressing) pauses at the bottom of<br />
each screen display. The user is prompted before the next screen is displayed as<br />
follows:<br />
1-111 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Enter to continue...<br />
Three user responses are valid for this prompt,which are listed in the following table.<br />
Input Description<br />
ENTER Pressing ENTER displays another screen of data.<br />
N Continues display and disables automatic pagination (no pause at bottom of<br />
each screen display).<br />
Q Quits the current process and returns to the previous process.<br />
BPIOCP User Responses<br />
Example<br />
The page control process is automatically disabled if the @ function is executed. For<br />
example, all of the following statements disable terminal pagination:<br />
PRINT @(1)<br />
CRT @(2)<br />
VARIABLE = @(3)<br />
With page control disabled, UniData assumes that the program will control the<br />
paging of data. To turn automatic pagination on from within a <strong>UniBasic</strong> program, use<br />
BPIOCP.
An example is provided with the BPIOCPN command.<br />
Related Command<br />
<strong>UniBasic</strong><br />
BPIOCPN<br />
BPIOCP 1-112
BPIOCPN<br />
Syntax<br />
BPIOCPN<br />
Description<br />
The <strong>UniBasic</strong> BPIOCPN command turns off automatic pagination. With pagination<br />
off, printing to a terminal does not pause at the bottom of each screen display.<br />
Example<br />
In the following example, the program prints the first 60 records of the INVENTORY<br />
file with pagination disabled by @(0,0). Then the BPIOCP command enables<br />
automatic pagination. The next 23 records are printed, and the user is prompted to<br />
press ENTER to continue. At this point, the user also can enter N to disable<br />
pagination.<br />
1-113 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
After all 60 records have printed, BPIOCPN executes. A prompt displays this information.<br />
When the user presses ENTER at the prompt, 60 records print with<br />
pagination off.<br />
JUNK = @(0,0) ; * Disable pagination<br />
OPEN 'INVENTORY' READONLY TO INVENTORY.FILE ELSE NULL<br />
SELECT INVENTORY.FILE<br />
PRINT "Printing after terminal addressing: @(0,0)"<br />
FOR X = 1 TO 60<br />
READNEXT REC THEN PRINT REC<br />
NEXT X<br />
PRINT "Sixty rec ids printed."<br />
PRINT "BPIOCP executing."<br />
BPIOCP ; *Enable pagination<br />
FOR X = 1 TO 60<br />
READNEXT REC THEN PRINT X:" ":REC<br />
NEXT X<br />
PRINT "Sixty rec ids printed."<br />
PRINT "BPIOCPN executing."<br />
INPUT var<br />
BPIOCPN ; *Disable pagination<br />
FOR X = 1 TO 60<br />
READNEXT REC THEN PRINT X:" ":REC<br />
NEXT X<br />
PRINT "Sixty rec ids printed."<br />
CLEARSELECT<br />
END<br />
Related Command<br />
<strong>UniBasic</strong><br />
BPIOCP<br />
BPIOCPN 1-114
BREAK<br />
Syntax<br />
BREAK [KEY] {ON | OFF | expr}<br />
Description<br />
The <strong>UniBasic</strong> BREAK command enables or disables the interrupt key to exit a<br />
program to the ‘!’ debugger prompt and displays the current program line number.<br />
The program must have been compiled and run with debugger options. For instructions,<br />
see the ECL BASIC and RUN commands in the UniData <strong>Commands</strong><br />
<strong>Reference</strong>.<br />
The system increments a counter each time BREAK OFF executes and decrements<br />
that same counter when BREAK ON executes. Until the system counter is less than<br />
or equal to zero (more BREAK ON statements executed than BREAK OFF statements),<br />
the interrupt key is not operational. This status continues even if you exit a<br />
program with the interrupt key disabled.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-115 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
KEY KEY is optional and has no effect. It is included for backward compatibility<br />
only.<br />
ON Enables the terminal interrupt key to stop the execution of a <strong>UniBasic</strong><br />
program and enter the <strong>UniBasic</strong> debugger.<br />
OFF Disables the interrupt key. Pressing the interrupt key has no effect on program<br />
execution.<br />
expr Enables the terminal interrupt key (to stop the execution of a <strong>UniBasic</strong><br />
program and enter the <strong>UniBasic</strong> debugger) if the expression is valid.<br />
BREAK Parameters
Examples<br />
In the following example, the program statement decrements the system counter and<br />
enables the interrupt key if the break counter is less than or equal to zero:<br />
BREAK ON<br />
In the next example, a numeric expression determines whether to enable the interrupt<br />
key. If X is greater than 0, UniData enables the interrupt key.<br />
BREAK X > 0<br />
Related Command<br />
UniData<br />
PTERM – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
BREAK 1-116
BYTELEN<br />
Syntax<br />
BYTELEN (string)<br />
Description<br />
The <strong>UniBasic</strong> BYTELEN function returns the number of bytes required to store a<br />
character. From one to four bytes could be required.<br />
Example<br />
The following figure illustrates a string that shows below each “character” the<br />
number of bytes required to store that character. The string contains eight bytes.<br />
Therefore, BYTELEN would return 8 for this string.<br />
Number<br />
of bytes<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CHARLEN, DISPLAYWIDTH, ISMB, LEN, MBLEN<br />
1-117 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
2 3 1 2
CALCULATE<br />
Syntax<br />
CALCULATE(dictionary.item)<br />
{dictionary.item}<br />
Description<br />
The <strong>UniBasic</strong> CALCULATE or {} (braces) function executes a virtual attribute. The<br />
dictionary.item must be a valid virtual attribute within the dictionary previously<br />
opened to the @DICT variable with an OPEN statement.<br />
Note: Before you use this function, you must compile the dictionary of the file you will<br />
open to the @DICT variable by using the ECL COMPILE.DICT or CD command.<br />
In the CALCULATE() form, the dictionary.item can be a quoted string or a <strong>UniBasic</strong><br />
variable. The expression uses the data from the current @RECORD during the evaluation<br />
process.<br />
In the {} form, the dictionary.item must be the literal dictionary name with no<br />
quotation marks.<br />
You must open a dictionary to @DICT and read the data record into @RECORD for<br />
the function to work properly.<br />
If these functions are successful, they update the values in @CONV, @FORMAT,<br />
and @HEADER. You can then use these @ variables in other <strong>UniBasic</strong> functions,<br />
such as ICONV, OCONV, and FMT. For more information about @ variables, see<br />
Appendix B, “<strong>UniBasic</strong>@variables.”<br />
CALCULATE 1-118
Example<br />
In the following example, the program segment opens the ORDERS file to the<br />
variable ORDER.FILE and the dictionary of the ORDERS file to the special @DICT<br />
variable. After selecting the ORDERS file, the program reads the value of each<br />
record ID into @ID, reads the value of the order record into @RECORD, then uses<br />
the {} (braces) function to evaluate the order balance (storing the total in<br />
TOTAL.DUE). The braces function updates the @CONV and @FORMAT variables,<br />
which are used to print the total with the correct format.<br />
1-119 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
OPEN 'ORDERS' TO ORDER.FILE ELSE<br />
STOP 'NO ORDER FILE'<br />
END<br />
OPEN 'DICT','ORDERS' TO @DICT ELSE<br />
STOP 'NO DICTIONARY FOR ORDERS FILE'<br />
END<br />
TOTAL.DUE = 0<br />
SELECT ORDER.FILE<br />
MORE = 1<br />
LOOP<br />
READNEXT @ID ELSE MORE = 0<br />
UNTIL NOT(MORE) DO<br />
READ @RECORD FROM ORDER.FILE,@ID ELSE<br />
@RECORD = ''<br />
END<br />
TOTAL.DUE += {GRAND_TOTAL}<br />
REPEAT<br />
TOTAL.DUE = OCONV(TOTAL.DUE,@CONV)<br />
PRINT "Total Accounts Receivable":FMT(TOTAL.DUE,@FORMAT)<br />
CLEARSELECT<br />
END<br />
Related Command<br />
<strong>UniBasic</strong><br />
ITYPE
CALL<br />
Syntax<br />
CALL *sub.name [[(argument1[,argument2][MAT array1 [,MAT array2]]...)]<br />
[ASYNC | SYNC] [ON connection]<br />
CALL @var [[(argument1[,argument2][MAT array1 [,MAT array2]]...)]<br />
[ASYNC | SYNC] [ON connection]<br />
CALL sub.name [[(argument1[,argument2][MAT array1 [,MAT array2]]...)]<br />
[ASYNC | SYNC] [ON connection]<br />
Description<br />
The <strong>UniBasic</strong> CALL command transfers program control to an external subroutine.<br />
The first form of the syntax calls a globally cataloged subroutine.<br />
The second form of the syntax calls a subroutine named in a variable.<br />
The third form of the syntax calls a subroutine directly.<br />
The called program or subroutine must contain a RETURN statement, which returns<br />
control to the calling program or subroutine.<br />
You can nest subroutines up to 1,024 levels deep.<br />
Note: You must catalog subroutines before using them in a <strong>UniBasic</strong> CALL statement.<br />
You must separate individual arguments by commas and enclose the set of arguments<br />
within parentheses. You can place arguments on multiple lines. Each continued line<br />
must end with a comma. Regardless of placement, the number and type of arguments<br />
in the CALL statement must match the number and type of arguments in the<br />
SUBROUTINE statement within the external subroutine. Arrays and singlevalued<br />
arguments can be passed in the same CALL statement.<br />
Tip: You can also pass variables through named and unnamed common areas.<br />
Variables stored in common area(s) are accessible to both calling and called<br />
programs without being passed as arguments. You cannot use the same variable<br />
name in both a SUBROUTINE argument and a common variables list.<br />
CALL 1-120
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Examples<br />
Note: A sample program that calls an external subroutine is provided in “Appendix<br />
A, Sample Program” in Developing <strong>UniBasic</strong> Applications.<br />
In the following example, the program statement calls the subroutine VID, passing<br />
the variables TITLE and ST:<br />
CALL VID(TITLE,ST)<br />
In the next example, the program segment calls the subroutine MONTHTOTAL by<br />
calling @var VID (see CALL Parameter table above), which holds the string<br />
“MONTHTOTAL”. Note that VID is defined before it is called.<br />
VID = "MONTHTOTAL"<br />
CALL @VID(TOTAL)<br />
1-121 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
sub.name The name of the called subroutine.<br />
@var A variable that contains the name of the subroutine to call.<br />
argument1, argument2 Any valid argument passed to the subroutine.<br />
MAT array1,<br />
MAT array2<br />
Any valid array passed to the subroutine.<br />
ASYNC | SYNC UniData no longer supports this parameter, but it remains for<br />
syntax compatibility.<br />
ON connection UniData no longer supports this parameter, but it remains for<br />
syntax compatibility.<br />
CALL Parameters
In the next example, the program segment calls the contents of cell (1,12) in the array<br />
cells, thus calling the subroutine RECEIPTS with the argument “MON1_12”. In the<br />
use of @matrices, you can select the array element by the use of an index (a variable<br />
within the dimensions of the array).<br />
"SUBROUTINE MONTHTOTAL(TOTAL)"<br />
SALES(1,12) = "RECEIPTS"<br />
CALL @SALES(1,12)(MON1_12)<br />
In the next example, the program statement calls the globally cataloged subroutine<br />
PROMPT.ROUTINE:<br />
CALL *PROMPT.ROUTINE<br />
In the following example, the CALL statement is invalid because subroutine SUBS,<br />
which is shown after this example, has a different number of arguments than the<br />
CALL statement. Called and calling programs must pass the same number of<br />
parameters.<br />
CALL SUBS(X,Y,Z)<br />
The subroutine SUBS, which the program in the previous example calls, follows:<br />
SUBROUTINE SUBS(X)<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CHAIN, COMMON, ENTER, GOSUB, RETURN, SUBROUTINE<br />
CALL 1-122
CALLC<br />
Syntax<br />
CALLC c.sub.name [(argument1[,argument2]...)]<br />
CALLC @var [(argument1[,argument2]...)]<br />
Description<br />
The <strong>UniBasic</strong> CALLC command transfers program control to an external function<br />
(c.sub.name). The second form of the syntax calls a function whose name is stored in<br />
a <strong>UniBasic</strong> variable (@var). The program could pass back return values in variables.<br />
CALLC arguments can be simple variables or complex expressions, but not arrays.<br />
CALLC can be used as a command or function.<br />
Calling a C Program in UNIX<br />
You must link the C program to UniData before calling it from a <strong>UniBasic</strong> program.<br />
Perform the following procedure to prepare UniData for CALLC:<br />
1-123 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
1. Write and compile the C program.<br />
2. Define the C program call interface.<br />
3. Build the runtime version of UniData (containing the linked C program).<br />
4. Write, compile, and execute the <strong>UniBasic</strong> program.<br />
For more information about this procedure, see Developing <strong>UniBasic</strong> Applications.<br />
Calling a Function on Windows Platforms<br />
The CALLC implementation in UniData for Windows Platforms uses the Microsoft<br />
Windows Dynamic Link Library (DLL) facility. This facility allows separate pieces<br />
of code to call one another without being permanently bound together. Linking<br />
between the separate pieces is accomplished at runtime (rather than compile time)<br />
through a DLL interface.
For CALLC, developers create a DLL and then call that DLL from UniData. E-type<br />
VOC entries for each function called from a DLL communicate interface information<br />
to UniData. For additional information and examples, see Administering UniData on<br />
UNIX or Administering UniData on Windows Platforms.<br />
Examples<br />
In the following example, the called subroutine draws a circle with its center at the<br />
twelfth row and twelfth column and a radius of 3:<br />
RADIUS = 3<br />
CENTER = "12,12"<br />
CALLC DRAW.CIRCLE(RADIUS,CENTER)<br />
In the next example, the subroutine name is stored in the variable SUB.NAME, and<br />
it is called indirectly:<br />
SUB.NAME = DRAW.CIRCLE<br />
CALLC @SUB.NAME(RADIUS,CENTER)<br />
In the next example, CALLC is used as a function, assigning the return value of the<br />
subroutine PROGRAM.STATUS in the variable RESULT:<br />
RESULT = CALLC PROGRAM.STATUS<br />
Related Command<br />
<strong>UniBasic</strong><br />
CALL<br />
CALLC 1-124
CASE<br />
Syntax<br />
BEGIN CASE<br />
CASE expression1<br />
statements1<br />
[ CASE expression2<br />
statements2]<br />
.<br />
. .<br />
. .<br />
[ CASE 1<br />
statements]<br />
END CASE<br />
Description<br />
The <strong>UniBasic</strong> CASE command creates a series of branches based on conditional<br />
expressions. Case structures must always begin with BEGIN CASE and terminate<br />
with END CASE.<br />
The number of CASE commands within BEGIN CASE and END CASE is unlimited.<br />
The number of statements within each CASE branch is unlimited. CASE statements<br />
can be nested.<br />
The CASE command tests each of the expressions in sequence. If an expression<br />
evaluates as true, the system executes the statements that follow it. When one of the<br />
CASE expressions is found to be true, the system does not test any subsequent<br />
expressions. If none of the conditions is true, the system does not execute any<br />
statements.<br />
With null value handling turned on, a test of the null value returns a negative result.<br />
For an overview of how the null value affects <strong>UniBasic</strong>, see Developing <strong>UniBasic</strong><br />
Applications.<br />
1-125 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
CASE expression1 Any <strong>UniBasic</strong> conditional expression. If the expression is true,<br />
execute statements1.<br />
statements1 The <strong>UniBasic</strong> statements to execute if expression1 is true.<br />
CASE expression2 Any <strong>UniBasic</strong> conditional expression. If the expression is true,<br />
execute statements2.<br />
statements2 The <strong>UniBasic</strong> statements to execute if expression2 is true.<br />
CASE 1<br />
statements<br />
Examples<br />
Note: An example of the use of CASE is included in the sample program in “Appendix<br />
A - Sample Program” of Developing <strong>UniBasic</strong> Applications.<br />
In the following example, if the variable DUE.DATE is greater than the system date,<br />
the program calls the subroutine PRINT.OVERDUE. (Notice that both dates are in<br />
internal format.) If DUE.DATE is less than or equal to the system date, the program<br />
prints the message “Okay” on the display terminal.<br />
BEGIN CASE<br />
CASE DUE.DATE > DATE()<br />
GOSUB PRINT.OVERDUE:<br />
CASE DUE.DATE
In the next example, the program segment transfers program control to either<br />
“CHARGE:” or “CHECK:” based on the value of the variable VAL. If VAL is not 1<br />
or 2, the program executes the statements after the CASE 1 clause.<br />
1-127 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
PRINT "Option number?" ; INPUT VAL<br />
BEGIN CASE<br />
CASE VAL = 1<br />
GOSUB CHARGE:<br />
CASE VAL = 2<br />
GOSUB CHECK:<br />
CASE 1<br />
PRINT "Answer 1 or 2 only"<br />
END CASE<br />
In the following example, the statement is invalid because the evaluation expression<br />
appears on the BEGIN CASE line:<br />
BEGIN CASE VAR 1<br />
In the next example, the statement is invalid because BEGIN CASE must appear<br />
before the first CASE statement:<br />
CASE VAL<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
IF/THEN/ELSE, LOOP/REPEAT
CAT<br />
Syntax<br />
expr1 CAT expr2<br />
Synonym<br />
:<br />
Description<br />
The <strong>UniBasic</strong> CAT arithmetic operator concatenates expr1 to expr2.<br />
Examples<br />
In the following example, the program segment concatenates A to B, and then prints<br />
123456:<br />
A = "123"<br />
B = "456"<br />
C = A CAT B<br />
PRINT C<br />
The following program segment compiles and runs only with null value handling on.<br />
The program concatenates two strings, one ending with the null value, and another<br />
beginning with ‘123.’ This produces the string @AM@NULL123@AM456. The called<br />
subroutine, print.setup, converts UniData delimiters and the null value to printable<br />
characters. (This subroutine is printed in the entry for “CHANGE” on page 133.)<br />
PRT.STG = ''<br />
Z=123:@AM:456<br />
Y=@AM:@NULL<br />
STG = Y CAT Z<br />
CALL print.setup(STG,PRT.STG)<br />
PRINT PRT.STG<br />
CAT 1-128
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CATS, SPLICE<br />
1-129 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
CATS<br />
Syntax<br />
CATS(array1,array2)<br />
Description<br />
The <strong>UniBasic</strong> CATS function concatenates array1 to array2. Each element of array2<br />
is concatenated to its corresponding element in array1.<br />
Example<br />
In the following example, the program segment concatenates array A to array B and<br />
prints 300A}400B}401C}402D}100E:<br />
A = 300:@VM:400:@VM:401:@VM:402:@VM:100<br />
B = "A":@VM:"B":@VM:"C":@VM:"D":@VM:"E"<br />
C = CATS(A,B)<br />
PRINT C<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CAT, SPLICE<br />
CATS 1-130
CHAIN<br />
Syntax<br />
CHAIN "str.expr"<br />
Description<br />
The <strong>UniBasic</strong> CHAIN command terminates the current <strong>UniBasic</strong> program and<br />
executes the ECL command str.expr. CHAIN performs a function similar to the<br />
EXECUTE statement, except that control is not returned to the original program.<br />
UniData treats str.expr as a command you type at the ECL colon (:) prompt. If str.exp<br />
executes a <strong>UniBasic</strong> program, variables could be passed through common areas, but<br />
all other variables are reinitialized when the new program begins.<br />
Tip: Use this command to avoid system-imposed limitations on program size by<br />
sequentially running several smaller programs rather than one large program.<br />
UDT.OPTIONS 6 and 40 affect the operation of the CHAIN command. For more<br />
information, see the UDT.OPTIONS <strong>Commands</strong> <strong>Reference</strong>.<br />
Examples<br />
In the following example, the program terminates and UniData executes the ECL<br />
command “RUN BP FORMLET”. FORMLET is a compiled <strong>UniBasic</strong> program.<br />
UniData does not return control to the original program when FORMLET terminates.<br />
CHAIN "RUN BP FORMLET"<br />
In the next example, the current program terminates and the paragraph<br />
RUN.ACCOUNTS executes:<br />
CHAIN "RUN.ACCOUNTS"<br />
1-131 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CALL, COMMON, ENTER, GOSUB<br />
CHAIN 1-132
CHANGE<br />
Syntax<br />
CHANGE(string, old.substring, new.substring)<br />
Description<br />
The <strong>UniBasic</strong> CHANGE function replaces all occurrences of old.substring in string<br />
with new.substring. If old.substring is an empty string, the system does not change<br />
string. CHANGE supports multibyte languages.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Examples<br />
In the following example, the program segment prints “<strong>UniBasic</strong> Release 6.1”:<br />
1-133 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
string Specifies the original text string.<br />
old.substring Specifies the text string to replace with new.substring.<br />
new.substring Specifies the text string with which to replace old.substring.<br />
CHANGE Parameters<br />
STRA = "<strong>UniBasic</strong> Release 6.1"<br />
OLDRELEASE = "6.0"<br />
NEWRELEASE = "6.1"<br />
STRB = CHANGE(STRA, OLDRELEASE,NEWRELEASE)<br />
PRINT STRB<br />
In the next example, the program segment prints “NEW STRC = A23A24A25A26”:<br />
STRC = "123124125126"<br />
PRINT "NEW STRC =":CHANGE(STRC,"1","A")
The following subroutine converts UniData delimiters and the null value to printable<br />
characters. (This subroutine compiles only with null value handling turned on.)<br />
SUBROUTINE PRINT.SETUP(STG, PRT.STG)<br />
PRT.STG = CHANGE(STG, @NULL, "@NULL")<br />
PRT.STG = CHANGE(PRT.STG, @AM, "@AM")<br />
PRT.STG = CHANGE(PRT.STG, @VM, "@VM")<br />
RETURN<br />
CHANGE 1-134
CHAR<br />
Syntax<br />
CHAR(expr)<br />
Description<br />
The <strong>UniBasic</strong> CHAR function changes a numeric expression to its ASCII (American<br />
Standard Code for Information Interchange) character string equivalent. expr can be<br />
a constant, variable, numeric function, or any combination of these. expr must<br />
evaluate to a positive number from 0 to 255 (the range of ASCII character codes).<br />
CHAR supports multibyte languages.<br />
Not all ASCII codes are printable. Some represent terminal controls, and others are<br />
reserved for special uses. For more information about ASCII character codes, see<br />
Appendix A, “ASCII Character Codes.”<br />
Tip: Use @variables to represent UniData delimiters and the null value. IBM<br />
recommends that you not use the <strong>UniBasic</strong> functions CHAR or CHARS to insert these<br />
variables because the ASCII code that represents it varies with language group.<br />
Examples<br />
In the following example, the program segment assigns the ASCII string equivalent<br />
of the numeric expression VAL to the variable VSTRING. The final numeric value of<br />
the argument is 90, so VSTRING becomes Z, the character equivalent of 90 in ASCII<br />
code.<br />
VAL=90<br />
VSTRING=CHAR(VAL)<br />
In the next example, the program statement sends the ASCII code 12 to the current<br />
print device. In ASCII, this is a form feed.<br />
PRINT CHAR(12)<br />
1-135 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
ASCII, CHARS, EBCDIC, SEQ<br />
CHAR 1-136
CHARLEN<br />
Syntax<br />
CHARLEN (string)<br />
Description<br />
The <strong>UniBasic</strong> CHARLEN function returns the number of characters in a character<br />
string. A multibyte character could require from one to four bytes to encode.<br />
Example<br />
The following figure illustrates a string of four multibyte characters. CHARLEN<br />
would return 4 for this string.<br />
Number<br />
of bytes<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
BYTELEN, DISPLAYWIDTH, ISMB, LEN, MBLEN<br />
1-137 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
2 3 1 2
CHARS<br />
Syntax<br />
CHARS(array)<br />
Description<br />
The <strong>UniBasic</strong> CHARS function changes a numeric value in array to its ASCII<br />
(American Standard Code for Information Interchange) character string equivalent.<br />
array elements can contain a constant, variable, numeric function, or any combination<br />
of these. array elements must evaluate to a positive number 0–255 (the range<br />
of ASCII character codes). CHARS supports multibyte languages.<br />
Not all ASCII codes are printable. Some represent terminal controls, and others are<br />
reserved for special uses. For more information about ASCII character codes, see<br />
Appendix A, “ASCII Character Codes.”<br />
Tip: Use @variables to represent UniData delimiters and the null value. IBM<br />
recommends that you not use the <strong>UniBasic</strong> functions CHAR or CHARS to insert these<br />
variables because the ASCII code that represents it varies with language group.<br />
Example<br />
In the following example, the program segment assigns the ASCII string equivalent<br />
of the elements of array VAL to the variable VARRAY. VARRAY now contains<br />
W}X}Y}Z, the character equivalent of 87,88,89, and 90 in the ASCII code system.<br />
VAL = 87:@VM:88:@VM:89:@VM:90<br />
VARRAY = CHARS(VAL)<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
ASCII, CHAR, EBCDIC, SEQ<br />
CHARS 1-138
CHECKSUM<br />
Syntax<br />
CHECKSUM(str.expr)<br />
Description<br />
The <strong>UniBasic</strong> CHECKSUM function computes the positional checksum of the<br />
string str.expr you specify. The positional checksum is the sum of the ASCII value of<br />
each character in the string, multiplied by the position of the character in the string.<br />
For more information about ASCII characters values, see Appendix A, “ASCII<br />
Character Codes.”<br />
Tip: You can use the CHECKSUM function to check whether data was copied<br />
correctly, or whether information processed properly, by comparing the<br />
CHECKSUM of the original data with the CHECKSUM of the copy.<br />
Example<br />
In the following example, the program statement prints out 2445, the checksum of<br />
string “123456789”:<br />
PRINT CHECKSUM("123456789")<br />
1-139 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
CLEAR<br />
Syntax<br />
CLEAR<br />
Description<br />
The <strong>UniBasic</strong> CLEAR command sets the values of all variables stored in local<br />
memory to 0, including all array elements. Variables assigned to named or unnamed<br />
common areas are not affected.<br />
Tip: CLEAR can be used at any point within a program.<br />
Note: CLEAR performs differently with BASICTYPEs M and P. All variables in<br />
unnamed common areas are also set to 0.<br />
Examples<br />
In the following example, the program statement clears all variables not held in<br />
common if the variable INITIALIZE is true and BASICTYPE is U. The variable<br />
INITIALIZE also set to 0 (false) if the variable is not held in common.<br />
IF INITIALIZE THEN CLEAR<br />
In the next example, the program segment sets X, Y, and all elements in NAME, to<br />
zero in BASICTYPEs P and M:<br />
COMMON NAME(100)<br />
X = 4<br />
Y = X - 1<br />
CLEAR<br />
CLEAR 1-140
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
COMMON, CLEARCOMMON<br />
UniData<br />
DELETECOMMON – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
1-141 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
CLEARCOMMON<br />
Syntax<br />
CLEARCOMMON [/common.label/]<br />
Synonyms<br />
CLEAR COMMON, CLEARCOM, CLEAR COM<br />
Description<br />
The <strong>UniBasic</strong> CLEARCOMMON command sets all variables in a named common<br />
area to zero. If you do not specify common.label, CLEARCOMMON sets all<br />
variables specified in the unnamed common area to zero.<br />
Examples<br />
In the following example, the program statement sets to zero all variables named in<br />
COM_1:<br />
CLEARCOMMON /COM_1/<br />
In the next example, the program statement sets to zero all variables held in common<br />
areas if the variable INITIALIZE.COMMON is true:<br />
IF INITIALIZE.COMMON THEN CLEAR COMMON<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLEAR, COMMON<br />
CLEARCOMMON 1-142
UniData<br />
DELETECOMMON, STACKCOMMON – For information, see the UniData<br />
<strong>Commands</strong> <strong>Reference</strong>.<br />
1-143 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
CLEARDATA<br />
Syntax<br />
CLEARDATA<br />
Description<br />
The <strong>UniBasic</strong> CLEARDATA command clears data stored by any executed DATA<br />
statements. Subsequent INPUT statements request data from the keyboard because<br />
the input queue is empty.<br />
Example<br />
In the following example, a DATA statement sets up an input queue. An INPUT<br />
statement then reads the first item (100) into the variable VAL. Because the value of<br />
VAL is 100, a CLEARDATA statement executes and clears the remaining list of data<br />
items. The last INPUT statement then requests information from the keyboard rather<br />
than getting it from the input queue. If the first value had not been 100, 120 would<br />
have been assigned from the second item in the input queue.<br />
DATA 100,120,105,54,120<br />
INPUT VAL<br />
IF VAL = 100 THEN CLEARDATA<br />
PRINT "VALUE": ; INPUT VAL2<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DATA, INPUT<br />
CLEARDATA 1-144
CLEARFILE<br />
Syntax<br />
CLEARFILE [file.var] [ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> CLEARFILE command clears all records from a file, but does not<br />
delete the file itself. You can clear only one file at a time with a CLEARFILE<br />
statement.<br />
Tip: The CLEARFILE statement clears any of the files that you can open, even if they<br />
reside in a remote account.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-145 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
file.var Optional. Specifies a dictionary or data file to clear.<br />
The file must have been opened previously with an OPEN<br />
statement.<br />
If you do not specify a file.var, the system reads from the<br />
default file. If no default file is open, a fatal READ error occurs.<br />
A default file is one for which no file variable is assigned in the<br />
OPEN statement.<br />
ON ERROR statements Specifies statements to execute if a fatal error occurs because<br />
the file is not open or is read-only.<br />
If you do not specify the ON ERROR clause, the program<br />
terminates under fatal error conditions.<br />
CLEARFILE Parameters
Example<br />
In the following example, the program statement removes all records from the file<br />
PASTDUE. The dictionary of PASTDUE remains unchanged after the execution of<br />
this statement.<br />
CLEARFILE PASTDUE<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
OPEN, OPENSEQ, OSOPEN<br />
UniData<br />
CLEAR.FILE – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
CLEARFILE 1-146
CLEARINPUT<br />
Syntax<br />
CLEARINPUT<br />
Synonym<br />
INPUTCLEAR<br />
Description<br />
The <strong>UniBasic</strong> CLEARINPUT command clears the terminal type-ahead buffer so the<br />
next INPUT statement forces a response from the user.<br />
Example<br />
In the following example, the CLEARINPUT statement clears the terminal typeahead<br />
buffer so the user must respond to the prompt:<br />
1-147 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
CLEARINPUT<br />
PRINT "DO YOU WANT TO DELETE THIS FILE?(Y OR N)"; INPUT X,1<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLEARDATA, INPUT, SYSTEM
CLEARSELECT<br />
Syntax<br />
CLEARSELECT [num.expr] [ALL]<br />
Description<br />
The <strong>UniBasic</strong> CLEARSELECT command clears active select lists. You can specify<br />
a particular ID list by specifying num.expr as 0 through 9. ALL clears all active select<br />
lists. If you do not specify a parameter, UniData clears the default ID list (zero). If<br />
you specify an ID list outside the valid range, a runtime error occurs.<br />
You generally create active lists by executing the ECL SELECT, SSELECT, or<br />
GET.LIST commands, or the <strong>UniBasic</strong> SELECT or GETLIST commands. These<br />
commands report or process a specific subset of IDs within a file. Because multiple<br />
select lists can be active at one time, the CLEARSELECT statement could clear one<br />
or all of the currently active lists.<br />
Examples<br />
In the following example, the program segment clears select list 1:<br />
ID.LIST=1<br />
CLEARSELECT ID.LIST<br />
In the next example, the program statement clears the default list 0:<br />
CLEARSELECT<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
SELECT, GETLIST<br />
CLEARINPUT 1-148
UniQuery<br />
GET.LIST, SELECT, SSELECT – For information, see Using UniQuery.<br />
1-149 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
CLEARSQL<br />
Syntax<br />
CLEARSQL [file.name.expr]<br />
Description<br />
The <strong>UniBasic</strong> CLEARSQL command clears all active temporary tables that were<br />
created during the current session (for example, created with the EXECUTESQL<br />
command with a corresponding TO clause). If you do not specify file.name.expr,<br />
CLEARSQL clears all the UniData SQL file variables created during this <strong>UniBasic</strong><br />
session.<br />
Note: When a program returns to the UniData prompt, UniData clears all UniData<br />
SQL file variables regardless of whether you execute CLEARSQL.<br />
Related Command<br />
<strong>UniBasic</strong><br />
EXECUTESQL<br />
CLEARSQL 1-150
CLOSE<br />
Syntax<br />
CLOSE [file.var] [ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> CLOSE command closes a dictionary or data file.<br />
Note: You can use the OPEN command to access an unlimited number of files in a<br />
single UniData process. However, the operating system could limit the number of<br />
files that can be opened across numerous processes and users.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-151 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
file.var Specifies a dictionary or data file to close. If you do not specify<br />
file.var, the default file is closed. If no default file is open, the<br />
command has no effect.<br />
A default file is created by omitting the file variable in the<br />
OPEN statement.<br />
ON ERROR statements Specifies statements to execute if a fatal error occurs because<br />
the file is not open.<br />
If you do not specify the ON ERROR clause, the program<br />
terminates under fatal error conditions.<br />
CLOSE Parameters
Example<br />
In the following example, the program segment opens and closes the file<br />
INVENTORY:<br />
OPEN 'INVENTORY' TO INVENTORY.FILE ELSE STOP<br />
CLOSE INVENTORY.FILE<br />
Related Command<br />
<strong>UniBasic</strong><br />
OPEN<br />
CLOSE 1-152
CLOSESEQ<br />
Syntax<br />
CLOSESEQ seq.file.var [ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> CLOSESEQ command closes a sequential file that you opened with<br />
the OPENSEQ or OSOPEN command. The CLOSESEQ command releases the<br />
exclusive file lock set by the OPENSEQ command. If any new lines (sequential<br />
records) were added to the file, UniData writes a new end-of-file mark after the new<br />
lines.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Example<br />
In the following example, the statement closes the sequential file referred to by the<br />
file variable DATA.59:<br />
CLOSESEQ DATA.59<br />
1-153 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
seq.file.var Specifies a sequential access file to close.<br />
The file must have been opened previously with an OPENSEQ<br />
or OSOPEN statement.<br />
ON ERROR statements Specifies statements to execute if a fatal error occurs because<br />
the file is not open.<br />
If you do not specify the ON ERROR clause, the program<br />
terminates under such fatal error conditions.<br />
CLOSESEQ Parameters
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLOSE, OPENSEQ, OSCLOSE, OSOPEN<br />
CLOSESEQ 1-154
closeSocket<br />
Syntax<br />
closeSocket(socket_handle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Use the closeSocket function to close a socket connection.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
The following table describes the status of each return code.<br />
1-155 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Parameter Description<br />
socket_handle The handle to the socket you want to close.<br />
closeSocket Parameters<br />
Return<br />
Code Status<br />
0 Success.<br />
Non-zero See Socket Function Error Return Codes.<br />
Return Code Status
CloseXMLData<br />
Syntax<br />
CloseXMLData(xml_data_handle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The CloseXMLData function closes the dynamic array variable for an XML<br />
document.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
xml_data_handle The name of the XML data file handle created by the OpenXMLData<br />
function.<br />
CloseXMLData Parameters<br />
The return value is one of the following:<br />
Example<br />
XML.SUCCESS Success<br />
XML.ERROR Failure<br />
XML.INVALID.HANDLE2 Invalid xml_data_handle<br />
The following example illustrates use of the CloseXMLData function:<br />
status = CloseXMLData(STUDENT_XML)<br />
CloseXMLData 1-156
COL1<br />
Syntax<br />
COL1( )<br />
Description<br />
The <strong>UniBasic</strong> COL1 function returns the column position preceding a substring<br />
found by the FIELD function. The COL1 function has no arguments. If you do not<br />
execute the FIELD function before executing COL1, the function returns 0. COL1<br />
supports multibyte languages.<br />
The FIELD function examines a string for a particular delimiter and returns the<br />
substring marked by the specified occurrence of that delimiter. While the FIELD<br />
function returns the substring itself, the COL1 function returns the position preceding<br />
the substring.<br />
Example<br />
In the following example, the FIELD function searches the string STRING for the<br />
third occurrence of the delimiter “,”. FIELD retrieves the substring “10” in the<br />
variable SSTR. The COL1 function assigns column 6, the column position of the<br />
character before “10”, to the variable SPOS.<br />
1-157 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
STRING = "11,20,10,15,20,15"<br />
SSTR = FIELD(STRING,",",3)<br />
SPOS = COL1()<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
COL2, FIELD, INDEX
COL2<br />
Syntax<br />
COL2( )<br />
Description<br />
The <strong>UniBasic</strong> COL2 function returns the column position following a substring<br />
found by the FIELD function. The COL2 function has no arguments. If you do not<br />
execute the FIELD before executing COL2, the function returns a zero. COL2<br />
supports multibyte languages.<br />
The FIELD function examines a string for a particular delimiter and returns the<br />
substring marked by the specified occurrence of that delimiter. While the FIELD<br />
function returns the substring itself, the COL2 function returns the position immediately<br />
after the substring within the string sent to the FIELD function.<br />
Example<br />
In the following example, the FIELD function searches the string STRING for the<br />
third occurrence of the delimiter “,”. FIELD assigns the substring “10” to the variable<br />
SSTR. The COL1 function assigns column 9, the column position of the character<br />
after “10”, to the variable SPOS2.<br />
STRING = "11,20,10,15,20,15"<br />
SSTR = FIELD(STRING,",",3)<br />
SPOS2 = COL2()<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
COL1, FIELD, INDEX<br />
COL2 1-158
COMMON<br />
Syntax<br />
COMMON [/common.name/] var1 [,var2][ARR1]...[,]<br />
Synonym<br />
COM<br />
Description<br />
The <strong>UniBasic</strong> COMMON command stores variables that can be accessed from any<br />
subroutine or program. You can declare one unnamed common area and multiple<br />
named common areas. The number of variables that a common area can contain<br />
depends on the virtual memory of your system. For information about virtual<br />
memory, see Administering UniData on UNIX or Administering UniData on<br />
Windows Platforms.<br />
Constraints and Considerations<br />
Keep the following points in mind when writing programs that use common to pass<br />
variables:<br />
1-159 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Common variables are not passed when you execute CHAIN to another<br />
<strong>UniBasic</strong> program.<br />
Unnamed common is removed when you return to the ECL prompt, but<br />
named common remains in memory until deleted with the ECL DELETE-<br />
COMMON command, even if the program aborts.<br />
COMMON must be the first noncomment statement in the called program.<br />
CLEARCOMMON sets the common variable to 0. DELETECOMMON<br />
removes common variables.
Variables in a common area must be declared the same type, dimension, and<br />
in the same order by all programs accessing them. Programs can declare<br />
more or fewer variables, and can change the name of the variables. The<br />
order of the names in a program’s COMMON statement determines which<br />
names go with which values.<br />
Common names are limited to a length of seven characters. No error<br />
message is returned when longer names are truncated during compilation.<br />
In the following example, STRING2 overwrites STRING1 because both<br />
names, commons1 and commons2, are truncated to “commons”:<br />
COMMON commons1 STRING1<br />
COMMON commons2 STRING2<br />
COMMON BASICTYPEs<br />
You can pass variables using common in any BASICTYPE. Here are some notes:<br />
With BASICTYPEs M and P, use of COMMON is more flexible because in<br />
these BASICTYPEs no zero element is maintained in arrays. For example,<br />
two programs declare COMMON, which are described in the following<br />
table.<br />
STACKCOMMON defaults to OFF in BASICTYPEs R and U, but is<br />
always ON in BASICTYPEs P and M.<br />
You can use the PASSCOM option for compatibility purposes, but its use is<br />
not needed to pass common variables.<br />
STACKCOMMON<br />
First Program Second Program<br />
Declares COMMON as:<br />
A,B(5)<br />
Assigns values of:<br />
A = 4 and B(3) = 5<br />
Declares COMMON as:<br />
U,V,W,X,Y,Z<br />
Therefore:<br />
U = 4 and X = 5<br />
Example Renaming COMMON Variables<br />
The ECL STACKCOMMON command makes use of common areas more flexible,<br />
although it requires additional memory. STACKCOMMON settings have the<br />
following effects:<br />
COMMON 1-160
1-161 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
If STACKCOMMON is off when one program executes another, the<br />
contents of unnamed common areas are passed to the executed program and<br />
back to the executing program.<br />
If STACKCOMMON is on when one program executes another program,<br />
the contents of unnamed common areas are not passed to the program you<br />
execute. Instead, they are saved, and the called program’s unnamed<br />
common areas are initialized to 0. When control is passed back to the calling<br />
program, it is restored to its value before the program call. Unnamed<br />
common areas are never passed to a phantom program.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
/common.name/ Specifies a name for a named common variable. common.name can<br />
have any valid variable name no longer than seven characters. Default<br />
(no common name provided) stores the variable in unnamed common.<br />
var1 A variable to place in the named or unnamed common.<br />
,var2 A second variable to place in the named or unnamed common areas.<br />
ARR1 An array to place in the named or unnamed common area. Do not<br />
declare common arrays with a DIM statement. Arrays in a common<br />
cannot be dynamically redimensioned.<br />
, You can enter a COMMON statement on several lines by terminating<br />
each line to be continued with a comma.<br />
COMMON Parameters<br />
Examples<br />
In the following example, the COMMON statement declares the arrays NAME and<br />
DATES, and declares the variable DCHANGE in unnamed common:<br />
COMMON NAME(100),DATES(100,2),DCHANGE
In the next example, the program segment creates two named common areas. The<br />
second COMMON statement continues on a second line. The comma (,) continuation<br />
character ends the continued line.<br />
COMMON /MENU/ X,Y,XDIM,YDIM,S.CHAR<br />
COMMON /CALC/ RATE(10),AMOUNT(10),DATE1,<br />
DATE2,LATE<br />
In the following example, the program segment is invalid because COMMON is not<br />
the first statement in the called program, and because variables in COMMON cannot<br />
be reassigned new values in a called program:<br />
VALUE = 253<br />
COMMON VALUE,SUBVALUE,ATTRIBUTE<br />
The following two programs demonstrate passing a variable through common. The<br />
FIRST_PROG establishes the common variable VAR, and then NEXT_PROG<br />
declares this variable, adds 1 to it, and prints it.<br />
FIRST_PROG<br />
COMMON VAR<br />
VAR = 1<br />
PRINT "IN FIRST_PROG"<br />
PRINT VAR<br />
CALL NEXT_PROG<br />
NEXT_PROG<br />
*Program NEXT_PROG<br />
COMMON VAR<br />
PRINT "IN NEXT_PROG"<br />
VAR = VAR+1<br />
PRINT VAR<br />
Here is the output from these programs:<br />
:RUN BP FIRST_PROG<br />
IN FIRST_PROG<br />
1<br />
IN NEXT_PROG<br />
2<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLEAR, CLEARCOMMON<br />
COMMON 1-162
UniData<br />
DELETECOMMON, STACKCOMMON – For information, see the UniData<br />
<strong>Commands</strong> <strong>Reference</strong> manual.<br />
1-163 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
CONTINUE<br />
Syntax<br />
CONTINUE<br />
Description<br />
The <strong>UniBasic</strong> CONTINUE command transfers control to the next iteration of a<br />
FOR/NEXT or LOOP/REPEAT statement.<br />
Tip: Use CONTINUE instead of GOTO in structured programs.<br />
Generally, the statements within a FOR/NEXT or LOOP/REPEAT structure execute<br />
one by one. If you want to break the sequence to begin the next iteration without a<br />
CONTINUE statement, you could use the GOTO statement. However, this makes the<br />
code more difficult to read and maintain. By using CONTINUE, you can clearly<br />
express the program logic without degrading program structure.<br />
Example<br />
In the following example, the program segment prints the value of I until I reaches<br />
eight. When I is equal to eight, the CONTINUE statement drops out of the<br />
FOR/NEXT loop, and the next statement in the program executes.<br />
FOR I = 1 TO 10<br />
IF I > 8 THEN CONTINUE<br />
PRINT "I = ":I<br />
NEXT I<br />
The preceding code produces the following output:<br />
I = 1<br />
I = 2<br />
I = 3<br />
...<br />
I = 8<br />
CONTINUE 1-164
Related Command<br />
<strong>UniBasic</strong><br />
EXIT<br />
1-165 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
CONVERT<br />
Syntax<br />
CONVERT expr1 TO expr2 IN var<br />
Description<br />
The <strong>UniBasic</strong> CONVERT command changes all occurrences of the substring expr1<br />
in var to the string expr2. <strong>UniBasic</strong> compares each character of the replacement<br />
string expr2 and, if necessary, replaces each character of the target string expr1 on an<br />
individual basis. <strong>UniBasic</strong> does not compare and insert strings as a whole.<br />
CONVERT supports multibyte languages.<br />
CONVERT can delete characters from a string, but it does not insert additional<br />
characters. If the replacement substring expr2 contains more characters than are in<br />
the substring it replaces (expr1), the extra characters are ignored.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Examples<br />
Parameter Description<br />
expr1 Specifies the target string to replace with expr2.<br />
expr2 Specifies the string with which to replace expr1.<br />
var Specifies the string to search for expr1.<br />
CONVERT Parameters<br />
In the following example, the program segment converts all occurrences of 1 to 3 and<br />
all occurrences of 2 to 4. The new contents of NSTRING becomes 34,0,03,35,44.<br />
NSTRING = "12,0,01,15,22"<br />
CONVERT "12" TO "34" IN NSTRING<br />
CONVERT 1-166
In the next example, the program segment converts all occurrences of AC to X, which<br />
sets NSTRING equal to XBDEFG (notice that C is deleted):<br />
1-167 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
NSTRING = "ABCDEFG"<br />
CONVERT "AC" TO "X" IN NSTRING<br />
In the following example, the replacement string of “F,G” is longer than the string it<br />
is intended to replace, so the extra characters, “,G”, are ignored. After the conversion,<br />
NSTRING equals F,C,D,E.<br />
NSTRING = "A,C,D,E"<br />
CONVERT "A" TO "F,G" IN NSTRING<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CONVERT function, SWAP
CONVERT<br />
Syntax<br />
CONVERT(expr1, expr2, expr3)<br />
Description<br />
The <strong>UniBasic</strong> CONVERT function changes all occurrences of the substring expr1 in<br />
expr3 to the string expr2. The system compares each character of the replacement<br />
string expr2 and, if necessary, replaces each character of the target string expr1 on an<br />
individual basis. <strong>UniBasic</strong> does not compare and insert strings as a whole.<br />
CONVERT supports multibyte languages.<br />
CONVERT can delete characters from a string expression, but it does not insert<br />
additional characters. If the replacement substring expr2 contains more characters<br />
than are in the substring it replaces (expr1), the extra characters are ignored.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Examples<br />
Parameter Description<br />
expr1 Specifies the target string to replace with expr2.<br />
expr2 Specifies the string with which to replace expr1.<br />
expr3 Specifies the string to search for expr1.<br />
CONVERT Parameters<br />
In the following example, the program segment changes OLDSTR to NEWSTR,<br />
which now contains “868,848,838,808”:<br />
OLDSTR = "767,747,737,707"<br />
NEWSTR = CONVERT("7","8",OLDSTR)<br />
CONVERT 1-168
In the next example, the program segment displays 1AA33BB667. Note that the fives<br />
in X are dropped because no corresponding substitute is provided.<br />
X = "122334455667"<br />
PRINT CONVERT("245","AB",X)<br />
In the following example, Z becomes kakakakaka because the extra character “t” in<br />
S2 is ignored:<br />
Y="sasasasasa"<br />
S1="s"<br />
S2="kt"<br />
Z=CONVERT(S1,S2,Y)<br />
PRINT Z<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CONVERT command, SWAP<br />
1-169 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
COS<br />
Syntax<br />
COS(expr)<br />
Description<br />
The <strong>UniBasic</strong> COS function returns the trigonometric cosine of a numeric<br />
expression.<br />
Examples<br />
In the following example, the program statement assigns the cosine of a 60-degree<br />
angle to the variable COSINE. COSINE is assigned the value of 0.5.<br />
COSINE = COS(60)<br />
In the next example, the program statement prints the cosine of the variable VAL plus<br />
10:<br />
PRINT COS(VAL+10)<br />
Related <strong>Commands</strong><br />
ACOS, ASIN, ATAN, COS, SIN, TAN<br />
COS 1-170
COUNT<br />
Syntax<br />
COUNT(str.expr1, str.expr2)<br />
Description<br />
The <strong>UniBasic</strong> COUNT function returns the number of times a substring appears<br />
within a string. The string you want to search, str.expr1, must be longer than the<br />
substring str.expr2. After str.expr2 is found, the system searches the string again with<br />
the new starting point after the entire first occurrence of str.expr2. If str.expr2 is not<br />
found, the COUNT function returns 0. COUNT supports multibyte languages.<br />
Note: In BASICTYPEs P and M, after UniData finds str.expr2, it searches the string<br />
again with the new starting point after the first character of the first occurrence of<br />
str.expr2. UniData can find overlapping character strings.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Examples<br />
In the following example, the program segment searches the string STRING for the<br />
number of occurrences of the substring II. It returns this number, 2, in the variable IC.<br />
1-171 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
str.expr1 Specifies the string to search. This string must be longer than str.expr2.<br />
str.expr2 Specifies the target string to search for and count occurrences of in str.expr1.<br />
COUNT Parameters<br />
STRING = "JAWSII,ROCKYIII,STARTREKIV"<br />
IC = COUNT(STRING,"II")
In the next example, the same program segment compiled under BASICTYPE P or<br />
M searches the string STRING for the number of occurrences of the substring II and<br />
assigns that number, 3, to the variable IC. It counts two occurrences of the substring<br />
II in ROCKYIII.<br />
$BASICTYPE "P"<br />
STRING = "JAWSII,ROCKYIII,STARTREKIV"<br />
IC = COUNT(STRING,"II")<br />
COUNT 1-172
COUNTS<br />
Syntax<br />
COUNTS(expr,str.expr)<br />
Description<br />
The <strong>UniBasic</strong> COUNTS function returns the number of times a substring appears<br />
within each element of an array. The elements in the array you want to search, expr,<br />
must be longer than the substring str.expr. After str.expr is found, the system searches<br />
the array again with the new starting point after the entire first occurrence of str.expr.<br />
If str.expr is not found, COUNTS returns 0. COUNTS supports multibyte languages.<br />
Note: In BASICTYPEs P and M, after UniData finds str.expr, it searches the string<br />
again with the new starting point after the first character of the first occurrence of<br />
str.expr. UniData can find overlapping character strings.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-173 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
expr Specifies the array to search. The elements of this array must be longer than<br />
str.expr.<br />
str.expr Specifies the target string to search for and count occurrences of in elements<br />
of expr.<br />
COUNTS Parameters
Examples<br />
In the following example, the program segment searches the string STR for the<br />
number of occurrences of substring I, and returns the answer in the variable IC. After<br />
execution, IC contains 2}3}1.<br />
STR = "JAWSII":@VM:"ROCKYIII":@VM:"STARTREKIV"<br />
IC = COUNTS(STR,"I")<br />
In the next example, the same program segment compiled under BASICTYPE P or<br />
M searches the string STR for the number of occurrences of the substring II and<br />
assigns the values to the variable IC. After execution, IC contains 1}2}0.<br />
$BASICTYPE "P"<br />
STR = "JAWSII":@VM:"ROCKYIII":@VM:"STARTREKIV"<br />
IC = COUNTS(STR,"II")<br />
If the preceding code is compiled in BASICTYPE U or R, COUNTS returns “1}1}0”<br />
in the variable IC.<br />
COUNT 1-174
createCertificate<br />
Syntax<br />
createCertificate(action, req, signKey, keyPass, CAcert, days, extensions, certOut)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The createCertificate function generates a certificate. The certificate can either be a<br />
self-signed certificate as a root CA that you can use later to sign other certificates, or<br />
it can be a CA signed certificate. The generated certificate conforms to X509V3<br />
standard.<br />
The difference between CA-signing and leaf-CA-signing is that, for CA-signing, the<br />
resultant certificate can serve as an intermediate CA certificate to sign other certificates,<br />
while leaf-CA-signing generates certificates that are intended for end user use<br />
only.<br />
This function is provided mainly for the purpose of enabling application development<br />
and testing. As such, the certificate generated contains only a minimum amount of<br />
information and does not allow any extensions specified by the X509 standard and<br />
that are supported by many other vendors. It is recommended that you implement a<br />
complete PKI solution partnered with a reputed PKI solution vendor.<br />
For detailed information about the createCertificate function, see <strong>UniBasic</strong><br />
Extensions.<br />
1-175 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
action 1 - Self-signing<br />
2 - CA-signing<br />
3 - leaf-CA-signing<br />
req A string containing the certificate request file name.<br />
signKey A string containing the private key file name.<br />
keyPass A string containing the pass phrase to protect the private key.<br />
CAcert A string containing the CA certificate.<br />
days The number of days for which the certificate is valid. The default is 365<br />
days.<br />
extensions A string containing extension specifications.<br />
certOut A string containing the generated certificate file.<br />
createCertificate Parameters<br />
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success.<br />
1 Cannot read certificate request file.<br />
2 Cannot read the key file.<br />
3 Cannot read the CA certificate file.<br />
4 Cannot generate the certificate.<br />
Return Code Status<br />
createCertificate 1-176
createCertRequest<br />
Syntax<br />
createCertRequest(key, inFormat, keyLoc, algorithm, digest, passPhrase,<br />
subjectData, outFile, outFormat)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The createCertRequest() function generates a PKCS #10 certificate request from a<br />
private key in PKCS #8 form and a set of user specified data. The request can be sent<br />
to a CA or used as a parameter to createCertificate() to obtain an X.509 public key<br />
certificate.<br />
The certificate request will typically contain the information described in the<br />
following table.<br />
Item Description<br />
Version Defaults to 0.<br />
The subject data must be provided by the requester through the dynamic array,<br />
subjectData. It contains @FM separated attributes in the form of “attri=value”.<br />
1-177 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Subject The identification data of the certificate holder. This includes, country,<br />
state/province, locality (city), organization, unit, common name, email<br />
address, and so forth.<br />
Public key The key’s algorithm (RSA or DSA) and value.<br />
Signature The signature of the requester, (signed by the private key).<br />
Certificate Request Information
The following table describes the commonly used subjectData attributes.<br />
Item Description Example<br />
C Country C=US<br />
ST State ST=Colorado<br />
L Locality L=Denver<br />
O Organization O=MyCompany<br />
OU Organization Unit OU=Sales<br />
CN Common Name CN=service@mycompany.com<br />
Email Email Address Email=john.doe@mycompany.com<br />
subjectData Attributes<br />
For detailed information about creating a certificate request, see <strong>UniBasic</strong><br />
Extensions.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
key A string containing the key or name of the file storing the key.<br />
inFormat The key format.<br />
1 - PEM<br />
2 - DER<br />
keyLoc 1 - Put the key into string privKey/pubKey.<br />
2 - Put the key into a file.<br />
algorithm 1 - RSA<br />
2 - DSA<br />
digest 1 - MD5<br />
2 - SHA1<br />
passPhrase A string storing the pass phrase to protect the private key.<br />
createCertRequest Parameters<br />
createCertRequest 1-178
Parameter Description<br />
The following table describes the status of each return code.<br />
1-179 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
subjectData The identification information of the requester.<br />
outFile A string containing the path name of the file where the certificate request<br />
is stored.<br />
outFormat The generated certificate format.<br />
1 - PEM<br />
2 - DER<br />
Return<br />
Code Status<br />
0 Success.<br />
createCertRequest Parameters (continued)<br />
1 Private key file cannot be opened.<br />
2 Unrecognized key or certificate format.<br />
3 Unrecognized key type.<br />
4 Unrecognized encryption algorithm.<br />
5 Unrecognized key (corrupted key or algorithm mismatch).<br />
6 Invalid pass phrase.<br />
7 Invalid subject data (illegal format or unrecognized attribute,<br />
etc.).<br />
8 Invalid digest algorithm.<br />
9 Output file cannot be created.<br />
99 Cert Request cannot be generated.<br />
Return Code Status
createRequest<br />
Syntax<br />
createRequest(URL, http_method, request_handle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The createRequest function creates an HTTP request and returns a handle to the<br />
request.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Option<br />
URL A string containing the URL for a resource on a web server. An<br />
accepted URL must follow the specified syntax defined in RFC 1738.<br />
The general format is: http://:/?.<br />
The host can be either a name string or IP address. The port is the port<br />
number to which you want to connect, which usually defaults to 80 and<br />
is often omitted, along with the preceding colon. The path tells the web<br />
server which file you want, and, if omitted, means “home page” for the<br />
system. The searchpart can be used to send additional information to a<br />
web server.<br />
http_method A string which indicates the method to be performed on the resource.<br />
See the table below for the available (case-sensitive) methods.<br />
request_handle A handle to the request object.<br />
createRequest Parameters<br />
createRequest 1-180
The following table describes the available methods for http_method.<br />
Method Description<br />
1-181 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
GET Retrieves whatever information, in the form of an entity, identified<br />
by the Request-URI. If the Request-URI refers to a data-producing<br />
process, it is the produced data which shall be returned as the entity<br />
in the response and not the source text of the process, unless that<br />
text happens to be the output of the process.<br />
POST [:] For this method, it can also have an optional MIME-type<br />
to indicate the content type of the data the request intends to send. If no<br />
MIME-type is given, the default content type will be “application/x-wwwform-urlencoded”.<br />
Currently, only “multipart/form-data” is internally<br />
supported, as described in function addRequestParameter() and<br />
submitRequest(), although other “multipart/* data can also be sent if the<br />
user can assemble it on his/her own. (The multipart/form-data format itself<br />
is thoroughly described in RFC 2388).<br />
HEAD The HEAD method is identical to GET except that the server<br />
MUST NOT return a message-body in the response. The metainformation<br />
contained in the HTTP headers in response to a HEAD<br />
request SHOULD be identical to the information sent in response to<br />
a GET request. This method can be used for obtaining<br />
metainformation about the entity implied by the request without<br />
transferring the entity-body itself. This method is often used for<br />
testing hypertext links for validity, accessibility, and recent modification.<br />
OPTIONS The OPTIONS method represents a request for information about<br />
the communication options available on the request/response chain<br />
identified by the Request-URI. This method allows the client to<br />
determine the options and/or requirements associated with a<br />
resource, or the capabilities of a server, without implying a resource<br />
action or initiating a resource retrieval. HTTP 1.1 and later.<br />
DELETE The DELETE method requests that the origin server delete the<br />
resource identified by the Request-URI. HTTP 1.1 and later.<br />
createRequest Methods
Method Description<br />
TRACE The TRACE method is used to invoke a remote, application-layer<br />
loop- back of the request message. HTTP 1.1 and later.<br />
PUT The PUT method requests that the enclosed entity be stored under<br />
the supplied Request-URI. HTTP 1.1 and later but not supported.<br />
CONNECT /* HTTP/1.1 and later but not supported */<br />
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success.<br />
createRequest Methods (continued)<br />
1 Invalid URL (Syntactically).<br />
2 Invalid method (For HTTP 1.0, only GET/POST/HEAD)<br />
Return Code Status<br />
Note: If URL does include a searchpart, it must be in its encoded format (space is<br />
converted into +, and other non-alphanumeric characters are converted into %HH<br />
format. See addRequestParameter() for more details). However, host and path are<br />
allowed to have these “unsafe” characters. <strong>UniBasic</strong> will encode them before<br />
communicating with the web server.<br />
This function can also be used later to support other protocols (like FTP, in which<br />
case the URL supplied would be in the form of:<br />
ftp://:@:/cwd1/.../cwdN>/;type= . The http_method option would be ignored for an FTP request.<br />
createRequest 1-182
createSecureRequest<br />
Syntax<br />
createSecureRequest(URL, http_method, request_handle, security_context)<br />
Description<br />
The createSecureRequest function behaves exactly the same as the<br />
createRequest() function, except for the fourth parameter, a handle to a security<br />
context, which is used to associate the security context with the request. If the URL<br />
does not start with “https” the parameter is ignored. If the URL starts with “https” but<br />
an invalid context handle or no handle is provided, the function aborts and returns<br />
with an error status.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-183 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
URL A string containing the URL for a resource on a web server. An<br />
accepted URL must follow the specified syntax defined in RFC<br />
1738. The general format is:<br />
http://:/?. The host can be either a<br />
name string or IP address. The port is the port number to connect to,<br />
which usually defaults to 80 and is often omitted, along with the preceding<br />
colon. The path tells the web server which file you want, and,<br />
if omitted, means “home page” for the system. The searchpart can be<br />
used to send additional information to a web server.<br />
http_method A string which indicates the method to be performed on the resource.<br />
See the table below for the available (case-sensitive) methods.<br />
request_handle A handle to the request object.<br />
securityContext A handle to the security context.<br />
createSecureRequest Parameters
The following table describes the available methods for http_method.<br />
Method Description<br />
GET Retrieves whatever information, in the form of an entity, identified<br />
by the Request-URI. If the Request-URI refers to a data-producing<br />
process, it is the produced data which shall be returned as the entity<br />
in the response and not the source text of the process, unless that<br />
text happens to be the output of the process.<br />
POST [:] For this method, it can also have an optional MIME-type<br />
to indicate the content type of the data the request intends to send. If no<br />
MIME-type is given, the default content type will be “application/x-wwwform-urlencoded”.<br />
Currently, only “multipart/form-data” is internally<br />
supported, as described in function addRequestParameter() and<br />
submitRequest(), although other “multipart/* data can also be sent if the<br />
user can assemble it on his/her own. (The multipart/form-data format itself<br />
is thoroughly described in RFC 2388).<br />
HEAD The HEAD method is identical to GET except that the server<br />
MUST NOT return a message-body in the response. The metainformation<br />
contained in the HTTP headers in response to a HEAD<br />
request SHOULD be identical to the information sent in response to<br />
a GET request. This method can be used for obtaining<br />
metainformation about the entity implied by the request without<br />
transferring the entity-body itself. This method is often used for<br />
testing hypertext links for validity, accessibility, and recent modification.<br />
OPTIONS The OPTIONS method represents a request for information about<br />
the communication options available on the request/response chain<br />
identified by the Request-URI. This method allows the client to<br />
determine the options and/or requirements associated with a<br />
resource, or the capabilities of a server, without implying a resource<br />
action or initiating a resource retrieval. HTTP 1.1 and later.<br />
DELETE The DELETE method requests that the origin server delete the<br />
resource identified by the Request-URI. HTTP 1.1 and later.<br />
createRequest Methods<br />
createSecureRequest 1-184
Method Description<br />
The following table describes the status of each return code.<br />
Note: If URL does include a searchpart, it must be in its encoded format (space is<br />
converted into +, and other non-alphanumeric characters are converted into %HH<br />
format. See addRequestParameter() for more details). However, host and path are<br />
allowed to have these “unsafe” characters. <strong>UniBasic</strong> will encode them before<br />
communicating with the web server.<br />
1-185 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
TRACE The TRACE method is used to invoke a remote, application-layer<br />
loop- back of the request message. HTTP 1.1 and later.<br />
PUT The PUT method requests that the enclosed entity be stored under<br />
the supplied Request-URI. HTTP 1.1 and later but not supported.<br />
CONNECT /* HTTP/1.1 and later but not supported */<br />
createRequest Methods (continued)<br />
Return Code Status<br />
0 Success.<br />
1 Invalid URL (Syntactically).<br />
2 Invalid method (For HTTP 1.0, only<br />
GET/POST/HEAD)<br />
Return Code Status
createSecurityContext<br />
Syntax<br />
createSecurityContext(context, version)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The createSecurityContext function creates a security context and returns a handle<br />
to the context.<br />
A security context is a data structure that holds all aspects of security characteristics<br />
that the application intends to associate with a secured connection. Specifically, the<br />
following information may be held for each context:<br />
Protocol version<br />
Sender’s certificate to be sent to the peer<br />
Issuer’s certificate or certificate chain to be used to authenticate incoming<br />
certificate<br />
Certificate verification depth<br />
Certificate Revocation List<br />
Sender’s private key for signature and key exchange<br />
Flag to perform client authentication (useful for server socket only)<br />
Context ID and time stamp<br />
For detailed information about the createSecurityContext function, see <strong>UniBasic</strong><br />
Extensions.<br />
createSecurityContext 1-186
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
The following table describes the status of each return code.<br />
1-187 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
context The security context handle.<br />
version A string with the following values: SSLv2, SSLv3 or TLSv1.<br />
createSecurityContext Parameters<br />
Return<br />
Code Status<br />
0 Success.<br />
1 Security context could not be created.<br />
2 Invalid version.<br />
Return Code Status
CRT<br />
Syntax<br />
CRT [print.expr]<br />
Synonym<br />
DISPLAY<br />
Description<br />
The <strong>UniBasic</strong> CRT command sends output to the display terminal regardless of the<br />
use of the PRINTER ON/OFF command. print.expr can consist of any of the<br />
following:<br />
String data.<br />
Any number of strings or numeric variables.<br />
<strong>UniBasic</strong> functions.<br />
Tip: Use the <strong>UniBasic</strong> @ function before the CRT command to position the cursor on<br />
the screen or execute other terminal functions before printing to the terminal.<br />
Set UDT.OPTIONS 5 on if you want the display to pause at the end of each page. For<br />
information about UDT.OPTIONS, see the UDT.OPTIONS <strong>Commands</strong> <strong>Reference</strong>.<br />
To suppress the line feed at the end of displayed text, end the CRT or DISPLAY<br />
statement with a colon.<br />
createSecurityContext 1-188
DATA<br />
Syntax<br />
DATA expr1 [,expr2]...<br />
Description<br />
The <strong>UniBasic</strong> DATA command places data in an input queue stored in @DATA.<br />
ASCII character 013 (CR) delimits elements in the queue. Each subsequent INPUT<br />
statement reads one element. @DATA is read-only. For more information about @<br />
variables, see Appendix B, “<strong>UniBasic</strong>@variables.”<br />
The expressions (expr1 and expr2) can be literal strings or variables. You can<br />
continue DATA statements over several lines by placing a comma at the end of each<br />
line to be continued.<br />
UniData places data in the queue in order of execution of DATA commands. The<br />
queue processes on a first-in, first-out basis. When the input queue is empty, UniData<br />
requests input from the terminal. The input queue remains available through program<br />
CHAIN and EXECUTE operations, but is cleared when control returns to the<br />
UniData ECL prompt (:).<br />
Tip: You can load inline prompts in paragraphs with the DATA command. For<br />
instructions, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
Example<br />
In the following example, the program segment executes a DATA statement<br />
containing variables and constants of both string and numeric types. The first value,<br />
10, is read by a subsequent input statement and assigns the value to the variable<br />
COUNT.<br />
1-187 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
DATA 10,"William","James",TESTVAL,135,<br />
"Test Run"<br />
INPUT COUNT
DATE<br />
Syntax<br />
DATE( )<br />
Description<br />
The <strong>UniBasic</strong> DATE function returns the current system date in internal format.<br />
Internal format is the number of days after December 31, 1967.<br />
Example<br />
The following statement prints the current system date in external format:<br />
PRINT OCONV(DATE(),"D")<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
ICONV Date (D), OCONV Date (D), TIMEDATE<br />
DATE 1-188
DBTOXML<br />
Syntax<br />
DBTOXML(xml_document, doc_location, u2xmap_file, u2xmap_location,<br />
condition, status)<br />
Description<br />
Creates an XML document from the UniData database.<br />
Parameters<br />
The following table describes each parameter of the syntax.T<br />
Parameter Description<br />
1-189 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
xml_document The name of the XML document to create.<br />
doc_flag A flag defining the type of xml_document. Valid values are:<br />
? XML.FROM.FILE - xml_document is a file name.<br />
? XML.FROM.STRING -xml_document is the name of<br />
variable containing the XML document.<br />
u2xmap_file The name of the U2XMAP file to use to produce the XML<br />
document.<br />
u2xmap_location The location of the U2XMAP file.<br />
? XML.FROM.FILE - u2xmap_file is a file name.<br />
? XML.FROM.STRING - is u2xmap_file the name of variable<br />
containing the mapping rules.<br />
condition A query condition for selecting data from the UniData<br />
file, for example, WHERE SCHOOL = "CO002"<br />
Status XML.SUCCESS or XML.FAILURE.<br />
DBTOXML Parameters
Note: The XML options set previously at the session level through the<br />
XMLSETOPTIONS command or through the XMLSetOptions() API are used when<br />
you run the DBTOXML API in the current UniData session.<br />
DBTOXML 1-190
DCOUNT<br />
Syntax<br />
DCOUNT(str,delim)<br />
Description<br />
The <strong>UniBasic</strong> DCOUNT function returns the number of substrings delimited by<br />
delim in a string. If str is an empty string, UniData returns 0. If str contains data but<br />
no delimiter, UniData returns 1. DCOUNT supports multibyte languages.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Paramete<br />
r Description<br />
Examples<br />
In the following example, the program segment finds three occurrences of the value<br />
mark and prints 3:<br />
STR = 123:@VM:456:@VM:789<br />
SUBS = DCOUNT(STR,@VM)<br />
PRINT SUBS<br />
In the next example, the program segment prints 1 because no delimiter is found in<br />
the string:<br />
STR = 123<br />
DCOUNT(STR,@VM)<br />
PRINT SUBS<br />
1-191 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
str Specifies the string to search for occurrences of substrings delimited by delim.<br />
delim Specifies the delimiter to use in searching str.<br />
DCOUNT Parameters
The following example prints 3:<br />
STR="A/B/C"<br />
PRINT DCOUNT(STR,"/")<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
COUNT, COUNTS<br />
DCOUNT 1-192
DEACTIVATEKEY<br />
Syntax<br />
DEACTIVATEKEY , [ON ] [ON ERROR<br />
]<br />
Description<br />
Use the DEACTIVATEKEY command to deactivate a key or a wallet. This command<br />
is useful to deactivate keys to make your system more secure.<br />
Note: You can deactivate only keys with password protection with this command.<br />
Keys that do not have password protection are automatically activated and cannot be<br />
deactivated.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-193 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
key.id The key ID or wallet ID to deactivate. If you provide a Wallet ID,<br />
UniData deactivates all keys in the wallet.<br />
DEACTIVATEKEY Parameters
Parameter Description<br />
password The password corresponding to key.id.<br />
ON NFA_SERVER The name of the NFA_SERVER on which you want to<br />
deactivate the encryption key. The syntax for NFA_SERVER<br />
can be either:<br />
@domain.var where domain.var specifies the ID for a VOC<br />
entry that contains the NFA server connection parameters.<br />
OR<br />
“MACHINE PORT [, UDTHOME<br />
]”<br />
NFA files are always encrypted and decrypted on the remote<br />
machine by the NFA server.<br />
ON ERROR statements If you specify ON ERROR statements and an error occurs,<br />
UniData executes the statements following the ON ERROR<br />
clause. Otherwise, UniData executes the next statement.<br />
STATUS Codes<br />
The DEACTIVATEKEY statement rerurns the following STATUS codes regarding<br />
wallet operations:<br />
STATUS<br />
Code<br />
DEACTIVATEKEY Parameters (continued)<br />
Description<br />
0 Operation successful<br />
1 Key is already activated or deactivated. This applies to a single key, not<br />
a wallet operation<br />
2 Operation failed. This applies to a single key, not a wallet operation<br />
3 Invalid wallet ID or password<br />
4 No access to wallet<br />
DEACTIVATEKEY STATUS Codes<br />
DEACTIVATEKEY 1-194
STATUS<br />
Code<br />
Example<br />
The following example illustrates deactivating an encryption key:<br />
1-195 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Description<br />
5 Invalid key ID or password<br />
6 No access to one of the keys in the wallet<br />
9 Other error<br />
DEACTIVATEKEY STATUS Codes (continued)<br />
DEACTIVATEKEY "test","myunidata" ON ERROR PRINT "Unable to deactivate key"
DEBUG<br />
Syntax<br />
DEBUG<br />
Description<br />
The <strong>UniBasic</strong> DEBUG command stops program execution, turns control over to the<br />
interactive <strong>UniBasic</strong> debugger, and then displays the debugger prompt (!). Pressing<br />
the interrupt key also gives control to the debugger. For information about the<br />
<strong>UniBasic</strong> debugger, see Using the <strong>UniBasic</strong> Debugger.<br />
To use the DEBUG command to display the contents of variables, you must compile<br />
the program with the D option.<br />
Note: The setting of UDT.OPTIONS 14 determines where to return control after<br />
exiting a <strong>UniBasic</strong> program when you are using the <strong>UniBasic</strong> debugger and enter<br />
ABORT or END. For information about UDT.OPTIONS, see the UDT.OPTIONS<br />
<strong>Commands</strong> <strong>Reference</strong>.<br />
When you enter the debugger, a message similar to the following displays, and the<br />
cursor is placed at the debugger prompt:<br />
DEBUGGER called before line 1 of program BP/TEST<br />
!<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
ABORT<br />
UniData<br />
BASIC, DEBUG.FLAG, DEBUGLINE.ATT, DEBUGLINE.DET, ON.ABORT,<br />
RUN, SETDEBUGLINE, UNSETDEBUGLINE – For information, see the UniData<br />
<strong>Commands</strong> <strong>Reference</strong>.<br />
DEBUG 1-196
DEFFUN<br />
Syntax<br />
DEFFUN function.name [([MAT] arg.1[,[MAT]arg.2]...)]<br />
[CALLING catalog.name]<br />
Description<br />
The <strong>UniBasic</strong> DEFFUN command declares a user-written function, making the<br />
function available in a <strong>UniBasic</strong> program. You must declare the function before you<br />
can use it in a program.<br />
Note: You also must define the function with the <strong>UniBasic</strong> FUNCTION command in<br />
a separately cataloged file before you can call it.<br />
Function Naming<br />
The function name used in the DEFFUN statement must be the same as the name of<br />
the cataloged file that contains the FUNCTION statement. Either of the following<br />
statements declares the function cataloged under the name func.name:<br />
1-197 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
DEFFUN func.name(arg, arg,...)<br />
DEFFUN name(arg, arg,...) CALLING func.name<br />
Within the calling program, the name used in the DEFFUN statement and the name<br />
used to call the function must be the same. This does not need to be the same name<br />
as the cataloged program file or the name used in the FUNCTION statement.
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
function.name Specifies the function name that the calling statement uses in<br />
this program.<br />
(MAT arg.1 ,MAT<br />
arg.2...)<br />
Examples<br />
Specifies the arguments to be passed to the function. You must<br />
enclose arguments in parentheses and separate them with<br />
commas. Precede an argument with MAT to indicate that the<br />
argument is an array.<br />
CALLING file.name Specifies the function’s cataloged file name. Include this<br />
statement if the cataloged program name differs from<br />
function.name. Can be a literal or variable.<br />
DEFFUN Parameters<br />
The DEFFUN statement in the following example declares myfunc. The CALLING<br />
clause indicates that the name of the cataloged file that contains the FUNCTION<br />
statement is called yourfunc. In the first print statement, the function is called and the<br />
return value is printed.<br />
DEFFUN myfunc(a, MAT b, c) CALLING "yourfunc" ;* Declare function.<br />
DIM b(10) ;* Define array.<br />
a = 2 ;* Set upper bound.<br />
FOR i = 1 TO a ;* Initialize array.<br />
b(i) = i<br />
NEXT i<br />
PRINT "r from FUNCTION: ":myfunc(a, MAT b, c)<br />
PRINT "c from FUNCTION: ":c<br />
DEFFUN 1-198
The preceding program calls the following function. The name of this cataloged file<br />
is yourfunc. This is the name that must match the DEFFUN statement in the program<br />
above. Notice that the function definition uses yet another name for the function<br />
(anotherfunc).<br />
1-199 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
FUNCTION anotherfunc(a, MAT b, c) ;* Start function<br />
definition.<br />
DIM b(-1) ;* Declare array.<br />
r = 0 ;* Initialize return value.<br />
c = 1 ;* Initialize value passed<br />
back.<br />
FOR i = 1 TO a ;* To the upper bound passed<br />
in:<br />
r += b(i) ;* Sum array members.<br />
c *= b(i) ;* Multiply array members.<br />
NEXT i<br />
RETURN r ;* Return value.<br />
The following screen example shows the command that runs the program and the<br />
output from the program:<br />
:RUN BP FUNCTION.CALL<br />
r from FUNCTION: 3<br />
c from FUNCTION: 2<br />
The following example calls a user-defined function named CALC.SALES.TAX:<br />
PRINT @(-1)<br />
DEFFUN CALC.SALES.TAX(arg.1,arg.2)<br />
PROMPT ''<br />
PRINT 'Enter county name':;INPUT COUNTY.NAME<br />
PRINT 'Enter sales amount ':;INPUT SALES.AMT<br />
TAX.AMT=0<br />
TAX.AMT=CALC.SALES.TAX(COUNTY.NAME,SALES.AMT)<br />
PRINT 'County name =':COUNTY.NAME<br />
PRINT 'Sales amount =':SALES.AMT<br />
PRINT 'Tax amount =':TAX.AMT<br />
END<br />
Related Command<br />
<strong>UniBasic</strong><br />
FUNCTION
DEL<br />
Syntax<br />
DEL dyn.array.var <br />
Description<br />
The <strong>UniBasic</strong> DEL command deletes an attribute, value, or subvalue from a dynamic<br />
array. The corresponding delimiter is also removed.<br />
The DELETE function and the DEL command perform the same action.<br />
Warning: DEL destroys the data and the corresponding delimiters. Use the DEL<br />
command with caution.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dyn.array.var Specifies the dynamic array on which to perform the delete operation.<br />
attrib.expr Specifies which attribute of the dynamic array to delete. If val.expr is<br />
omitted, DEL deletes the entire attribute, including all values and<br />
subvalues.<br />
,val.expr Specifies which value of the dynamic array attribute to delete. If<br />
subval.expr is omitted, DEL deletes the entire value, including the<br />
subvalues.<br />
,subval.expr Specifies which subvalue of the dynamic array attribute value to delete.<br />
DEL Parameters<br />
DEL 1-200
Examples<br />
The following program segment is taken from “Appendix A, Sample Program” of<br />
Developing <strong>UniBasic</strong> Applications. It deletes the attribute in the variable POSITION.<br />
This removes one order for a particular client from the CLIENTS file in the demo<br />
database.<br />
1-201 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><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 />
In the following example, the program segment deletes the third attribute of the<br />
dynamic array ARRAY1. The attribute removed is ‘Anne’.<br />
ARRAY1 = '#543':@AM:'Dorothy':@AM:'Anne':@AM:'Parker'<br />
DEL ARRAY1<br />
In the following example, the statement is invalid. The DEL statement has too many<br />
parameters:<br />
ARRAY1 = '#543':@AM:'Dorothy':@AM:'Anne':@AM:'Parker'<br />
DEL ARRAY<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DELETE, EXTRACT, INSERT, REMOVE, REPLACE, SUBSTRINGS
DELETE<br />
Syntax<br />
DELETE [file.var,] record.ID.expr [ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> DELETE command deletes a record from a UniData file. In addition,<br />
the DELETE command releases any locks on the record that have been set by<br />
previous commands.<br />
Note: The DELETEU command also deletes a record, but it does not release locks.<br />
This is the only difference between DELETE and DELETEU statements.<br />
<strong>UniBasic</strong> locks are advisory only. For more information,see Developing <strong>UniBasic</strong><br />
Applications.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
file.var Specifies the file from which to delete the record.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal DELETE error occurs.<br />
A default file is one for which no file variable is assigned in the<br />
OPEN statement.<br />
record.ID.expr Specifies the record to delete.<br />
ON ERROR statements Specifies <strong>UniBasic</strong> statements to execute if the DELETE<br />
statement fails because UniData cannot find the file, or a<br />
default file is not open. If you do not specify the ON ERROR<br />
clause, the program terminates.<br />
DELETE Parameters<br />
DELETE 1-202
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
DELETE<br />
Syntax<br />
DELETE(dyn.array, attrib.expr[,val.expr [,subval.expr]])<br />
Description<br />
The <strong>UniBasic</strong> DELETE function deletes an attribute, value, or subvalue from a<br />
dynamic array. The corresponding delimiter is also removed.<br />
The DELETE function and the DEL command perform the same action.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dyn.array.var Specifies the dynamic array from which to delete.<br />
attrib.expr Specifies which attribute of the dynamic array to delete. If val.expr is<br />
omitted, DELETE deletes the entire attribute, including all values and<br />
subvalues.<br />
,val.expr Specifies which value of the dynamic array attribute to delete. If<br />
subval.expr is omitted, DELETE deletes the entire value, including all<br />
subvalues.<br />
,subval.expr Specifies which subvalue of the dynamic array attribute value to delete.<br />
DELETE Parameters<br />
Examples<br />
In this first example, the program segment deletes the first attribute (125) and the<br />
attribute mark from the dynamic array ARRAY:<br />
ARRAY = 125:@AM:1:@VM:62:@VM:3:@AM:132:@VM:4:@VM:5:@SM:1<br />
ARRAY=DELETE(ARRAY,1,0,0)<br />
DELETE 1-204
In the next example, the program statement removes the first subvalue of the first<br />
value of the second attribute in ARRAY. The modified array is assigned to ARRAY2.<br />
ARRAY2=DELETE(ARRAY,2,1,1)<br />
In the next example, the program segment deletes the third attribute, including A, B,<br />
and C:<br />
1-205 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ARRAY = 1:@AM:2:@AM:'A':@VM:'B':@VM:'C'<br />
ARRAY = DELETE(ARRAY,3,0,0)<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DEL, DELETE, DELETEU
DELETELIST<br />
Syntax<br />
DELETELIST list.name.expr<br />
Description<br />
The <strong>UniBasic</strong> DELETELIST command deletes a saved select list.<br />
Select lists are saved by the UniQuery SAVE.LIST command and the <strong>UniBasic</strong><br />
WRITELIST command.<br />
list.name.expr is the name of the saved list to be deleted. If the list you specify cannot<br />
be found, UniData displays an error message and takes no action.<br />
Example<br />
The following statement deletes the saved list CUST in the current account:<br />
DELETELIST "CUST"<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
FORMLIST, READLIST, SELECT, SELECTINDEX, SELECTINFO,<br />
WRITELIST<br />
UniQuery<br />
DELETE.LIST, GET.LIST, SAVE.LIST, SELECT, SSELECT – For information, see<br />
the UniQuery <strong>Commands</strong> <strong>Reference</strong>.<br />
DELETELIST 1-206
UniData SQL<br />
SELECT – For information, see the UniData SQL <strong>Commands</strong> <strong>Reference</strong>.<br />
1-207 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
DELETEU<br />
Syntax<br />
DELETEU [file.var,] record.ID.expr [ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> DELETEU command deletes the specified record from a UniData file.<br />
The DELETEU command retains record locks that were set by the same user process.<br />
This allows UniData to delete a record and re-create it while retaining a lock on it.<br />
Note: The DELETE command also deletes a record, but it releases locks. This is the<br />
only difference between DELETE and DELETEU statements.<br />
<strong>UniBasic</strong> locks are advisory only. For information about UniData file and record<br />
locks, see Developing <strong>UniBasic</strong> Applications.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
file.var, Specifies the file from which to delete the record.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal DELETE error occurs.<br />
A default file is one for which no file variable is assigned in the<br />
OPEN statement.<br />
record.ID.expr Specifies the record to delete.<br />
ON ERROR statements Specifies <strong>UniBasic</strong> statements to execute if the DELETE<br />
statement fails because UniData cannot find the file, or a<br />
default file is not open. If you do not specify the ON ERROR<br />
clause, the program terminates.<br />
DELETEU Parameters<br />
DELETEU 1-208
Examples<br />
In the following example, the statement eliminates the record with the record ID of<br />
JONES from the most recently opened default file:<br />
DELETEU "JONES"<br />
The following segment deletes the record. The record ID is stored in the variable<br />
DEL_ID. The file was opened to the variable DISCOUNT.<br />
DEL_ID = "ACTION_FILMS"<br />
DELETEU DISCOUNT, DEL_ID<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DEL, DELETE, DELETE function, RELEASE<br />
1-209 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
DIM<br />
Syntax<br />
DIM name1(rows[,cols]) [,name2(rows[,cols])]...<br />
Synonym<br />
DIMENSION<br />
Description<br />
The <strong>UniBasic</strong> DIM command creates and determines the dimensions of a dimensioned<br />
array. You can specify arrays with one dimension (rows) or two dimensions<br />
(rows or rows, cols). In addition, the following limitations apply:<br />
You must dimension any array before you use it within a program.<br />
Zero elements other than 0,0 (such as 0,5 or 1,0) are invalid.<br />
The maximum number of elements you can specify is based on the total<br />
amount of virtual memory available on your system.<br />
Arrays passed to a subroutine cannot be redimensioned within the<br />
subroutine.<br />
For information about system configurations, see Administering UniData on UNIX<br />
or Administering UniData on Windows Platforms.<br />
MATREAD, MATWRITE, and MATPARSE load and empty an array from left to<br />
right and from top to bottom beginning with element 1,1 and ending by placing<br />
excess data in element 0,0.<br />
Note: BASICTYPEs M and P do not support position 0,0 in arrays. You could lose<br />
data if an array is too small for the amount of data you are attempting to load into it<br />
with MATPARSE.<br />
DIM 1-210
Parameters<br />
The following table describes each parameter of the syntax.<br />
Paramete<br />
r Description<br />
INMAT Function Return Values<br />
After you execute DIM, the <strong>UniBasic</strong> INMAT function returns one of the values<br />
described in the following table.<br />
Resizing Arrays<br />
You can use the DIM statement to dynamically redimension an array without losing<br />
any data if the size of the redimensioned array is large enough to contain all data in<br />
the original array. When you redimension, <strong>UniBasic</strong> places the old data elements into<br />
the new array from left to right and from top to bottom. All leftover data is placed in<br />
the 0,0 element.<br />
1-211 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
name1 Specifies the name of the array.<br />
rows Specifies the number of rows in the array.<br />
,cols Specifies the number of columns in the array. If cols is omitted, the array is<br />
one-dimensional.<br />
DIM Parameters<br />
Value Description<br />
0 The dimensioned array was not created. UniData returns an error message, but<br />
program execution continues.<br />
1 Memory was insufficient to create the dimensioned array. UniData returns an error<br />
message, but program execution continues.<br />
n The dimensioned array was created. n is the number of elements in the array.<br />
INMAT Function Return Values
Although you can change the size of an array during program execution, its configuration<br />
cannot change. For example, a two-dimensional array cannot be changed to<br />
one-dimensional and vice versa.<br />
Examples<br />
In the following example, the program statement creates three arrays: one-dimensional<br />
NAME, one-dimensional TITLES, and two-dimensional DATES.<br />
DIM NAME(100),TITLES(100),DATES(100,2)<br />
In the next example, two DIMENSION statements are included in the same program,<br />
although because the new array is smaller than the original, all excess data is placed<br />
in element 0,0. After the execution of the second DIMENSION statement, the array<br />
has the dimension of 100 by 10.<br />
DIM WAGES(50,100)<br />
DIM WAGES(100,10)<br />
The following program segment creates the array TEST by setting variable A to 30,<br />
and then declaring TEST as a one-dimensional array of 30 elements:<br />
A = 30<br />
DIM TEST (A)<br />
The following sample code is invalid because array size is declared with nonnumeric<br />
variables “(” and “)” and because you cannot use a variable in a dimension statement:<br />
TEST = "(10,5)"<br />
DIM TEST<br />
In contrast, the following statement is valid:<br />
DIM TEST (10,5)<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
INMAT, MAT, MATBUILD, MATPARSE, MATREAD, MATREADL,<br />
MATREADU, MATWRITE, MATWRITEU<br />
DIM 1-212
DIGEST<br />
Syntax<br />
DIGEST(algorithm, data, dataLoc, result)<br />
Description<br />
The DIGEST function generates a message digest of supplied data. A message digest<br />
is the result of a one-way hash function (digest algorithm) performed on the message.<br />
Message digest has the unique properties that alight change in the input results in a<br />
significant difference in the resulting digest. Therefore, the probability of two<br />
different messages resulting in the same digest (collision) is very unlikely. It is also<br />
virtually impossible to reverse to the original message from a digest. Message digest<br />
is widely used for digital signatures and other purposes.<br />
The desired digest algorithm is specified in algorithm. You specify data and its<br />
location are with data and dataLoc, respectively. UniData puts the arrived digest into<br />
a dynamic array in result. Since digest is short and has a fixed length, it is always put<br />
into a string, and no file option is provided. The result can be in either binary or hex<br />
format.<br />
1-213 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
algorithm A string containing the digest algorithm name (uppercase or lowercase).<br />
UniData supports the following algorithms:<br />
“md2”<br />
“md4”<br />
“md5”<br />
“mdc2”<br />
“rmd160”<br />
“sha”<br />
“sha1”<br />
data Data or the name of the file containing the data to be digested.<br />
dataLoc 1 - Data in a string<br />
2 - Data in a file<br />
result A string to store the digest result.<br />
DIGEST Parameters<br />
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success<br />
1 Unsupported digest algorithm<br />
2 The data file cannot be read<br />
3 Message digest cannot be obtained<br />
4 Invalid parameters<br />
Return Code Status<br />
DIGEST 1-214
DIR<br />
Syntax<br />
DIR(file.expr)<br />
Description<br />
The <strong>UniBasic</strong> DIR function returns the file size (in bytes), the last date and time the<br />
file was modified (in internal format), and the privileges for the file. UniData stores<br />
these values in the first four attributes of the return value. file.expr must evaluate to<br />
a file name at the operating system level. If you do not specify a path, UniData<br />
searches the current directory.<br />
Example<br />
The following UNIX program segment retrieves the file statistics on the UniData file<br />
stored in the subdirectory /usr/accounting/gl. The first attribute contains the file size<br />
in bytes, the second attribute contains the date the file was last updated, and the third<br />
attribute contains the time the file was last updated. UniData stores the second and<br />
third attributes in internal format, and the example converts them to the external<br />
format.<br />
1-215 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
FILESTAT = DIR("/usr/accounting/gl")<br />
SIZE = FILESTAT <br />
DATE.MOD = OCONV(FILESTAT,'D2/')<br />
TIME.MOD = OCONV(FILESTAT,'MT')<br />
PRINT 'The gl file is ':SIZE<br />
PRINT 'And was last modified: ':DATE.MOD,TIME.MOD
DISABLEDEC<br />
Syntax<br />
DISABLEDEC [, ], [ON ERROR<br />
]<br />
Description<br />
Use the DISABLEDEC command to turn off decryption on a file or fields you<br />
specify.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
filename The name of the file on which you want to disable decryption.<br />
field_list A comma-separated list of fields for which you want to disable<br />
decryption. Do not enter spaces between the field names.<br />
ON ERROR statements If you specify ON ERROR statements and an error occurs,<br />
UniData executes the statements following the ON ERROR<br />
clause. Otherwise, UniData executes the next statement.<br />
DISABLEDEC Parameters<br />
DIR 1-216
STATUS Codes<br />
DISABLEDEC has the following STATUS codes:<br />
STATUS<br />
Code Description<br />
Example<br />
The following example illustrates disabling decryption on two fields in a file using a<br />
quoted string:<br />
1-217 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
0 No error, operation successful<br />
1 Decryption is already disabled<br />
2 General operation failure, such as an open file error<br />
3 File is not an encrypted file<br />
4 Attempting operation on a WHOLERECORD encrypted file<br />
5 Field(s) is not an encrypted field<br />
6 Cannot locate information to disable decryption<br />
7 Field is not a valid field in this file<br />
DISABLEDEC STATUS Codes<br />
DISABLEDEC "CUSTOMER","NAME,PHONE" ON ERROR PRINT "Unable to disable<br />
decryption<br />
The next example illustrates disabling decryption on two fields using variables:<br />
CUST="CUSTOMER"<br />
FIELDS="NAME,PHONE"<br />
DISABLEDEC CUST,FIELDS ON ERROR PRINT "Unable to disable decryption"
DISPLAY<br />
DISPLAY is a synonym for the CRT command. For further information, see CRT.<br />
Synonym<br />
CRT<br />
DISPLAY 1-218
DISPLAYWIDTH<br />
Syntax<br />
DISPLAYWIDTH (string)<br />
Description<br />
The <strong>UniBasic</strong> DISPLAYWIDTH function returns the number of bytes needed to<br />
display a string expression. For instance, the display width of English characters is<br />
one. In languages that use multibyte characters, the display width of a character can<br />
be 1, 2, 3, or 4 bytes, depending on the language and the character.<br />
Example<br />
The following illustration shows a string that indicates below each “character” the<br />
number of bytes required to display that character. The string contains eight bytes.<br />
Therefore, DISPLAYWIDTH would return 8 for this string.<br />
Number<br />
of bytes<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
BYTELEN, CHARLEN, ISMB, LEN, MBLEN<br />
1-219 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
2 3 1 2
DOWNCASE<br />
Syntax<br />
DOWNCASE(str.expr)<br />
Description<br />
The <strong>UniBasic</strong> DOWNCASE function converts all characters in a string (str.expr) to<br />
lowercase. Special characters, including the null value, are not converted by this<br />
function. DOWNCASE does not convert multibyte characters.<br />
Example<br />
In the following example, the program segment converts the contents of the variable<br />
USTRING to lowercase letters:<br />
USTRING = "WHY am I HAPPY?"<br />
DSTRING = DOWNCASE(USTRING)<br />
DSTRING now contains “why am i happy?”.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
ICONV Masked Character (MC), OCONV Masked Character (MC), UPCASE<br />
DOWNCASE 1-220
DQUOTE<br />
DQUOTE is a synonym for the QUOTE function. For more information, see<br />
QUOTE.<br />
Synonym<br />
QUOTE<br />
1-221 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
DROUND<br />
Syntax<br />
DROUND(val.expr [,precision.expr])<br />
Description<br />
The <strong>UniBasic</strong> DROUND function performs double-precision rounding on a value.<br />
Double-precision rounding uses two words to store a number, accommodating a<br />
larger number than in single-precision rounding, which stores each number in a<br />
single word.<br />
Note: DROUND affects the internal representation of the numeric value. It performs<br />
the rounding without conversion to and from string variables. This increases the<br />
speed of calculation.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
val.expr Specifies the value to round.<br />
,precision.expr Specifies the precision for the rounding. The valid range is 0 to 14.<br />
Default precision is four places.<br />
DROUND Parameters<br />
Example<br />
In the following example, the DROUND statement results in 18.84955596. The<br />
equation is resolved, and then the result is rounded to eight decimal places.<br />
A= DROUND((3.14159265999*2*3),8)<br />
PRINT A<br />
DROUND 1-222
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
PRECISION<br />
UniData<br />
FLOAT.PRECISION – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
1-223 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
EBCDIC<br />
Syntax<br />
EBCDIC(expr)<br />
Description<br />
The <strong>UniBasic</strong> EBCDIC (Extended Binary Coded Decimal Information Code)<br />
function converts the ASCII (American Standard Code for Information Interchange)<br />
data in expr to its corresponding EBCDIC values.<br />
Note: BASICTYPE U, the standard application, converts data to EBCDIC format<br />
before the data is written to tape.<br />
Example<br />
In the following example, the program statement first prints a message, and then<br />
prints the EBCDIC equivalent of the ASCII variable VAL:<br />
PRINT "EBCDIC equivalent":EBCDIC(VAL)<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
ASCII, CHAR, CHARS, SEQ<br />
EBCDIC 1-217
ECHO<br />
Syntax<br />
ECHO [ON | OFF | expr]<br />
Description<br />
The <strong>UniBasic</strong> ECHO command controls whether characters display on the terminal<br />
screen as you type them on the keyboard.<br />
Tip: Use ECHO for security purposes when the entry of an ID or password should<br />
not display on the terminal screen.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Example<br />
The following program segment enables echoing because A+B is not 0:<br />
A = 1<br />
B = 3<br />
ECHO A+B<br />
1-218 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ON Enables the display of characters as you type them on the keyboard.<br />
OFF Disables the display of characters as you type them on the keyboard.<br />
expr When expr is 0, ECHO is set to OFF. When expr is not 0, ECHO is set to<br />
ON. expr must be numeric.<br />
ECHO Parameters
EDADRV_Cleanup<br />
Syntax<br />
RETCODE EDADRV_Cleanup<br />
Description<br />
This is the last function that EDA calls. This function frees all allocated memory and<br />
all handles to the external database, closes all files, and frees the driver environment.<br />
Return Codes<br />
The following table describes the EDADRV_Cleanup return codes.<br />
Return<br />
Code Error Description<br />
0 N/A Successful.<br />
EDADRV_Cleanup Return Codes<br />
EDADRV_Cleanup 1-219
EDADRV_CloseStmt<br />
Syntax<br />
RETCODE EDADRV_CloseStmt(stmthdl)<br />
Description<br />
Once a cursor is opened by the execution of the EDADRV_ExecuteStmt function, it<br />
remains open even after all the rows have been fetched. The<br />
EDADRV_CloseStatement closes any open cursors associated with the statement<br />
handle.<br />
Warning: The result buffer allocated by the EDADRV_FetchStmt function should not<br />
be freed by this function, it can only be freed by the EDADRV_FreeResult function.<br />
Input Variable<br />
The following table describes the input parameter.<br />
1-220 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Type Argument Description<br />
EDA_T_STMT_HDL stmthdl<br />
EDADRV_CloseStmt<br />
Statement handle.
Return Codes<br />
The following table describes the EDADRV_CloseStmt return codes.<br />
Return<br />
Code Error Description<br />
0 N/A Successful.<br />
1 EDADRV_ERR_SYSTEM External system error.<br />
103 EDADRV_INVALID_STMT_ID Invalid statement handle.<br />
EDADRV_CloseStmt Return Codes<br />
EDADRV_CloseStmt 1-221
EDADRV_Connect<br />
Syntax<br />
RETCODE EDADRV_Connect(connhdl,datasource,login_name,password)<br />
Description<br />
The EDADRV_Connect function makes a connection to an external database.<br />
Input Variables<br />
The following table describes the input variables.<br />
Output Variable<br />
The following table describes the output variable.<br />
1-222 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Type Argument Description<br />
char * datasource The name of the data source.<br />
char * login_name The user login name.<br />
char * password The password corresponding to the login name.<br />
EDADRV_Connect Input Variables<br />
Type Argument Description<br />
EDA_T_CONN_HDL * connhdl The connection handle.<br />
EDADRV_Connect Output Variable
Return Codes<br />
The following table describes the EDADRV_Connect return codes.<br />
Return<br />
Code Error Description<br />
0 N/A Successful.<br />
1 EDADRV_ERR_SYSTEM External system error.<br />
101 EDADRV_ERR_MEMORY Internal memory allocation error.<br />
EDADRV_Connect Return Codes<br />
EDADRV_Connect 1-223
EDADRV_Disconnect<br />
Syntax<br />
RETCODE EDADRV_Disconnect(connhdl)<br />
Description<br />
The EDADRV_Disconnect function disconnects from an external database and<br />
releases the connection handle.<br />
Input Variable<br />
The following table describes the input variable.<br />
Return Codes<br />
The following table describes the EDADRV_Disconnect return codes.<br />
1-224 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Type Argument Description<br />
EDA_T_CONN_HDL connhdl The connection handle.<br />
EDADRV_Disconnect Input Variable<br />
Return<br />
Code Error Description<br />
0 N/A Successful.<br />
1 EDADRV_ERR_SYSTEM External system error.<br />
102 EDADRV_INVALID_CONN_ID Invalid connection handle.<br />
EDADRV_Disconnect Return Codes
EDADRV_DropStmt<br />
Syntax<br />
RETCODE EDADRV_DropStmt(stmthdl)<br />
Description<br />
The EDADRV_DropStmt function closes any open cursors associated with the<br />
statement handle and makes the SQL statement unavailabe for any future use.<br />
Warning: The result buffer allocated by the EDADRV_FetchStmt function should not<br />
be freed by this function, it can only be freed by the EDADRV_FreeResult function.<br />
Input Variable<br />
The following table describes the input parameter.<br />
Type Argument Description<br />
EDA_T_STMT_HDL stmthdl<br />
EDADRV_DropStmt<br />
Statement handle.<br />
Return Codes<br />
The following table describes the EDADRV_DropStmt return codes.<br />
Return<br />
Code Error Description<br />
0 N/A Successful.<br />
1 EDADRV_ERR_SYSTEM External system error.<br />
103 EDADRV_INVALID_STMT_ID Invalid statement handle.<br />
EDADRV_DropStmt Return Codes<br />
EDADRV_DropStmt 1-225
1-226 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
EDADRV_EndTransaction<br />
Syntax<br />
RETCODE EDADRV_EndTransaction(connhdl,trans_flag)<br />
Description<br />
The EDADRV_EndTransaction function commits or rolls back a transaction on the<br />
external database, depending on the value of trans_flag.<br />
Input Variables<br />
The following table describes the input variables.<br />
Type Argument Description<br />
EDA_T_CONN_HDL connhdl The connection handle.<br />
int trans_flag The action to take if the transaction ends. Valid<br />
values are:<br />
0 – EDA_COMMIT. Commit the<br />
transaction.<br />
1 – EDA_ROLLBACK. Rollback the<br />
transaction.<br />
EDADRV_EndTransaction Input Variables<br />
EDADRV_EndTransaction 1-227
Return Codes<br />
The following table describes the EDADRV_EndTransaction return codes.<br />
1-228 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return<br />
Code Error Description<br />
0 N/A Successful.<br />
1 EDADRV_ERR_SYSTEM External system error.<br />
102 EDADRV_INVALID_CONN_ID Invalid connection handle.<br />
114 EDADRV_INVALID_TRANS_FLAG Invalid END TRANSACTION<br />
flag.<br />
EDADRV_EndTransaction Return Codes
EDADRV_ExecuteStmt<br />
Syntax<br />
RETCODE EDADRV_ExecuteStmt(stmthdl,parameters,rowcount)<br />
Description<br />
EDA calls the EDADRV_ExecuteStmt function to execute an SQL statement that has<br />
been prepared with EDA_PrepareStmt.<br />
EDA provides parameter values for each input and input/output parameter. Parameter<br />
values are supplied in a string format, separated by field marks. The value of the field<br />
mark is determined by calling the EDADRV_GetADDAttr function. The<br />
EDADRV_ExecuteStmt function binds each parameter and executes a statement that<br />
has already been prepared with the EDADRV_PrepareStmt function. If the statement<br />
is INSERT, UPDATE, or DELETE (statement type EDASTMT_DML), the output<br />
variable rowcount contains the number of rows affected by the operation. If the<br />
statement is a query (statement type EDASTMT_QUERY), rowcount contains the<br />
number of columns of the result set. If the statement is a stored procedure (statement<br />
type EDASTMT_PROCEDURE), rowcount is not set.<br />
Input Variables<br />
The following table describes the input variables.<br />
Type Argument Description<br />
EDA_T_STMT_HDL stmthdl The statement handle.<br />
EDA_T_STRING parameters The statement parameters.<br />
EDADRV_ExecuteStmt Input Variables<br />
EDADRV_ExecuteStmt 1-229
Output Variable<br />
The following table describes the output variable.<br />
Return Codes<br />
The following table describes the EDADRV_ExecuteStmt return codes.<br />
1-230 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Type Argument Description<br />
int * rowcount The number of the rows affected by the INSERT, UPDATE,<br />
or DELETE statement, or the number of columns in the result<br />
set, or the values of output and input/output parameters of a<br />
stored procedure.<br />
EDADRV_ExecuteStmt Output Variable<br />
Return<br />
Code Error Description<br />
0 N/A Successful.<br />
1 EDADRV_ERR_SYSTEM External system error.<br />
2 EDADRV_SYSERR_OBJ_EXIST Object already exists.<br />
101 EDADRV_ERR_MEMORY Internal memory allocation error.<br />
103 EDADRV_INVALID_STATEMENT_ID Invalid statement handle.<br />
111 EDADRV_INVALID_PARAM_TYPE Invalid parameter type<br />
112 EDADRV_INVALID_DATATYPE Invalid data type<br />
113 EDADRV_TOO_MANY_OUT_PARAM Too many output parameters.<br />
EDADRV_ExecuteStmt Return Codes
EDADRV_FetchStmt<br />
Syntax<br />
RETCODE EDADRV_FetchStmt(stmthdl,direction,numrows,rowsfetched,<br />
result)<br />
Description<br />
The EDADRV_FetchStmt function fetches numrows rows from an open cursor.<br />
Currently, EDA only uses forward scrolling. EDA expects the result set to be returned<br />
in a string format. The rows of the result are separated with record marks<br />
(EDADRV_ATTR_RM) and column values within each row separated with the<br />
NULL character (“\0”).<br />
In order to hold the result set, the EDADRV_FetchStmt function allocates a buffer.<br />
This buffer can only be freed by the EDADRV_FreeResult function.<br />
Input Variables<br />
The following table describes the input variables.<br />
Type Variable Description<br />
EDA_T_STMT_HDL stmthdl The statement handle.<br />
int direction The fetch direction. Valid values are:<br />
0 – Fetch Forward<br />
int numrows The number of rows to fetch.<br />
EDADRV_FetchStmt Input Variables<br />
EDADRV_FetchStmt 1-231
Output Variables<br />
The following table describes the output variables.<br />
Return Codes<br />
The following table describes the EDADRV_FetchStmt return codes.<br />
1-232 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Type Variable Description<br />
int * rowsfetched The number of the row retrieved.<br />
EDA_T_RESULT * result The result string.<br />
EDADRV_FetchStmt Output Variables<br />
Return<br />
Code Error Description<br />
0 N/A Successful.<br />
1 EDADRV_ERR_SYSTEM External system error.<br />
101 EDADRV_ERR_MEMORY Internal memory allocation error.<br />
103 EDADRV_INVALID_STMT_ID Invalid cursor handle.<br />
104 EDADRV_INVALID_FETCH_DIR Invalid fetch direction.<br />
EDADRV_FetchStmt Return Codes
EDADRV_FreeResult<br />
Syntax<br />
RETCODE EDADRV_FreeResult(buf)<br />
Description<br />
The buffer allocated by the EDADRV_FetchStmt or the EDADRV_Perform function<br />
is not freed until EDA calls the EDADRV_FreeResult function. The<br />
EDADRV_FreeResult function frees the result set buffer.<br />
Input Variable<br />
The following table describes the input variable.<br />
Return Codes<br />
Type Variable Description<br />
EDA_T_RESULT buf The result buffer<br />
EDADRV_FreeResult Input Variable<br />
The following table describes the EDADRV_FreeResult return codes.<br />
Return<br />
Code Error Description<br />
0 N/A Successful.<br />
EDADRV_FreeResult Return Codes<br />
EDADRV_FreeResult 1-233
EDADRV_GetDBInfo<br />
Syntax<br />
RETCODE EDADRV_GetDBInfo(connhdl,infotype,dbinfo)<br />
Description<br />
The EDADRV_GetDBInfo function returns general information about the database<br />
to which the application is currently connected.<br />
Input Variables<br />
The following table describes the input variables.<br />
1-234 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Type Variable Description<br />
EDA_T_CONN_HDL connhdl The connection handle.<br />
int infotype The information type. Valid values are:<br />
EDADRV_DBMS_NAME – The name of the<br />
database<br />
EDADRV_DBMS_VERSION – The database<br />
version.<br />
EDADRV_SERVER_NAME – The name of<br />
the instance on the external database.<br />
EDADRV_DATABASE_NAME – The name<br />
of the database.<br />
EDADRV_GetDBInfo Input Variables
Output Variable<br />
The following table describes the output variable.<br />
Type Variable Description<br />
EDA_T_RESULT * dbinfo The database information.<br />
EDADRV_GetDBInfo Output Variable<br />
Return Codes<br />
The following table describes the EDADRV_GetDBInfo return codes.<br />
Return<br />
Code Error Description<br />
0 N/A Successful.<br />
1 EDADRV_ERR_SYSTEM External system error.<br />
101 EDADRV_ERR_MEMORY Internal memory allocation error.<br />
102 EDADRV_INVALID_CONN_ID Invalid connection handle.<br />
115 EDADRV_INVALID_INFOTYPE Invalid information type.<br />
EDADRV_GetDBInfo Return Codes<br />
EDADRV_GetDBInfo 1-235
EDADRV_GetEDAAttr<br />
Syntax<br />
RETCODE EDADRV_GetEDAAttr(attribute_type,value)<br />
Description<br />
The EDADRV_GetEDAAttr function receives an attribute name – value pair.<br />
Valid values for the EDA driver attribute are:<br />
1-236 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Type Attribute Name Description<br />
EDADRV_T_STR EDADRV_ATTR_SYSNAME At this release, the only valid value<br />
is UniData.<br />
EDADRV_T_STR EDADRV_ATTR_VERSION Valid values are 7.1 or 7.2.<br />
EDADRV_T_INT EDADRV_ATTR_RM The ASCII character representing<br />
a record mark (RM), such as ^255.<br />
EDADRV_T_INT EDADRV_ATTR_FM The ASCII character representing<br />
a field mark (FM), such as ^254.<br />
EDADRV_T_INT EDADRV_ATTR_VM The ASCII character representing<br />
a value mark (VM), such as ^253.<br />
EDADRV_T_INT EDADRV_ATTR_SM The ASCII character representing<br />
a subvalue mark (SM), such as<br />
^252.<br />
EDADRV_T_INT EDADRV_ATTR_TM The ASCII character representing<br />
a text mark (TM), such as ^251.<br />
EDADRV_T_INT EDADRV_NULLVAL The ASCII character representing<br />
the null value.<br />
EDADRV_GetEDAAttr Values
Input Variables<br />
The following table describes the input variables.<br />
Type Variable Description<br />
int attribute_type The name of the EDA driver attribute.<br />
EDA_T_SYMBOL value The value for the EDA driver attribute.<br />
EDADRV_SetParam Input Variables<br />
Return Codes<br />
The following table describes the EDADRV_GetEDAAttr return codes.<br />
Return<br />
Code Error Description<br />
0 N/A Successful.<br />
105 EDADRV_INVALID_DRV_ATTR Invalid driver attribute.<br />
EDADRV_GetEDAAttr Codes<br />
EDADRV_GetDBInfo 1-237
EDADRV_GetErrmsg<br />
Syntax<br />
RETCODE EDADRV_GetErrmsg(errmsg)<br />
Description<br />
If the last driver function returned an error code, EDA calls this function to retrieve<br />
the corresponding error message string. If the error is returned from the external<br />
database, the driver returns this external database error. Otherwise, the driver should<br />
generate its own error message.<br />
Output Variable<br />
The following table describes the output variable.<br />
Return Codes<br />
The following table describes the EDADRV_GetErrmsg return codes.<br />
1-238 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Type Variable Description<br />
EDA_T_RESULT * errmsg The error message string.<br />
EDADRV_GetErrmsg Output Variable<br />
Return<br />
Code Error Description<br />
0 N/A Successful.<br />
1 EDADRV_ERR_SYSTEM External system error.<br />
101 EDADRV_ERR_MEMORY Internal memory allocation error.<br />
EDADRV_GetErrmsg Return Codes
EDADRV_GetSpecialInfo<br />
Syntax<br />
RETCODE EDADRV_GetSpecialInfo(infotype,parameters,dbinfo)<br />
Description<br />
EDA calls the EDADRV_GetSpecialInfo function to retrieve special information<br />
about the database to which it is currently connected, such as rename table, rename<br />
index, and BLOB data type equivalents.<br />
When you specify EDADRV_BLOB_FIELD as the infotype, do not specify the<br />
parameter input variable. The output parameter returns the data type for the BLOB<br />
field on the external database, followed by the separator ‘\0’ and ‘0’ or ‘1’ for<br />
precision. For example, DB2 returns ‘CLOB\01’ and SQL Server returns<br />
‘VARCHAR(MAX)\00.’<br />
When you specify EDADRV_RENAME_TABLE or EDADRV_RENAME_INDEX<br />
as the infotype, you must also specify both the source table or index name and the<br />
target table or index name, separated by “\0.” The output variable returns the rename<br />
table or rename index statement from the external database.<br />
When you specify EDADRV_DRIVER_INFO as the infotype, do not specify the<br />
parameter variable. The output parameter returns EDA driver information, including<br />
the EDA driver version, the supplier of the EDA driver, the date the EDA driver was<br />
created, the EDA driver target database name, and the EDA driver target database<br />
version.<br />
EDADRV_GetSpecialInfo 1-239
Input Variables<br />
The following table describes the input variables for the EDADRV_GetSpecialInfo<br />
function.<br />
Variable Description<br />
Output Variable<br />
The following table describes the output variable for the EDADRV_GetSpecialInfo<br />
function.<br />
1-240 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
infotype The information type. Valid values are:<br />
EDADRV_BLOB_FIELD – The data type for the BLOB<br />
field.<br />
EDADRV_RENAME_TABLE – The rename table statement.<br />
EDADRV_RENAME_INDEX – The rename index<br />
statement.<br />
EDADRV_DRIVER_INFO – information about the EDA<br />
driver.<br />
parameters The parameter array.<br />
EDADRV_GetSpecialInfo Input Variables<br />
Type Variable Description<br />
EDA_T_RESULT * dbinfo The database information.<br />
EDADRV_GetSpecialInfo Input Variables
Return Codes<br />
The following table describes the EDADRV_GetSpecialInfo return codes.<br />
Return<br />
Code Error Description<br />
0 N/A Successful.<br />
101 EDADRV_ERR_MEMORY Internal memory allocation error.<br />
115 EDADRV_INVALID_INFOTYPE Invalid information type.<br />
EDADRV_GetSpecialInfo Return Codes<br />
EDADRV_GetSpecialInfo 1-241
EDADRV_LoadSymbols<br />
Syntax<br />
RETCODE EDA_LoadSymbols(numsymbols, symbols)<br />
Description<br />
The EDADRV_LoadSymbols function loads other functions to the EDA Driver<br />
Symbol array. This is the first function EDA calls.<br />
The EDA Driver Symbol array is an array of structures of the type<br />
EDA_T_SYMBOL. It contains pointers to all other driver functions as array<br />
elements.<br />
EDADRV_LoadSymbols allocates memory for the Driver Symbol array, fills in the<br />
array with either pointers to other driver functions or constants according to the<br />
following template.<br />
1-242 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Array<br />
Index Array Element Value Description<br />
0 EDASYM_DBTYPE The driver’s data model. At this<br />
release, UniData only supports<br />
EDA_1NF.<br />
1 EDASYM_DBFAMILY The name of the driver database, such<br />
as DBMS_DB2,<br />
DBMS_MSSQLSERVER,<br />
DBMS_OTHERS.<br />
2 EDASYM_VERSION The version of this driver. This is for<br />
information purposes only, EDA does<br />
not use this value.<br />
3 EDASYM_CONNECT The pointer to EDADRV_Connect.<br />
4 EDASYM_DISCONNECT The pointer to<br />
EDADRV_Disconnect.<br />
Driver Functions
Array<br />
Index Array Element Value Description<br />
5 EDASYM_END_TRANSACTION The pointer to<br />
EDADRV_EndTransaction.<br />
6 EDASYM_PREPARE_STMT The pointer to<br />
EDADRV_PrepareStmt.<br />
7 EDASYM_DROP_STMT The pointer to EDADRV_DropStmt.<br />
8 EDASYM_EXECUTE_STMT The pointer to EDADRV_Execute.<br />
9 EDASYM_CLOSE_STMT The pointer to EDADRV_Close.<br />
10 EDASYM_FETCH_STMT The pointer to EDADRV_FetchStmt.<br />
11 EDASYM_PERFORM The pointer to EDADRV_Perform.<br />
12 EDASYM_SET_ATTRIBUTE The pointer to<br />
EDADRV_GetEDAAttr.<br />
13 EDASYM_GET_ERRMSG The pointer to<br />
EDADRV_GetErrmsg.<br />
14 EDASYM_CLEANUP The pointer to EDADRV_Cleanup.<br />
15 EDASYM_GET_DBINFO The pointer to<br />
EDADRV_GetDBInfo.<br />
16 EDASYM_FREE_RESULT The pointer to<br />
EDADRV_FreeResult.<br />
17 EDASYM_GETSPECIALINFO The pointer to<br />
EDADRV_GetSpecialInfo.<br />
Driver Functions<br />
EDADRV_LoadSymbols 1-243
Output Variables<br />
The following table describes the output variables.<br />
Return Codes<br />
The following table describes the EDADRV_LoadSymbols return codes.<br />
1-244 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Type Argument Description<br />
int * numsymbols The number of symbols returned.<br />
EDA_T_SYMBOL * symbols The Driver Symbol Array pointer.<br />
EDADRV_LoadSymbols Output Variables<br />
Return<br />
Code Error Description<br />
0 N/A Successful.<br />
101 EDADRV_ERR_MEMORY Internal memory allocation error.<br />
108 EDADRV_CONFIG_NOT_EXIST edaconfig file does not exist.<br />
109 EDADRV_OPEN_CONFIG_ERROR Could not open edaconfig file.<br />
110 EDADRV_DB2INSTANCE_NOT_SET DB2INSTANCE in edaconfig file<br />
not set.<br />
EDADRV_LoadSymbols Return Codes
EDADRV_Perform<br />
Syntax<br />
RETCODE EDADRV_Perform(connhdl,stmt,numrows,result)<br />
Description<br />
The EDADRV_Perform function combines the processing of the<br />
EDADRV_PrepareStmt and the EDADRV_Execute functions, and if the statement is<br />
a query, it also fetches the entire result set as in EDADRV_FetchStmt. See the above<br />
functions for a description of the processing performed by the EDADRV_Perform<br />
function. The driver designer may choose to either Prepare and Execute or Execute<br />
Direct on the external database side.<br />
Input Variables<br />
The following table describes the input variables.<br />
Type Variable Description<br />
EDA_T_CONN_HDL connhdl The connection handle.<br />
EDA_T_STMT stmt The statement content.<br />
EDADRV_Perform Input Variables<br />
Output Variables<br />
The following table describes the output variables.<br />
Type Variable Descripton<br />
int * numrows The number of rows retrieved or affected.<br />
EDA_T_RESULT * result The result string.<br />
EDADRV_Perform Output Parameters<br />
EDADRV_Perform 1-245
Return Codes<br />
The following table describes the EDADRV_Perform return codes.<br />
1-246 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return<br />
Code Error Description<br />
0 N/A Successful.<br />
1 EDADRV_ERR_SYSTEM External system error.<br />
2 EDADRV_SYSERR_OBJ_EXIST Object already exists.<br />
101 EDADRV_ERR_MEMORY Internal memory allocation error.<br />
102 EDADRV_INVALID_CONN_ID Invalid connection handle.<br />
106 EDADRV_TOO_MANY_DATA Too much data fetched.<br />
112 EDADRV_INVALID_DATATYPE Invalid data type<br />
113 EDADRV_TOO_MANY_OUT_PARAM Too many output parameters.<br />
EDADRV_Perform Return Codes
EDADRV_PrepareStmt<br />
Syntax<br />
RETCODE EDADRV_PrepareStmt(connhdl,stmthdl,stmt)<br />
Description<br />
The EDADRV_PrepareStmt function prepares a statement passed to it by EDA. If the<br />
driver already has a statement handle that it can reuse, it may choose to return this<br />
preallocated handle in the stmthdl output variable, otherwise, it allocates a new<br />
statement handle and returns it in stmthdl.<br />
If the statement is a DDL statement (statement type EDASTMT_DDL) or a DML<br />
statement, such as INSERT, UPDATE or DELETE (statement type<br />
EDASTMT_DML), or a SELECT statement (statement type EDASTMT_QUERY),<br />
the statement may contain input parameters. These parameters are designated by<br />
parameter markers (“?”). In this case, EDA supplies as many parameter descriptions<br />
as there are parameter markers.<br />
If the statement is a stored procedure call (statement type<br />
EDASTMT_PROCEDURE), the statement may contain input, output, and<br />
input/output parameters (parameter types of EDAPARAM_IN, EDAPARAM_OUT,<br />
and EDAPARAM_INOUT). In this case, EDA supplies as many parameter descriptions<br />
as there are input and input/output parameters of a stored procedure.<br />
The EDADRV_PrepareStmt function allocates an array of EDA_T_PTYPE structures,<br />
converts EDA data type into the corresponding external database data type, and<br />
associates this array with the statement handle for its later use in<br />
EDADRV_ExecuteStmt.<br />
EDADRV_PrepareStmt 1-247
Input Variables<br />
The following table describes the input variables.<br />
Output Variable<br />
The following table describes the output variable.<br />
Return Codes<br />
The following table describes the EDADRV_PrepareStmt return codes.<br />
1-248 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Type Argument Description<br />
EDA_T_CONN_HDL connhdl The connection handle.<br />
EDA_T_STMT stmt The statement content.<br />
EDADRV_PrepareStmt Input Variables<br />
Type Argument Description<br />
EDA_T_STMT_HDL * stmthdl The statement handle.<br />
EDADRV_PrepartStmt Output Variable<br />
Return<br />
Code Error Description<br />
0 N/A Successful.<br />
1 EDADRV_ERR_SYSTEM External system error.<br />
101 EDADRV_ERR_MEMORY Internal memory allocation error.<br />
102 EDADRV_INVALID_CONN_ID Invalid connection handle.<br />
112 EDADRV_INVALID_DATATYPE Invalid data type<br />
EDADRV_PrepareStmt Return Codes
ENABLEDEC<br />
Syntax<br />
ENABLEDEC [,], [ON ERROR<br />
]<br />
Description<br />
Use the ENABLEDEC command to activate decryption on a file or fields you<br />
specify.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
filename The name of the file on which you want to enable decryption.<br />
field_list A comma-separated list of fields for which you want to enable<br />
decryption. Do not enter spaces between the field names.<br />
ON ERROR statements If you specify ON ERROR statements and an error occurs,<br />
UniData executes the statements following the ON ERROR<br />
clause. Otherwise, UniData executes the next statement.<br />
ENABLEDEC Parameters<br />
ENABLEDEC 1-249
STATUS Codes<br />
ENABLEDEC has the following STATUS codes:<br />
STATUS<br />
Code Description<br />
Example<br />
The following example illustrates enabling decryption on two fields in a file using a<br />
quoted string:<br />
1-250 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
0 No error, operation successful<br />
1 Decryption is already enabled<br />
2 General operation failure, such as an open file error<br />
3 File is not an encrypted file<br />
4 Attempting operation on WHOLERECORD encrypted file<br />
5 Field(s) is not an encrypted file<br />
6 Cannot locate information to disable encryption<br />
7 Field is not a valid field in this file<br />
ENABLEDEC STATUS Codes<br />
ENABLEDEC "CUSTOMER","NAME,PHONE" ON ERROR PRINT "Unable to enable<br />
decryptiON<br />
The next example illustrates enabling decryption on two fields using variables:<br />
CUST="CUSTOMER"<br />
FIELDS="NAME,PHONE"<br />
ENABLEDEC CUST,FIELDS ON ERROR PRINT "Unable to enable decryption"
ENCODE<br />
Syntax<br />
ENCODE(algorithm, action, data, dataLoc, result, resultLoc)<br />
Description<br />
The ENCODE() function performs data encoding on input data. Currently, UniData<br />
supports only Base64 encoding. Base 64 encoding is designed to represent arbitrary<br />
sequences of octets that do not need to be humanly readable. A 65-character subset<br />
of US-ASCII is used, enabling 6-bits to be represented per printable character. The<br />
subset has the important property that it is represented identically in all versions of<br />
ISO646, including US-ASCII, and all characters in the subset are also represented<br />
identically in all versions of EBCDIC. The encoding process represents 24-bit groups<br />
of input bits as output strings of 4 encoded characters. The encoded output stream<br />
must be represented in lines of no more than 76 characters each. All line breaks must<br />
be ignored by the decoding process. All other characters not found in the 65-character<br />
subset should trigger a warning by the decoding process.<br />
The function can perform either encoding or decoding, as specified by action. The<br />
data can either be in the dynamic array, data, or in a file whose name is specified in<br />
data, determined by dataLoc.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
algorithm A string containing the encode method name. UniData currently only<br />
supports the Base64 method.<br />
action 1 - Encode<br />
2 - Decode<br />
data Data or the name of the file containing the data to be encoded or decoded.<br />
ENCODE Parameters<br />
ENCODE 1-251
Parameter Description<br />
dataLoc 1 - Data in a string<br />
2 - Data in a file<br />
The following table describes the status of each return code.<br />
1-252 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
result Encoded or decoded data or the name of the file storing the processed<br />
data.<br />
resultLoc 1 - Result in a string<br />
2 - Result in a file.<br />
ENCODE Parameters (continued)<br />
Return<br />
Code Status<br />
0 Success.<br />
1 Unsupported algorithm.<br />
2 Invalid parameters (invalid data or result location<br />
type, and so forth).<br />
3 The data cannot be read.<br />
4 The data cannot be encoded or decoded.<br />
Return Code Status
ENCRYPT<br />
Syntax<br />
ENCRYPT(algorithm, action, data, dataLoc,key, keyLoc, keyAction, salt, IV, result,<br />
resultLoc)<br />
Description<br />
The ENCRYPT() function performs symmetric encryption operations. You can call<br />
various block and stream symmetric ciphers through this function. The supported<br />
ciphers are listed in <strong>UniBasic</strong> Extensions.<br />
You specify ciphers by algorithm, and they are not case sensitive. You can specify<br />
Base64 encoding and decoding with the action parameter. If you specify encoding,<br />
the encrypted data is Base64 encoded before being entered into result. If you specify<br />
decoding, the data is Base64 decoded before being encrypted. Specify the data and<br />
its location using data and dataLoc, respectively. You can explicitly specify Key, read<br />
it from a file, or, alternatively, derived it on the fly by specifying keyAction, in which<br />
case the key string is used as a pass phrase to derive the actual key. The encrypted or<br />
decrypted data is put into the dynamic array result, or a file, as specified by resultLoc.<br />
Salt is used to provide more security against certain kinds of cryptanalysis attacks,<br />
such as dictionary attacks. If you specify an empty salt, UniData uses an internally<br />
generated salt in deriving the key. UniData ignores Salt when action is set to decrypt.<br />
UniData uses IV (Initialization Vector) to provide additional security to some block<br />
ciphers. It does not need to be secret but should be fresh, meaning different for each<br />
encrypted data. If you supply an existing key, IV is generally needed. However, if the<br />
encryption key is to be derived from a pass phrase, IV can be generated automatically.<br />
Both salt and IV must be provided in hexadecimal format.<br />
ENCRYPT 1-253
Parameters<br />
he following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-254 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
algorithm A string containing the cipher name.<br />
action 1 - Encrypt<br />
2 - Base64 encode after encryption<br />
3 - Decrypt<br />
4 - Base64 decode before encryption<br />
5 - One-line Base64 encoding, which does not place line breaks in the<br />
result.<br />
6 - One-line Base64 decoding, which does not place line breaks in the<br />
result.<br />
data Data or the name of the file containing the data to be processed.<br />
dataLoc 1 - Data in a string<br />
2 - Data in a file<br />
key The actual key (password) or file name containing the key.<br />
keyLoc 1 - Key in data<br />
2 - Key in file<br />
keyAction 1 - Use actual key<br />
2 - Derive key from pass phrase<br />
Salt A string containing the Salt value.<br />
IV A string containing IV.<br />
result The result buffer or the name of the file storing the result.<br />
resultLoc 1 - Result in a string<br />
2 - Result in a file.<br />
ENCRYPT Parameters
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success.<br />
1 Invalid cipher.<br />
2 Invalid parameters (location/action value is<br />
out of range, etc.).<br />
3 The data cannot be read.<br />
4 The key cannot be derived.<br />
5 Base 64 encoding/decoding error.<br />
6 Encryption/decryption error.<br />
ENCRYPT Return Codes<br />
ENCRYPT 1-255
END<br />
Syntax<br />
END<br />
Description<br />
The <strong>UniBasic</strong> END command declares the end of a program or a block of statements.<br />
<strong>UniBasic</strong> does not require you to use END at the end of a program.<br />
Example<br />
In the following example, the END in bold type declares the end of the program<br />
segment. (The first END ELSE ends the THEN clause in the IF/THEN/ELSE<br />
statement.)<br />
A = 0<br />
PRINT "Enter a number: ":<br />
INPUT X<br />
IF X>0 THEN<br />
PRINT "Incrementing."<br />
A += 1<br />
END ELSE<br />
PRINT "Decrementing."<br />
A -= 1<br />
END<br />
PRINT A<br />
1-256 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
ENTER<br />
Syntax<br />
ENTER filename<br />
ENTER @variable<br />
Description<br />
The <strong>UniBasic</strong> ENTER command passes control to the program you specify. It terminates<br />
the program that is passing control and executes the cataloged program. The<br />
ENTER command allows variables to pass through common areas, but all other<br />
variables are reinitialized when the new program begins.<br />
Note: This command does not return control to the original program by default. For<br />
structured programming, use GOSUB and RETURN. This makes the program easier<br />
to read and maintain.<br />
The ENTER command processes faster than the CHAIN command.<br />
Examples<br />
In the following example, the program statement transfers control to cataloged<br />
program CHECK_1:<br />
ENTER CHECK_1<br />
In the next example, the program segment transfers control to cataloged program<br />
CHECK_2:<br />
NO = 2<br />
PROG = "CHECK_":NO<br />
ENTER @PROG<br />
ENTER 1-257
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CALL, CHAIN, COMMON, GOSUB<br />
1-258 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
EQ<br />
Syntax<br />
variable = expr<br />
expr1 EQ expr2<br />
Synonym<br />
=<br />
Description<br />
The <strong>UniBasic</strong> EQ operator serves as an assignment operator and a relational operator.<br />
As an assignment operator, it assigns expr to variable. As a relational operator, it tests<br />
whether expression expr1 is equal to expr2.<br />
expr1 and expr2 can be any valid <strong>UniBasic</strong> expressions, variables, strings, or literals.<br />
Relational operators make the comparisons that direct program flow in conditional<br />
statements like the following:<br />
IF VAR1 = VAR2 THEN GOSUB SUB1<br />
DO UNTIL VAR1 = VAR2<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
variable Specifies the variable to which to assign the contents of expr.<br />
expr Specifies a value, string, expression, or variable the value of which variable<br />
is assigned to.<br />
EQ Parameters<br />
EQ 1-259
Examples<br />
In the following example, the program statement assigns the value of 60 to the<br />
variable PAGELENGTH:<br />
PAGELENGHTH EQ 60<br />
In the next example, the EQ relational operator is used in a conditional test. The<br />
program segment tests whether A equals B. In this case, the message “NOT EQUAL”<br />
prints.<br />
A = 24<br />
B = 23<br />
IF A EQ B THEN<br />
PRINT "EQUAL"<br />
END ELSE<br />
PRINT "NOT EQUAL"<br />
END<br />
Related Command<br />
<strong>UniBasic</strong><br />
EQS<br />
1-260 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
EQS<br />
Syntax<br />
EQS(array1,array2)<br />
Description<br />
The <strong>UniBasic</strong> EQS function compares each value in array1 to its corresponding<br />
value in array2. UniData returns an array with 1 in each position where values are<br />
equal, and 0 in each position for values that are not equal.<br />
Example<br />
In the following example, the program segment compares ARRAY1 to ARRAY 2<br />
and returns ARRAY3. After EQS, ARRAY3 contains 1}1}1}0}0.<br />
ARRAY1 = '11':@VM:'12':@VM:'13':@VM:'20':@VM:'21'<br />
ARRAY2 = '11':@VM:'12':@VM:'13':@VM:'19':@VM:'22'<br />
ARRAY3 = EQS(ARRAY1,ARRAY2)<br />
EQS 1-261
EQU<br />
Syntax<br />
EQU constant1 TO value1 [[,constant2 TO value2]...]<br />
EQU constant1 {LITERALLY | LIT} string2 [[,constant2 {LITERALLY |<br />
LIT} string2]...]<br />
Synonym<br />
EQUATE<br />
Description<br />
The <strong>UniBasic</strong> EQU command replaces a constant with an array, function, number,<br />
string, or variable name when the program is compiled.<br />
The only difference between the statements using TO and those using LITERALLY<br />
is the use of quotation marks. In the TO form, you cannot enclose literals in quotation<br />
marks. In the LITERALLY form, you must enclose literals in quotation marks.<br />
After the execution of an EQUATE statement, you can use the constant symbols and<br />
variables interchangeably at all levels of the program.<br />
EQUATE variables are available from within the <strong>UniBasic</strong> debugger.<br />
The variable literal string limit is 2,048 characters. EQUATE has the same limit.<br />
Tip: EQUATE enables you to use longer, more meaningful names as you write code.<br />
These names are replaced with the actual value when the program is compiled.<br />
EQUATE also lets you equate a control character to a meaningful name. UniData<br />
does not use memory for a constant symbol because the replacement takes place<br />
during compilation.<br />
1-262 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Paramete<br />
r Description<br />
constant Specifies the constant to be replaced with value when the program is<br />
compiled.<br />
value Specifies the value to replace constant with when the program is compiled.<br />
string Specifies a literal string, in quotes, to replace constant with when the program<br />
is compiled.<br />
EQ Parameters<br />
Examples<br />
In the following example, all occurrences of the constant SB are replaced with the<br />
value CHAR(8) (clear screen) during program compilation:<br />
EQUATE SC TO CHAR(8)<br />
In the next example, UniData replaces every occurrence of the constant TITLE with<br />
the string ALGONQUIN:<br />
EQUATE TITLE LITERALLY "ALGONQUIN"<br />
In the next example, UniData replaces every occurrence of the constant TRUE with<br />
the value 1, and every occurrence of the constant FALSE with the value 0:<br />
EQUATE TRUE to 1, FALSE to 0<br />
IF TRUE<br />
PRINT "Income less than target figure."<br />
END<br />
IF FALSE<br />
PRINT "Income equal to or greater than target!"<br />
END<br />
EQU 1-263
In the next example, UniData replaces every occurrence of the constant FULLNAME<br />
with the expression in the EQUATE statement. The program segment prints “Mary<br />
Jones”.<br />
1-264 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
EQUATE FULLNAME LITERALLY "FIRST_NAME:' ':LAST_NAME"<br />
FIRST_NAME = "Mary"<br />
LAST_NAME = "Jones"<br />
PRINT FULLNAME<br />
After the program is compiled, the print statement looks like this:<br />
PRINT FIRST_NAME:' ':LAST_NAME<br />
The following example shows the same program segment using the TO form of the<br />
statement syntax. In this case, the quotation marks around FIRST_NAME:'<br />
':LAST_NAME are removed.<br />
EQUATE FULLNAME TO FIRST_NAME:' ':LAST_NAME<br />
FIRST_NAME = "Mary"<br />
LAST_NAME = "Jones"<br />
PRINT FULLNAME
EREPLACE<br />
Syntax<br />
EREPLACE(expression, substring, replacement [,occurrence [,begin] ] )<br />
Description<br />
The EREPLACE function replaces substring in expression with another substring. If<br />
you do not specify occurrence, each occurrence of substring is replaced.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
expression The expression in which you want to replace substring.<br />
substring The substring you want to replace. If substring is an empty string,<br />
replacement is prefixed to expression. If replacement is an empty string,<br />
all occurrences of substring are removed.<br />
replacement The replacement value for substring.<br />
occurrence Specifies the number of occurrences of substring to replace. To replace all<br />
occurrences, specify occurrence as a number less than 1.<br />
begin Specifies the first occurrence of substring to replace. If you omit begin, or<br />
specify a value less than 1, it defaults to 1.<br />
EREPLACE Parameters<br />
If expression evaluates to the null value, null is returned. If substring, replacement,<br />
occurrence, or begin evaluates to the null value, the EREPLACE function fails and<br />
the program terminates with a run-time error message.<br />
Note: The EREPLACE function behaves like the CHANGE function except when<br />
substring evaluates to an empty string.<br />
EREPLACE 1-265
EXECUTE<br />
Syntax<br />
EXECUTE "str.expr" [[ASYNC | SYNC] ON connection [ON ERROR<br />
statements]] [PASSLIST list.num.expr] [RTNLIST list.num.expr]<br />
[CAPTURING dyn.array.var] [RETURNING dyn.array.var] [PASSCOM]<br />
Synonym<br />
PERFORM<br />
Description<br />
The <strong>UniBasic</strong> EXECUTE command executes an ECL or UniData SQL command<br />
from within a <strong>UniBasic</strong> program.<br />
You can execute multiple commands with a single EXECUTE statement by<br />
separating each command by attribute marks. When the EXECUTE statement<br />
executes, UniData separates each command and executes them in order.<br />
Note: The settings of UDT.OPTIONS affect the way ECL commands execute. For<br />
information about these options, see the UDT.OPTIONS <strong>Commands</strong> <strong>Reference</strong>. For<br />
information about UDT.OPTIONS that could affect that command, see the<br />
appropriate ECL command in the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
Reminder: When you compile EXECUTE and PERFORM in BASICTYPE P, a<br />
different parser is used. The P-type parser scans a file of commands that are defined<br />
in the Spectrum-SMA standards or in the McDonnell Douglas REALITY ® operating<br />
system. If the command is found in this file, it is parsed using the P-type parser. If the<br />
command is not found in the REALITY file, it is parsed as if the program had been<br />
compiled with BASICTYPE U. Because all REALITY commands are uppercase, using<br />
lowercase commands will always result in the use of the standard UniData parser.<br />
If you want to execute a standard UniData, UniQuery, or ECL command from within<br />
a program compiled with BASICTYPE P, use the <strong>UniBasic</strong> command<br />
UDTEXECUTE.<br />
1-266 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
str.expr Specifies a UniData command with appropriate parameters. If<br />
you pass a file name to PERFORM, you must use the actual file<br />
name, not a file variable (which is assigned in the OPEN<br />
statement).<br />
ASYNC | SYNC UniData no longer supports this parameter, but it remains for<br />
syntax compatibility.<br />
ON connection UniData no longer supports this parameter, but it remains for<br />
syntax compatibility.<br />
ON ERROR statements UniData no longer supports this parameter, but it remains for<br />
syntax compatibility.<br />
CAPTURING,<br />
dyn.array.var<br />
RETURNING,<br />
dyn.array.var<br />
The CAPTURING clause stores the output in a dynamic array<br />
instead of on the display terminal. Each line of the text becomes<br />
an attribute in the array. Output sent to the printer is not affected<br />
by this clause.<br />
The order of CAPTURING and RETURNING is<br />
interchangeable.<br />
The RETURNING clause captures error messages resulting<br />
from the command executed with PERFORM. This variable<br />
contains a string of error message numbers separated by spaces.<br />
If the executed command creates a spooler hold file, UniData<br />
also returns the hold file number in the same variable.<br />
EXECUTE Parameters<br />
EXECUTE 1-267
Parameter Description<br />
Reminder: The error message numbers you capture with RETURNING will vary,<br />
depending upon which version of UniData you are running.<br />
The ECL STACKCOMMON Command<br />
The ECL STACKCOMMON command makes use of common areas more flexible,<br />
although it requires additional memory. STACKCOMMON settings have the<br />
following effects:<br />
1-268 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
RTNLIST int.expr The RTNLIST clause must be an integer from 0–9, designating<br />
the select list to return to the calling program. You can use the<br />
resulting list with subsequent READNEXT statements or in the<br />
PASSLIST clause of an EXECUTE statement. If an expression<br />
is not given after RTNLIST, the generated select list replaces the<br />
contents of list 0. If RTNLIST is not specified, no list is returned.<br />
If you use EXECUTE to call a <strong>UniBasic</strong> program, no select list<br />
is returned even though you specify RTNLIST. On the other<br />
hand, PASSLIST is always effective and transfers a select list to<br />
the called program.<br />
PASSLIST int.expr The PASSLIST clause must evaluate to an integer 0, 1 or 2,<br />
designating the select list to be sent to the called program. If you<br />
do not specify int.expr, list 0 is assumed.<br />
The passed list can be the result of previous SELECT or<br />
GETLIST commands, or the result of the RTNLIST clause of a<br />
PERFORM statement.<br />
PASSCOM This parameter is provided for backward compatibility for<br />
releases before 3.1.<br />
EXECUTE Parameters (continued)<br />
If STACKCOMMON is off when one program executes another, the<br />
unnamed common is passed to the executed program and back to the<br />
executing program.<br />
If STACKCOMMON is on when one program executes another program,<br />
the unnamed common is not passed to the program you execute. Instead,<br />
unnamed common is saved, and the unnamed common of the called<br />
program is initialized to 0. When control is passed back to the calling<br />
program, unnamed common is restored to its value before the program call.<br />
Unnamed common is never passed to a phantom program.
Note: STACKCOMMON is always on in BASICTYPEs P and M. STACKCOMMON<br />
is off by default in BASICTYPEs R and U.<br />
Examples<br />
In the following example, the program statement performs the command in cmd3 and<br />
sends output to a dynamic array cpt_var:<br />
PERFORM cmd3 CAPTURING cpt_var<br />
In the next example, the program segment executes a variable containing a UniData<br />
command:<br />
LIST.PER = "LIST PERSONNEL WAGETYPE AGE"<br />
PERFORM LIST.PER<br />
In the next example, the EXECUTE statement creates a record ID list using the<br />
SELECT statement. The select list is then used to read records from the file.<br />
EXECUTE 'SELECT CLIENTS WITH COUNTRY = "Canada"'<br />
EXECUTE "SAVE.LIST 'canadians'"<br />
OPEN 'CLIENTS' TO CLIENT.FILE ELSE ABORT<br />
GETLIST 'canadians' SETTING LIST.CNT<br />
ELSE PRINT CLIENT:" SAVEDLISTS ID ‘canadians’ CANNOT BE<br />
FOUND";STOP<br />
PRINT @(-1)<br />
FOR I = 1 TO 22<br />
READNEXT ID ELSE EXIT<br />
READ REC FROM CLIENT.FILE, ID THEN<br />
PRINT @(5,I):REC:@(20,I):REC<br />
END ELSE<br />
PRINT "CANNOT FIND RECORD":ID<br />
END<br />
NEXT I<br />
CLEARSELECT<br />
END<br />
In the next example, the program segment executes a paragraph from within a<br />
<strong>UniBasic</strong> program using the EXECUTE statement:<br />
PARA = "PA":@AM:"DISPLAY HELLO"<br />
EXECUTE PARA<br />
This paragraph displays the word HELLO on the terminal screen.<br />
EXECUTE 1-269
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
COMMON, EXECUTESQL, MDPERFORM, PCPERFORM, UDTEXECUTE<br />
UniData<br />
STACKCOMMON – For more information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
1-270 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
EXECUTESQL<br />
Syntax<br />
EXECUTESQL str.expr [ASYNC | SYNC] [ON connection [ON ERROR<br />
statements]]<br />
Description<br />
The <strong>UniBasic</strong> EXECUTESQL command executes a UniData SQL statement within<br />
a <strong>UniBasic</strong> program.<br />
If the UniData SQL statement includes a SELECT statement with the intent to<br />
process internal program items, the SELECT statement must contain a TO clause<br />
with a resulting file name. Otherwise, UniData displays the result of the statement. If<br />
you select only the @ID attribute, UniData stores the @IDs in a select list. If the<br />
UniData SQL statement includes a TO clause, the data is stored in the output file and<br />
is then available to the <strong>UniBasic</strong> program via the READNEXTTUPLE statement.<br />
Note: After you execute a SELECT statement and complete processing of the selected<br />
records, you must execute the CLEARSQL command to clear the select list and make<br />
all records in the file available for further processing.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
str.expr Specifies a valid UniData SQL statement for UniData to<br />
execute.<br />
EXECUTESQL Parameters<br />
EXECUTESQL 1-271
Parameter Description<br />
Examples<br />
In the following example, the program segment executes a UniData SQL command:<br />
1-272 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ASYNC | SYNC UniData no longer supports this parameter, but it remains for<br />
syntax compatibility.<br />
ON connection UniData no longer supports this parameter, but it remains for<br />
syntax compatibility.<br />
ON ERROR statements UniData no longer supports this parameter, but it remains for<br />
syntax compatibility.<br />
EXECUTESQL Parameters (continued)<br />
OUT.COMMAND = "SELECT NAME, ADDRESS, CITY"<br />
OUT.COMMAND := " FROM CLIENTS;"<br />
EXECUTESQL OUT.COMMAND<br />
CLEARSELECT<br />
The following output displays on the terminal screen when you execute the preceding<br />
program:<br />
Page 1<br />
Name Address City<br />
------------------------------ ------------------------- ---------<br />
------<br />
Paul Castiglione 45, reu de Rivoli Paris<br />
Fredrick Anderson 854, reu de Rivoli Paris<br />
Beverly Ostrovich 7925 S. Blake St. Sydney<br />
Cal di Grigorio 913 Montreal Ave. Regina<br />
Franklin Sears 213 Midland St. Perth<br />
Gino Lee 483 E. Silverman St. Fonthill<br />
JoAnn Casey 4024 South Ivywood Circle Omaha<br />
...
In the next example, the program segment executes the same UniData SQL command<br />
with a TO clause that stores the UniData SQL output in a file that you can access<br />
using the READNEXTTUPLE statement. (This program uses the CLIENTS file in<br />
the demo database.)<br />
OUT.COMMAND = "SELECT NAME, ADDRESS, CITY, STATE"<br />
OUT.COMMAND := " FROM CLIENTS TO SQL_INPUT;"<br />
EXECUTESQL OUT.COMMAND<br />
DONE = 0<br />
FOR X = 1 TO 5<br />
READNEXTTUPLE CLIENT.INFO FROM "SQL_INPUT" ELSE STOP<br />
CONVERT @AM TO " " IN CLIENT.INFO<br />
PRINT CLIENT.INFO<br />
NEXT X<br />
CLEARSELECT<br />
END<br />
This program produces the following results:<br />
Paul Castiglione 45, reu de Rivoli Paris<br />
Fredrick Anderson 854, reu de Rivoli Paris<br />
Beverly Ostrovich 7925 S. Blake St. Sydney NSW<br />
Cal di Grigorio 913 Montreal Ave. Regina Saskatchewan<br />
Franklin Sears 213 Midland St. Perth<br />
In the next example, the UniData SQL statement selects an @ID only. UniData uses<br />
a select list instead of storing the output. In this case, the UniData SQL command<br />
does not require a TO clause, and the <strong>UniBasic</strong> READNEXT statement processes the<br />
IDs selected.<br />
OPEN 'CLIENTS' TO CLIENT.FILE ELSE PRINT 'Open Error.'<br />
OUT.COMMAND = "SELECT @ID"<br />
OUT.COMMAND := " FROM CLIENTS"<br />
OUT.COMMAND := " WHERE CITY = 'Paris';"<br />
EXECUTESQL OUT.COMMAND<br />
DONE = 0<br />
LOOP<br />
READNEXT @ID ELSE DONE = 1<br />
UNTIL DONE DO<br />
GOSUB PROCESS.RECS<br />
REPEAT<br />
CLEARSELECT<br />
PROCESS.RECS:<br />
*print records for clients in Paris."<br />
READ REC FROM CLIENT.FILE,@ID<br />
THEN PRINT REC<br />
RETURN<br />
END<br />
EXECUTESQL 1-273
The program output is:<br />
1-274 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Paul}Castiglione}Chez Paul}45, reu de<br />
Rivoli}Paris}}75008}France}3342425544|3342664857}Work|Fax<br />
Fredrick}Anderson}Otis Concrete}854, reu de<br />
Rivoli}Paris}}75008}France}3342482815|3342481924}Work|Fax<br />
Antonette}Larnelle}Monde Cable}19, rue Jean<br />
Goujon}Paris}}75008}France}3438291902|3438295512}Work|Fax<br />
Pierre}Edmond}JT Engineering}70, avenue<br />
d'Iena}Paris}}75016}France}3391928392|3391992193}Work|Fax<br />
Pierre}Logni}Wine College}70, avenue<br />
d'Iena}Paris}}75016}France}3393688924|3393688523}Work|Fax<br />
Omar}Saulnier}Maurice Salon}4, avenue<br />
Valencia}Paris}}75016}France}3348756898 |3348589782 }Work|Fax<br />
David}Silvers}Qinton Systems}9, avenue<br />
Valencia}Paris}}75016}France}3441831291|3441830107}Work|Fax<br />
Fernando}Ducrot}Monde Cable}19, rue Jean<br />
Goujon}Paris}}75008}France}3344587968|3344668871}Work|Fax<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
EXECUTE, READNEXT, READNEXTTUPLE<br />
UniData SQL<br />
For more information about UniData SQL commands, see the UniData SQL<br />
<strong>Commands</strong> <strong>Reference</strong>.
EXIT<br />
Syntax<br />
EXIT<br />
Description<br />
The <strong>UniBasic</strong> EXIT command terminates a FOR/NEXT or LOOP/REPEAT<br />
structure and transfers control to the following statement. As with the CONTINUE<br />
statement, EXIT forms well structured programs.<br />
Tip: Use EXIT in structured programs instead of GOTO. This makes the code easier<br />
to read and maintain.<br />
Example<br />
In the following example, the program segment exits the FOR/NEXT loop when I is<br />
greater than 8:<br />
FOR I = 1 TO 10<br />
IF I > 8 THEN EXIT<br />
PRINT "I = ":I<br />
NEXT I<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CONTINUE, FOR/NEXT, LOOP/REPEAT<br />
EXIT 1-275
EXP<br />
Syntax<br />
EXP(expr)<br />
Description<br />
The <strong>UniBasic</strong> EXP function raises e to the power of expr. e is approximately<br />
2.71828. expr must be numeric. The function e x is its own derivative. If y = e x , then<br />
x is the natural logarithm of y.<br />
If exp is too large or too small, a warning message is printed and 0 is returned. If exp<br />
is an empty string, the empty string is returned.<br />
Example<br />
In the following example, the program statement raises e to the power of 2, and<br />
assigns this value, 7.3891, to the variable ETOX:<br />
ETOX = EXP(2)<br />
Related Command<br />
<strong>UniBasic</strong><br />
LN<br />
1-276 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
EXTRACT<br />
Syntax<br />
EXTRACT(dyn.array.expr, attrib.expr,[val.expr [,subval.expr]])<br />
dyn.array.expr <br />
Description<br />
The <strong>UniBasic</strong> EXTRACT function retrieves data from an attribute, value, or<br />
subvalue in a dynamic array. The dynamic array itself remains unchanged. You can<br />
use either of the preceding syntax forms.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dyn.array.expr Specifies a dynamic array from which to retrieve the data.<br />
attrib.expr Specifies an attribute of the dynamic array from which to retrieve the<br />
data. If the value of attrib.expr is less than 1, UniData uses 1.<br />
val.expr Specifies a value of attrib.expr from which to extract the data. If the<br />
values of val.expr and subval.expr are 0, or if they do not appear in the<br />
EXTRACT function, UniData retrieves an attribute.<br />
subval.expr Specifies a subvalue of the value specified by val.expr in the attribute<br />
specified by attrib.expr, from which to retrieve data.<br />
If the values of val.expr and subval.expr are 0, UniData retrieves an<br />
attribute. If the value of subval.expr is 0, or if it does not appear in the<br />
EXTRACT function, UniData retrieves a value.<br />
EXTRACT Parameters<br />
EXTRACT 1-277
Examples<br />
The following program segment is taken from the sample program in Appendix A,<br />
“Sample Program,” in Developing <strong>UniBasic</strong> Applications. The variable ENTRY is<br />
used to extract the user-requested values from the ORDERS record.<br />
1-278 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
DISPLAY_DATA:<br />
* Display the current information in the desired record. This is<br />
* determined by the number the user entered (ORDER_NUMBER).<br />
...<br />
NUM_ENTRIES = DCOUNT(ORDER.REC,@VM)<br />
FOR ENTRY = 1 TO NUM_ENTRIES<br />
PRODUCT_NUMBER = ORDER.REC<br />
COLOR = ORDER.REC<br />
QUANTITY = ORDER.REC<br />
PRICE = OCONV(ORDER.REC,"MD2$,")<br />
In the following example, the program segment assigns the string Joan to the variable<br />
MID. Joan is the second attribute in the dynamic array ARR. The value and subvalue<br />
expressions are 0, resulting in the extraction of an attribute.<br />
ARR = "#543":@AM:"Joan":@AM:"D’Arc"<br />
MID = EXTRACT(ARR,2,0,0)<br />
In the next example, the program segment assigns the string Dagny, the second value<br />
of the third attribute, to the variable MID:<br />
ARRAY = "#143":@AM:"Gustav":@AM:"Mahler":@VM:"Dagny":@VM:"Jens"<br />
MID = EXTRACT(ARRAY,3,2)<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DEL, INSERT, REMOVE, REPLACE, SUBSTRINGS
FIELD<br />
Syntax<br />
FIELD(string.expr,delim.expr,field.expr [,rep.expr])<br />
Description<br />
The <strong>UniBasic</strong> FIELD function treats a string as an array, with fields delimited by any<br />
specified ASCII character (for example, spaces, commas, or periods), and returns a<br />
substring or group of substrings. FIELD supports multibyte languages.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
string.expr Specifies the string expression to search.<br />
delim.expr Specifies the field delimiter.<br />
field.expr Specifies the field at which to begin the search.<br />
,rep.expr Specifies the number of fields to return. If you do not specify rep.expr, or it<br />
is less than 1, UniData returns a default of 1 substring.<br />
FIELD Parameters<br />
Examples<br />
In the following example, the program segment assigns the third value (“Guy”) in the<br />
array ARR to the array NARRAY:<br />
ARR = "#999":@VM:"Charlemagne":@VM:"Guy":@VM:"Pierre"<br />
NARRAY = FIELD(ARR,@VM,2,1)<br />
FIELD 1-247
In the next example, the program segment assigns the two fields following the third<br />
occurrence of the delimiter “,” in the variable ARR to NARRAY. UniData stores the<br />
value 5,8 in NARRAY.<br />
ARR = "10,10,5,8,7,12,15,8"<br />
NARRAY = FIELD(ARR,",",3,2)<br />
In the next example, the program segment assigns the second group of characters in<br />
a string delimited by spaces in the variable NAME to LNAME. UniData stores the<br />
value Smith in LNAME.<br />
NAME = "Harry Smith"<br />
LNAME = FIELD(NAME," ",2)<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
COL1, COL2, INDEX<br />
1-248 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
FIELDSTORE<br />
Syntax<br />
FIELDSTORE(str.expr,delimiter,b.pos,option,new.expr)<br />
Description<br />
The <strong>UniBasic</strong> FIELDSTORE function inserts an expression and an appropriate<br />
delimiter into a string.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
str.expr Specifies the target string.<br />
delimiter Specifies the character that delimits fields in str.expr.<br />
b.pos Specifies the occurrence of the delimiter at which to insert.<br />
If the number of delimiters is less than b.pos, UniData inserts the appropriate<br />
number of spaces and delimiters.<br />
option Specifies whether FIELDSTORE will insert before, insert after, or replace<br />
the field at b.pos. Refer to the following FIELDSTORE Options table for<br />
further details.<br />
new.expr Specifies the expression (with its associated delimiter) to insert before or<br />
after the specified delimiter.<br />
FIELDSTORE Parameters<br />
FIELDSTORE 1-249
Options<br />
The value of option determines the operation to be executed. The following table<br />
describes these options and their results.<br />
Value Description<br />
Examples<br />
In the following example, the program segment inserts AR in the string ASTATES.<br />
After execution, ASTATES contains the string “AL:AK:AR:AZ”.<br />
1-250 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
If option > 0 UniData replaces the number of substrings specified in option.<br />
If option = 0 UniData inserts new.expr at the position indicated by b.pos.<br />
If option < 0 UniData deletes the number of substrings specified in option, and inserts<br />
new.expr at the location indicated by b.pos.<br />
FIELDSTORE Options<br />
ASTATES = 'AL:AK:AZ'<br />
ASTATES = FIELDSTORE(ASTATES,':',3,0,'AR')<br />
The following program segment compiles and runs only when null value handling is<br />
on. The program segment inserts AR, and then inserts the null value into ASTATES.<br />
It calls the externally cataloged subroutine PRINT.SETUP to convert the null value<br />
to a printing character, and then prints the converted ASTATES. (PRINT.SETUP is<br />
shown under CHANGE.)<br />
PRT.STR = ''<br />
ASTATES = 'AL:AK:AZ'<br />
ASTATES = FIELDSTORE(ASTATES,':',3,0,'AR')<br />
PRINT "ASTATES = ":ASTATES<br />
ASTATES = FIELDSTORE(ASTATES,':',3,0,@NULL)<br />
STR = ASTATES<br />
CALL PRINT.SETUP(STR,PRT.STR)<br />
PRINT "ASTATES = ":PRT.STR<br />
This program prints the following:<br />
ASTATES = AL:AK:AR:AZ<br />
ASTATES = AL:AK:@NULL:AR:AZ
In the next example, the program segment specifies that processing begins at the fifth<br />
value (ugly), that this value is deleted (the -1 option), and that the new.expr<br />
(orange,black) is to be inserted in the same position. After processing, COLORS<br />
contains the string “yellow,blue,red,green,orange, black,white”.<br />
COLORS = 'yellow,blue,red,green,ugly,white'<br />
COLORS = FIELDSTORE(COLORS,',',5,-1,'orange,black')<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
INS, INSERT<br />
FIELDSTORE 1-251
FILEINFO<br />
Syntax<br />
FILEINFO(file.var, code)<br />
Description<br />
The FILEINFO function returns information about the configuration of a file.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Paramete<br />
r Description<br />
1-252 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
file.var Specifies the file to be analyzed.<br />
file.var is the file variable previously used in an OPEN or OPENSEQ<br />
statement.<br />
code Specifies the type of information to return.<br />
FILEINFO Parameters
FILEINFO Codes<br />
code indicates the information requested. The following table describes the codes and<br />
the return values of the function.<br />
Code<br />
Information<br />
Requested File Type Return Value<br />
0 File open status ALL 1= Open<br />
0= Not open<br />
2 Full path name of file ALL Pathname of file<br />
3 File type HASHED<br />
DYNAMIC<br />
DIRECTORY<br />
SEQUENTIAL<br />
NFA<br />
OS<br />
EDA<br />
4 Hashing file type HASH & DYN<br />
(KEYONLY)<br />
HASH & DYN<br />
(KEYDATA)<br />
OTHERS<br />
5 Modulo of file HASH<br />
DIRECTORY<br />
DYNAMIC<br />
OTHERS<br />
6 Minimum modulo of<br />
file<br />
7 Group size of file HASH & DYN<br />
OTHERS<br />
8 Block size of file HASH & DYN<br />
OTHERS<br />
FILEINFO Codes<br />
2<br />
3<br />
4<br />
5<br />
7<br />
8<br />
13<br />
Hash type (0 or 1)<br />
Hash type (32 or 33)<br />
Modulo<br />
0<br />
Current modulo<br />
Not applicable<br />
DYNAMIC Minimum modulo<br />
(Block size/1024)-1<br />
Not applicable<br />
Block size<br />
Not applicable<br />
FILEINFO 1-253
Code<br />
9 Merge factor<br />
percentage<br />
10 Split factor<br />
percentage<br />
11 Current load<br />
percentage<br />
13 Does file contain<br />
alternate key indexes?<br />
1-254 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Information<br />
Requested File Type Return Value<br />
14 Next line number to<br />
read or write<br />
DYNAMIC<br />
OTHERS<br />
DYNAMIC<br />
OTHERS<br />
DYNAMIC<br />
OTHERS<br />
HASH & DYN<br />
OTHERS<br />
SEQUENTIAL<br />
OTHERS<br />
17 Filename HASH & DIR<br />
& DYNAMIC<br />
OTHERS<br />
18 Block size of file HASH & DIR<br />
& DYNAMIC<br />
OTHERS<br />
Merge factor<br />
Not applicable<br />
Split factor<br />
Not applicable<br />
Percent result of the<br />
formula:<br />
(keyspace(grp)<br />
*100)/blksize<br />
Not applicable<br />
1= yes; 2 = no<br />
Not applicable<br />
Next line number<br />
Not applicable<br />
VOC entry name<br />
Not applicable<br />
Block size<br />
Not applicable<br />
19 Access permissions ALL Permissions the person<br />
running the program has<br />
expressed as total UNIX<br />
values<br />
(r=4,w=2,x=1, so rw= 6)<br />
20 Index to which the<br />
last SETINDEX<br />
statement was applied<br />
ALL VOC entry name<br />
FILEINFO Codes (continued)
Code<br />
21 Index record read by<br />
last browsing<br />
statement, such as<br />
READFWD and<br />
READBCK.<br />
22 File type: recoverable<br />
or nonrecoverable<br />
24 Type of Replication<br />
file<br />
ALL Key value<br />
ALL 1 – Recoverable<br />
0 – Nonrecoverable<br />
ALL 0 – File is not a replication<br />
object<br />
1 – File is a publishing<br />
object<br />
2 – File is a subscribing<br />
object<br />
27 Is the file encrypted? ALL 0 – File is not encrypted<br />
1 – File is encrypted<br />
28 Type of file<br />
encryption<br />
Information<br />
Requested File Type Return Value<br />
ALL Returns a dynamic array<br />
containing the following<br />
information:<br />
? For a file encrypted with<br />
the WHOLERECORD<br />
option:<br />
-1@SM@SM<br />
? For a file encrypted at<br />
the field level:<br />
@SM@SM@<br />
SM<br />
? Returns an empty string<br />
if the file is not<br />
encrypted.<br />
FILEINFO Codes (continued)<br />
FILEINFO 1-255
FILELOCK<br />
Syntax<br />
FILELOCK [file.var] [ON ERROR statements] LOCKED statements<br />
Description<br />
The <strong>UniBasic</strong> FILELOCK command locks the dictionary or data portion of a file<br />
against access by READL, READU, READVU, MATREADL, MATREADU,<br />
MATWRITEU, WRITEU, and WRITEVU statements. Other file input/output<br />
commands ignore FILELOCK.<br />
Reminder: <strong>UniBasic</strong> locks are advisory only. For more information, see Developing<br />
<strong>UniBasic</strong> Applications.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-256 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
file.var Specifies the file to lock.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal error occurs.<br />
A default file is one for which no file variable is assigned in the<br />
OPEN statement.<br />
ON ERROR statements Specifies statements to perform if the FILELOCK statement<br />
fails with a fatal error condition because the file is not open.<br />
If you do not specify the ON ERROR clause, the program<br />
terminates abnormally.<br />
LOCKED statements Specifies statements to execute if the file is already locked.<br />
FILELOCK Parameters
STATUS Function Return Values<br />
After you execute of the FILELOCK command, the <strong>UniBasic</strong> STATUS function<br />
returns 0 if the file was locked successfully. If the file was already locked, and if the<br />
LOCKED clause was included in the FILELOCK statement, STATUS returns the<br />
user number of the process that locked the file.<br />
Example<br />
In the following example, the FILELOCK statement locks the file STAT, preventing<br />
lock-checking commands from accessing this file:<br />
FILELOCK STAT LOCKED STOP<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
FILEUNLOCK, RECORDLOCKED, RELEASE<br />
FILELOCK 1-257
FILEUNLOCK<br />
Syntax<br />
FILEUNLOCK [file.var] [ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> FILEUNLOCK command unlocks a file previously locked with a<br />
FILELOCK command.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Example<br />
In the following example, the FILEUNLOCK statement unlocks the file referred to<br />
by the file variable INVENTORY.FILE:<br />
FILEUNLOCK INVENTORY.FILE<br />
1-258 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
file.var Specifies the file to unlock.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal error occurs.<br />
A default file is one for which no file variable is assigned in the<br />
OPEN statement.<br />
ON ERROR statements Specifies statements to perform if the FILEUNLOCK statement<br />
fails with a fatal error condition because the file is not open.<br />
If you do not specify the ON ERROR clause, the program<br />
terminates.<br />
FILEUNLOCK Parameters
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
FILELOCK, RECORDLOCKED, RELEASE<br />
FILEUNLOCK 1-259
FIND<br />
Syntax<br />
FIND expr IN dyn.array[,occur] SETTING f [,v[,s]] {THEN statements | ELSE<br />
statements}<br />
Description<br />
The <strong>UniBasic</strong> FIND command determines the position of the given expression in a<br />
dynamic array. FIND returns the attribute, value, and subvalue position of the found<br />
string. The expression must match the entire array element to make a match.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-260 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
expr Specifies the expression to find. expr must be either a numeric value or a<br />
string value.<br />
dyn.array Specifies the dynamic array in which to find expr.<br />
,occur Specifies the occurrence of expr to find. The default is 1 (the first<br />
occurrence).<br />
FIND Parameters
Parameter Description<br />
f,v,s Specifies variables in which to place the position of expr:<br />
f – Attribute<br />
v – Value<br />
s – Subvalue<br />
If the attribute found has neither multivalues nor subvalues, then v and s, if<br />
specified, are set to 0. If only multivalues are present, s is set to 0. If only<br />
subvalues exist, v is also set to 0.<br />
THEN<br />
statements<br />
ELSE<br />
statements<br />
For more information about writing THEN...ELSE parameters, see Developing<br />
<strong>UniBasic</strong> Applications. The <strong>UniBasic</strong> FIND and LOCATE commands are compared<br />
in this manual.<br />
Examples<br />
Specifies statements to execute if the expr is found in the array. END is<br />
required when statements extend over more than one line. Either a THEN<br />
statement or an ELSE statement is required.<br />
Specifies statements to execute if the expr is not found in the array. END is<br />
required when statements are multiline. Either a THEN statement or an<br />
ELSE statement is required.<br />
FIND Parameters (continued)<br />
In the following example, the program segment searches for an occurrence of 31 in<br />
the string DA. This results in F=3, V=1, and S=0 because 31 is found in the third<br />
attribute as the first multivalue, and this attribute has no subvalues.<br />
001: DA = 1:@AM:2:@AM:31:@VM:32:@VM:41:@VM:41:@VM:42:@VM:43<br />
002: FIND 31 IN DA SETTING F,V,S THEN<br />
003: PRINT "F=":F:" V=":V:" S=":S<br />
004: END ELSE<br />
005: PRINT "NOT FOUND"<br />
006: END<br />
In the next example, the program segment searches for the second occurrence of 41<br />
in the string DA. This results in F=3, V=4, and S=0 because the second occurrence<br />
of 41 is found in the third attribute as the fourth multivalue, and this attribute has no<br />
subvalues.<br />
DA = 1:@AM:2:@AM:31:@VM:32:@VM:41:@VM:41:@VM:42:@VM:43<br />
FIND 41 IN DA,2 SETTING F,V,S ELSE PRINT "NOT FOUND"<br />
FIND 1-261
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
[], FINDSTR, LOCATE<br />
1-262 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
FINDSTR<br />
Syntax<br />
FINDSTR substr IN dyn.array[,occur] SETTING f[,v[,s]] {THEN statements |<br />
ELSE statements}<br />
Description<br />
The <strong>UniBasic</strong> FINDSTR command determines the position of a given substring in a<br />
dynamic array. FINDSTR supports multibyte languages.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
substr Specifies the substring to find. substr must be either a numeric value or a<br />
string value.<br />
dyn.array Specifies the dynamic array in which to find substr.<br />
,occur Specifies which occurrence of substr you want to find in the array. The<br />
default for occur is 1 (the first occurrence).<br />
FINDSTR Parameters<br />
FINDSTR 1-263
Parameter Description<br />
Examples<br />
In the following example, the program segment searches for 3 in the string DA. This<br />
results in F=3, V=1, and S=0 because 3 is found in the third attribute as the first multivalue,<br />
and this attribute has no subvalues.<br />
1-264 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
f,v,s Specifies variables in which to place the position of substr:<br />
f – Attribute<br />
v – Value<br />
s – Subvalue<br />
If the attribute found has neither multivalues nor subvalues, then v and s,<br />
if specified, are set to 0. If only multivalues are present, s is set to 0. If only<br />
subvalues exist, v is also set to 0.<br />
THEN<br />
statements<br />
ELSE<br />
statements<br />
DA = 1:@AM:2:@AM:31:@VM:32:@VM:41:@VM:41:@VM:42:@VM:43<br />
FINDSTR 3 IN DA SETTING F,V,S ELSE PRINT "NOT FOUND"<br />
In the next example, the program segment searches for the second occurrence of 4 in<br />
the string DA. This results in F=3, V=4, and S=0 because the second occurrence of 4<br />
is found in the third attribute as the 4 multivalue, and this attribute has no subvalues.<br />
DA = 1:@AM:2:@AM:31:@VM:32:@VM:41:@VM:41:@VM:42:@VM:43<br />
FINDSTR 4 IN DA,2 SETTING F,V,S ELSE PRINT "NOT FOUND"<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
FIND, LOCATE<br />
Specifies statements to execute if the substr is found in the array. Either a<br />
THEN statement or an ELSE statement is required.<br />
Specifies statements to execute if the substr is not found in the array. Either<br />
a THEN statement or an ELSE statement is required.<br />
FINDSTR Parameters (continued)
FLUSH<br />
Syntax<br />
FLUSH<br />
The FLUSH command flushes output to the terminal when UDT.OPTIONS<br />
46 is on.<br />
Note: For more information about UDT.OPTIONS 46, see the UDT.OPTIONS<br />
<strong>Commands</strong> <strong>Reference</strong>.<br />
FLUSH 1-265
FMT<br />
Syntax<br />
FMT(expr, "len [f.char] {L | R | T | C} [n] [$] [,] [Z] [mask]")<br />
FMT(expr, "{L | R | T | C} # len [f.char] [n] [$] [,] [Z] [mask]")<br />
expr "[L | R | T | C] # len [f.char] [n] [$] [,] [Z] [mask]"<br />
FMT(expr, pattern.var)<br />
Description<br />
The <strong>UniBasic</strong> FMT function formats data in expr for display purposes. FMT can<br />
format a dynamic array that contains multivalues. The statement can be no longer<br />
than 2,046 characters.<br />
In the first form of the syntax, L, R, C, or T and len are required.<br />
The second form is the same as the first form with the elements in a different order.<br />
The third form does not include the keyword FMT, but the elements are in the same<br />
order as in the second form.<br />
In the fourth form, you provide the pattern format in a variable, pattern.var.<br />
Note: The FMT function can produce different results based on the BASICTYPE<br />
setting. The parameter descriptions that follow represent BASICTYPE U.<br />
1-266 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
len Specifies the total number of single-byte characters to appear in the output<br />
string.<br />
f.char Specifies a single-byte fill character to be used if the formatted string is not<br />
long enough to fill len; the default is a space. Cannot be a multibyte character.<br />
Prefix a numeric f.char with \ to indicate it is the fill character.<br />
L Specifies left-justification in a string of len spaces. If the text is longer than<br />
len, the text is broken in len intervals. Has no effect in multibyte languages.<br />
R Specifies right-justification in a string of len spaces. Has no effect in<br />
multibyte languages.<br />
C Specifies centered text in the column of width len. Has no effect in multibyte<br />
languages.<br />
T Specifies text justification. If data must be broken to fit in a column, it is<br />
justified on a word basis (from space to space). Has no effect in multibyte<br />
languages.<br />
n Specifies the maximum number of decimal places allowed, rounding as<br />
necessary. If n = 0, the number is rounded to an integer.<br />
$ Prints a dollar sign before the formatted string. Valid for numeric data only.<br />
, Prints numbers with commas separating each level of thousands. Valid for<br />
numeric data only.<br />
Z Specifies the suppression of leading zeros.<br />
mask Specifies a pattern mask composed of numbers and other characters.<br />
Numeric data is placed sequentially in the mask before justification.<br />
FMT Parameters<br />
FMT 1-267
STATUS Function Return Values<br />
After you execute FMT, the STATUS function returns one of the values described in<br />
the following table.<br />
Value Description<br />
0 Successful completion.<br />
Examples<br />
In the following example, the program segment prints the variable SS.NUM as a<br />
formatted string using a pattern mask. The result printed is a string with 11 characters,<br />
left-justified:“543-70-4128”.<br />
1-268 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
1 String expression is invalid or exceeds the allowable string size.<br />
2 Conversion code is invalid.<br />
STATUS Function Return Values<br />
SS.NUM=543704128<br />
PRINT FMT(SS.NUM,"11L###-##-####")<br />
In the next example, the program segment prints the variable NUM as a 12-character,<br />
right-justified number with two decimal places, preceded by a dollar sign and<br />
composed with commas. The segment prints the value “$16,526.00”.<br />
NUM = 16526<br />
PRINT FMT(NUM, "12R2$,")<br />
In the next example, the program segment formats the string OUT.STRING with 0 as<br />
the fill character, right-justified, and in a column of four spaces. The segment prints<br />
0044.<br />
OUT.STRING = 44<br />
OUT.STRING = FMT(OUT.STRING,"4\0R")<br />
PRINT OUT.STRING<br />
In the next example, the program statement saves the variable STR as a rightjustified,<br />
eight column string:<br />
STR = STR "R#8"
In the next example, the program segment uses a variable to specify the pattern<br />
format. UniData formats STR according to the variable PATTERN:<br />
PATTERN = "12R2$,"<br />
STR = STR PATTERN<br />
FMT 1-269
FOOTING<br />
Syntax<br />
FOOTING [ON num.expr] str.expr ['option']...<br />
Description<br />
The <strong>UniBasic</strong> FOOTING command causes the specified string to print or display at<br />
the bottom of each page of a report. You can specify a footer of any length. The ECL<br />
LIMIT command has no effect on this command.<br />
Note: Turn on UDT.OPTION 64 to force the footing to appear on the last page or<br />
screen. With this option turned off, the footing does not appear on the last page or<br />
screen. For more information about UDT.OPTION 64, see the UDT.OPTIONS<br />
<strong>Commands</strong> <strong>Reference</strong>.<br />
The PRINTER command directs the output of a FOOTING command not sent to a<br />
print file as follows:<br />
1-270 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
PRINTER OFF causes a report, together with its footings, to appear on the<br />
user’s terminal screen.<br />
PRINTER ON causes all subsequent footings, headings, and PRINT output<br />
to be sent to the destination specified by the current SETPTR setting.
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
ON num.expr Specifies a print file to which you want to send the footing: 0–254.<br />
str.expr Specifies the string to display at the bottom of each page.<br />
option... option must be enclosed in single quotation marks. You can place<br />
option(s) anywhere in the footing expression. option can be any of the<br />
following:<br />
ASCII code – Passes to the printer or file code controlling paging<br />
characteristics.<br />
P or S – Prints current page number.<br />
N – Suppresses the pagination prompt after each page.<br />
L – Advances one line. Used for multiline footings.<br />
D – Prints date in MM-DD-YY format.<br />
T – Prints time/date in MM-DD-YY HH:MM:SS format.<br />
C – Centers the footing text.<br />
G – Forces the line to fill the width of the page.<br />
FOOTING Parameters<br />
Examples<br />
In the following example, the program statement produces a footing using a character<br />
string:<br />
FOOTING "Copyright 1999, Genius, Inc."<br />
In the next example, the program statement prints Page and the current page number.<br />
It advances one line and then prints Paul’s Produce. Notice the two single quotation<br />
marks in the middle of the strings. They are necessary to print a single apostrophe in<br />
the footer. The ON 2 clause sends the footing to print file 2.<br />
FOOTING ON 2 "Page 'PL'Paul''s Produce"<br />
FOOTING 1-271
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
GETPTR, HEADING, PRINTER<br />
UniData<br />
SETPTR – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
1-272 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
FORMLIST<br />
Syntax<br />
FORMLIST dynamic.array.var [TO list.num.expr]<br />
Description<br />
The <strong>UniBasic</strong> FORMLIST command creates an active select list from a dynamic<br />
array. FORMLIST uses the attribute marks in dynamic.array.var to create a select list<br />
that you can use with READNEXT statements or other list processing commands<br />
such as external LIST statements.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dynamic.array.var Specifies a dynamic array from which to create a select list.<br />
TO list.num.expr Specifies which list, 0 through 9, you want the list sent to. 0 is<br />
the default list.<br />
FORMLIST Parameters<br />
Examples<br />
In the following example, the program segment creates a select list and then uses that<br />
list to print four records in the CLIENTS file:<br />
ARRAY.LIST = 9999:@AM:10034:@AM:9980:@AM:10015<br />
FORMLIST ARRAY.LIST TO 0<br />
PRINT "PROCESSING THE FOLLOWING ITEMS:"<br />
PERFORM "LIST CLIENTS NAME COMPANY"<br />
END<br />
FORMLIST 1-273
This program segment produces the following results:<br />
1-274 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
LIST CLIENTS NAME COMPANY 17:33:03 Apr 27 1999 1<br />
CLIENTS... Name.......................... Company<br />
Name..................<br />
9999 Paul Castiglione Chez Paul<br />
10034 Fredrick Anderson Otis Concrete<br />
9980 Beverly Ostrovich Riley Architects<br />
10015 Cal di Grigorio Regina Flooring<br />
4 records listed<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DELETELIST, READLIST, SELECT, SELECTINDEX, SELECTINFO,<br />
WRITELIST<br />
UniQuery<br />
DELETE.LIST, GET.LIST, SELECT, SSELECT, SAVE.LIST – For information, see<br />
the UniQuery <strong>Commands</strong> <strong>Reference</strong>.<br />
UniData SQL<br />
SELECT – For information, see the UniData SQL <strong>Commands</strong> <strong>Reference</strong>.
FOR/NEXT<br />
Syntax<br />
FOR var = val1 TO val2 [STEP val3]<br />
statements]<br />
[UNTIL | WHILE expr]<br />
statements<br />
NEXT [var]<br />
Description<br />
The <strong>UniBasic</strong> FOR/NEXT command executes statements repeatedly while incrementing<br />
a variable over a range until it reaches the end of the range, or until the<br />
condition in the WHILE or UNTIL clause is achieved. You can nest FOR/NEXT<br />
constructions. Each FOR statement must end with a NEXT statement.<br />
FOR/NEXT should be constructed so termination occurs based on the WHILE or<br />
UNTIL condition. Use the CONTINUE statement to transfer control to the next<br />
iteration of the command.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
var Specifies the variable to increment.<br />
val1 Specifies the beginning of the range for incrementing var.<br />
val2 Specifies the end of the range for incrementing var.<br />
STEP val3 Specifies the change to use in incrementing var. The increment can be<br />
negative or positive, making the variable decrease or increase.<br />
FOR/NEXT Parameters<br />
FOR/NEXT 1-275
Parameter Description<br />
Examples<br />
The following program segment is taken from the sample program in Appendix A,<br />
“Sample Program,” in Developing <strong>UniBasic</strong> Applications. This segment prints multivalues<br />
from the ORDERS file when a client has ordered multiple items.<br />
1-276 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
statements Specifies the statements to carry out for each loop.<br />
UNTIL |<br />
WHILE expr<br />
statements<br />
Specifies a condition, expr, to test after each loop. If the UNTIL keyword<br />
is used, the loop continues until expr is true. If the WHILE keyword is<br />
used, the loop continues until expr is not true. In either case, when the loop<br />
stops, the statements are executed before the program continues.<br />
NEXT var The NEXT statement defines the end of the block of statements to be<br />
repeated. The optional var is the same variable as in the beginning of the<br />
FOR/NEXT statement.<br />
FOR/NEXT Parameters (continued)<br />
DISPLAY_DATA:<br />
* Display the current information in the desired record. This is<br />
* determined by the number the user entered (ORDER_NUMBER).<br />
.<br />
.<br />
. FOR ENTRY = 1 TO NUM_ENTRIES<br />
PRODUCT_NUMBER = ORDER.REC<br />
COLOR = ORDER.REC<br />
QUANTITY = ORDER.REC<br />
PRICE = OCONV(ORDER.REC,"MD2$,")<br />
IF PRODUCT_LINE = '' THEN<br />
PRODUCT_LINE = PRODUCT_NUMBER "R#10"<br />
COLOR_LINE = COLOR "R#10"<br />
QUANTITY_LINE = QUANTITY "R#10"<br />
PRICE_LINE = PRICE "R#10"<br />
END ELSE<br />
PRODUCT_LINE := " ":PRODUCT_NUMBER "R#10"<br />
COLOR_LINE := " ":COLOR "R#10"<br />
QUANTITY_LINE := " ":QUANTITY "R#10"<br />
PRICE_LINE := " ":PRICE "R#10"<br />
END<br />
NEXT ENTRY
In the following example, the program segment prints the string 10,8,6,4,2,. The loop<br />
terminates before printing 0 because the FOR/NEXT statement specifies that when<br />
the variable I falls below 1, the loop terminates.<br />
FOR I = 10 TO 1 STEP -2<br />
PRINT I:",":<br />
NEXT I<br />
In the next example, the optional WHILE expression clause creates a secondary<br />
condition for the termination of the FOR/NEXT structure. While a normal<br />
FOR/NEXT loop repeats the contained statements 10 times, the WHILE clause<br />
results in this example stopping after only three repetitions. This occurs because the<br />
value read from the DATA statement by the INPUT command exceeds the value of I<br />
on the third iteration. The WHILE clause with the same statements results in the loop<br />
terminating after one iteration. After the iteration, I is less than K, satisfying the<br />
condition and causing the loop to stop.<br />
K=50<br />
DATA 3,4,2,51,8,10,15,3,2,8<br />
FOR I = 1 TO 10 WHILE I < K<br />
INPUT K<br />
PRINT I,K<br />
NEXT I<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CASE, LOOP/REPEAT<br />
FOR/NEXT 1-277
FUNCTION<br />
Syntax<br />
FUNCTION function.name [([MAT] arg.1[, [MAT] arg.2]...)]<br />
RETURN var<br />
Description<br />
The <strong>UniBasic</strong> FUNCTION command begins the definition of a user-written<br />
function. The FUNCTION command must be the first noncomment line in the file,<br />
which must be cataloged locally or globally.<br />
The cataloged file name must be included in the DEFFUN statement in the calling<br />
program.<br />
The calling program must specify the same number and type of arguments in the<br />
calling statement as are included in the FUNCTION statement.<br />
Note: UniData triggers are <strong>UniBasic</strong> subroutines or functions that are called when<br />
a user attempts to update or delete a record. For more information about coding a<br />
<strong>UniBasic</strong> function that is called by a trigger, see Developing <strong>UniBasic</strong> Applications.<br />
1-278 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
function.name Specifies the name of the function (for documentation purposes<br />
only). It need not be the same as the name used to call the<br />
function.<br />
You must include this function’s cataloged file name in the<br />
DEFFUN statement in the calling program.<br />
(MAT arg.1 ,MAT<br />
arg.2...)<br />
Examples<br />
Specifies the arguments to be passed from the calling program.<br />
Arguments must be enclosed in parentheses and separated by<br />
commas. Precede an argument with MAT to indicate that the<br />
argument is an array. Up to 254 arguments can be passed.<br />
RETURN var Returns control to the calling program. Can pass back an<br />
argument.<br />
FUNCTION Parameters<br />
The following function performs calculations on a dimensioned array, returning<br />
values in the function arguments and return value, r. The name of the cataloged file<br />
that contains this function definition is yourfunc. This name must be used in the<br />
DEFFUN statement in the calling program. Notice that the function definition uses<br />
yet a different name (anotherfunc). The name anotherfunc is not referenced<br />
anywhere.<br />
FUNCTION anotherfunc(a, MAT b, c) ;* Start function<br />
definition.<br />
DIM b(-1) ;* Declare array.<br />
r = 0 ;* Initialize return value.<br />
c = 1 ;* Initialize value passed<br />
back.<br />
FOR i = 1 TO a ;* To the upper bound passed<br />
in:<br />
r += b(i) ;* Sum array members.<br />
c *= b(i) ;* Multiply array members.<br />
NEXT i<br />
RETURN r ;* Return value.<br />
FUNCTION 1-279
The following program calls the preceding function. Because the function is called<br />
myfunc within this program, the CALLING clause is included in the DEFFUN<br />
statement to identify the cataloged program file yourfunc. Note that values in<br />
arguments a and b are passed back, although they are not used by the program.<br />
1-280 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
DEFFUN myfunc(a, MAT b, c) CALLING "yourfunc" ;* Declare function.<br />
DIM b(10) ;* Define array.<br />
a = 2 ;* Set upper bound.<br />
FOR i = 1 TO a ;* Initialize array.<br />
b(i) = i<br />
NEXT i<br />
PRINT "r from FUNCTION: ":myfunc(a, MAT b, c)<br />
PRINT "c from FUNCTION: ":c<br />
The program runs and prints out the following text:<br />
:RUN BP FUNCTION.CALL<br />
r from FUNCTION: 3<br />
c from FUNCTION: 2<br />
Related Command<br />
<strong>UniBasic</strong><br />
DEFFUN
GARBAGECOLLECT<br />
Syntax<br />
GARBAGECOLLECT<br />
Description<br />
The <strong>UniBasic</strong> GARBAGECOLLECT command releases all reserved but nonactive<br />
memory allocated for <strong>UniBasic</strong> variables.<br />
1-281
GE<br />
Syntax<br />
expr1 GE expr2<br />
Synonyms<br />
#, >=<br />
Description<br />
The <strong>UniBasic</strong> >= relational operator tests whether expression expr1 is greater than or<br />
equal to expr2.<br />
expr1 and expr2 can be any valid <strong>UniBasic</strong> expressions, variables, strings, or literals.<br />
Relational operators make the comparisons that direct program flow in conditional<br />
statements like the following:<br />
1-282 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
IF VAR1 GE VAR2 THEN GOSUB SUB1<br />
DO UNTIL VAR1 >= VAR2<br />
Example<br />
In the following example, the program segment tests whether A is greater than or<br />
equal to B. Because A is greater than B, the message “Greater Than or Equal To”<br />
prints.<br />
A = 24<br />
B = 22<br />
IF A GE B THEN<br />
PRINT "Greater Than or Equal To"<br />
END ELSE<br />
PRINT "Less Than"<br />
END
Related Command<br />
<strong>UniBasic</strong><br />
GES<br />
1-283
generateKey<br />
Syntax<br />
generateKey(priveKey, pubKey, format, keyLoc, algorithm, keyLength, passPhrase,<br />
paramFile)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The generateKey() function generates a public key cryptography key pair and<br />
encrypts the private key. You should then put it into an external key file protected by<br />
the provided pass phrase. UniData SSL sessions can use the protected private key<br />
later to secure communication. The public key will not be encrypted.<br />
The generated private key will be in PKCS #8 form and is encoded in either PEM or<br />
DER format specified by format. The generated public key is in traditional form. If<br />
keyLoc is 1, the resulted key is put into a dynamic array in privKey and pubKey.<br />
Otherwise, they are put into OS level files specified by privKey and pubKey.<br />
To make sure the private key is protected, you must provide a pass phrase. UniData<br />
uses a one-way hash function to derive a symmetric key from the pass phrase to<br />
encrypt the generated key. When installing the private key into a security context with<br />
the setPrivateKey() function, or generating a certificate request with the generate-<br />
CertRequest() function, you must provide this pass phrase to gain access to the<br />
private key.<br />
For detailed information about the generateKey function, see <strong>UniBasic</strong> Extensions.<br />
1-284 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
privKey A string storing the generated private key or name of the file storing the<br />
generated private key.<br />
pubKey A string storing the generated public key or name of the file storing the<br />
generated public key.<br />
format 1 - PEM<br />
2 - DER<br />
keyLoc 1 - Put the key into string privKey/pubKey.<br />
2 - Put the key into a file.<br />
algorithm 1 - RSA<br />
2 - DSA<br />
keyLength Number of bits for the generated key. Between 512 and 2048.<br />
passPhrase A string storing the pass phrase to protect the private key.<br />
paramFile A parameter file needed by DSA key generation.<br />
generateKey Parameters<br />
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success.<br />
1 Key pair cannot be generated.<br />
2 Unrecognized key file format.<br />
3 Unrecognized encryption algorithm.<br />
4 Unrecognized key type or invalid key length (must be between 512 and<br />
2048).<br />
5 Empty pass phrase.<br />
generateKey Return Codes<br />
1-285
Return<br />
Code Status<br />
1-286 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
6 Invalid DSA parameter file.<br />
7 Random number generator cannot be seeded properly.<br />
8 Private key cannot be written.<br />
generateKey Return Codes (continued)
GES<br />
Syntax<br />
GES(array1,array2)<br />
Description<br />
The <strong>UniBasic</strong> GES function compares each value in array1 to its corresponding<br />
value in array2. UniData returns an array with 1 in each position where the value in<br />
array1 is greater than or equal to the value in the corresponding position in array2.<br />
UniData returns 0 in each position for values that are less than array2.<br />
Example<br />
In the following example, the program segment compares ARRAY1 to ARRAY2 and<br />
returns ARRAY3. ARRAY3 then contains 1}1}1}0}0.<br />
ARRAY1 = 10:@VM:20:@VM:30@VM:40:@VM:50<br />
ARRAY2 = 9:@VM:10:@VM:30:@VM:50:@VM:60<br />
ARRAY3 = GES(ARRAY1,ARRAY2)<br />
1-287
GET<br />
Syntax<br />
GET[X] var[,length] [SETTING count.var] FROM line.expr [UNTIL term.expr]<br />
[RETURNING term.var] [WAITING seconds]<br />
[THEN statements |ELSE statements]<br />
Description<br />
The <strong>UniBasic</strong> GET command receives unprompted input from an attached line.<br />
UniData accepts all control characters, including the carriage return and line feed as<br />
input characters. All data read from the attached line is placed in var. GET supports<br />
multibyte languages.<br />
Performance of the GET statement varies according to the termination conditions<br />
specified, and whether the THEN or ELSE clauses are specified.<br />
Input from the attached line is terminated in four ways:<br />
UniData has read the number of characters specified in length.<br />
After a single character is read (when length and UNTIL are not coded).<br />
When any character you specify in term.exp is encountered in input.<br />
When UniData reads the record mark character, @RM, and the number of<br />
seconds has elapsed.<br />
Note: UniData never executes the ELSE clause if you include UNTIL without<br />
WAITING or length.<br />
If you code the WAITING clause, UniData executes the ELSE clause only after the<br />
number of seconds specified for timeout. If the input is terminated for any other<br />
reason, UniData executes the THEN clause.<br />
In special cases, UniData executes the ELSE clause if the line has not been attached<br />
before executing the GET statement.<br />
1-288 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
X Specifies that GET return var as hexadecimal. This feature<br />
allows binary data to contain a 255 value (hexadecimal FF).<br />
For instance, if a user enters HELLO, the input data variable<br />
contains 48454C4C4F.<br />
var Specifies a variable to receive input.<br />
,length Specifies the number of characters to accept as input from the<br />
attached line. The default is one character unless you use<br />
UNTIL in the statement.<br />
SETTING count.var count.var is the number of characters received from the<br />
attached line.<br />
FROM line.expr line.expr is the attached line receiving input.<br />
UNTIL term.expr term.expr is a string of characters, any of which terminate<br />
input. The terminating character does not appear in the<br />
returned text variable.<br />
If you use UNTIL and do not specify term.expr, any number of<br />
characters is accepted. Characters often used for the UNTIL<br />
clause are carriage return and line feed.<br />
RETURNING term.var Assigns the character that terminates the input to term.var.<br />
Input terminates due to:<br />
Reaching the maximum number of characters.<br />
Timeout.<br />
Record mark encountered in input. In this case, term.var<br />
contains an empty string.<br />
WAITING seconds Specifies the number of seconds to wait before UniData times<br />
out.<br />
THEN<br />
statements | ELSE<br />
statements<br />
If the line is not attached, UniData performs the ELSE clause.<br />
If the line is not attached and there is not an ELSE clause, a<br />
runtime error displays and the user enters the <strong>UniBasic</strong><br />
debugger.<br />
GET Parameters<br />
1-289
Example<br />
In the following example, the program segment waits 15 seconds for 10 characters of<br />
input from line 0. If time expires before 10 characters are received from the attached<br />
line, UniData stops receiving, returns the data received, and performs the ELSE<br />
clause.<br />
1-290 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
GET TMP,10 FROM 0 WAITING 15<br />
ELSE PRINT "Input time has expired"<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
SEND<br />
UniData<br />
PROTOCOL – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.
getCipherSuite<br />
Syntax<br />
getCipherSuite(context,ciphers)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The getCipherSuite() function obtains information about supported cipher suites,<br />
their version, usage, strength and type for the security context you specify. The result<br />
is put into the dynamic array ciphers, with one line for each cipher suite, separated<br />
by a field mark (@FM). The format of the string for one cipher suite is as follows.<br />
Suite, version, key-exchange, authentication, encryption, digest,<br />
export<br />
Refer to the cipher tables in <strong>UniBasic</strong> Extensions for definitions of all suites. The<br />
following is an example of a typical Suite.<br />
EXP-DES-CBC-SHA SSLv3 Kx=RSA(512) Au=RSA Enc=DES(40) Mac=SHA1<br />
export<br />
The suite is broken down as follows. The suite name is EXP-DES-CBC-SHA. It is<br />
specified by SSLv3. The Key-exchange algorithm is RSA with 512-bit key. The<br />
authentication is also done by RSA algorithm. The Data encryption uses DES (Data<br />
Encryption Standard, an NIST standard) with CBC mode. MAC (Message Authentication<br />
Code, a hash method to calculate message digest) will be done with SHA-1<br />
(Secure Hash Algorithm 1, also an NIST standard) algorithm. The suite is exportable.<br />
UniData only retrieves those methods that are active for the protocol.<br />
1-291
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
The following table describes the status of each return code.<br />
1-292 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
context The Security Context handle.<br />
ciphers A Dynamic array containing the cipher strings delimited by @FM.<br />
getCipherSuite Parameters<br />
Return<br />
Code Status<br />
0 Success.<br />
1 Invalid Security Context handle.<br />
2 Unable to obtain information.<br />
Return Code Status
GETENV<br />
Syntax<br />
GETENV(var | "envir.var")<br />
Description<br />
The <strong>UniBasic</strong> GETENV function returns the contents of the UNIX, or Windows<br />
platform environment variable. If you include the environment variable explicitly (as<br />
opposed to including it in a variable), you must enclose it in quotation marks.<br />
Examples<br />
In the following example, the program statement retrieves the value of UDTBIN in<br />
X:<br />
X = GETENV("UDTBIN")<br />
In the next example, the program retrieves the value of UDTBIN in X, but uses a<br />
variable to define UDTBIN:<br />
VAR = "UDTBIN"<br />
X = GETENV(VAR)<br />
1-293
getHTTPDefault<br />
Syntax<br />
getHTTPDefault(option, value)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The getHTTPDefault function returns the default values of the HTTP settings. See<br />
the section under setHTTPDefault for additional information.<br />
Parameters<br />
The following table describes each parameter of the syntax:<br />
Parameter Description<br />
1-294 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
option Currently, the following options are defined:<br />
PROXY_NAME<br />
PROXY_PORT<br />
VERSION<br />
BUFSIZE<br />
AUTHENTICATE<br />
HEADERS<br />
value A string containing the appropriate option value.<br />
getHTTPDefault Parameters
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success.<br />
1 Invalid option.<br />
Return Code Status<br />
1-295
GETLIST<br />
Syntax<br />
GETLIST list.name [,acct.name] [TO list.num] [SETTING count.var]<br />
{THEN | ELSE} statements [END]<br />
Description<br />
The <strong>UniBasic</strong> GETLIST command restores a select list from a saved list.<br />
Tip: Use GETLIST to access a list without having to issue multiple SELECT or<br />
SSELECT commands.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-296 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
list.name Specifies the saved list.<br />
acct.name Specifies a full path of a directory where the list resides if<br />
list.name is not in the current account.<br />
TO list.num Specifies the number of the active list. list.num can be 0 through<br />
9. The default list is 0.<br />
SETTING count.var Specifies a variable to contain the number of elements the<br />
GETLIST command generates.<br />
THEN | ELSE<br />
statements<br />
Specifies statements to execute if the command succeeds<br />
(THEN) or fails (ELSE). Either a THEN or an ELSE statement<br />
is required. END is required to terminate multiline statements.<br />
GETLIST Parameters
Examples<br />
In the following example, the program segment retrieves the previously saved list<br />
CS_STAFF and assigns it to active list 2. If the list is not found, the program aborts<br />
and displays an error message.<br />
GETLIST "CS_STAFF" TO 2 ELSE<br />
ABORT "NO CS_STAFF saved list found."<br />
In the next example, the program segment creates a select list and saves it. GETLIST<br />
then retrieves the saved list to active list 0 (the default). The program then uses the<br />
IDs in list 0 to retrieve the first 22 Canadian clients.<br />
EXECUTE 'SELECT CLIENTS WITH COUNTRY = "Canada"'<br />
EXECUTE "SAVE.LIST 'canadians'"<br />
OPEN 'CLIENTS' TO CLIENT.FILE ELSE ABORT<br />
GETLIST 'canadians'<br />
ELSE PRINT "SELECT LIST CANNOT BE FOUND";STOP<br />
PRINT @(-1)<br />
FOR I = 1 TO 22<br />
READNEXT ID ELSE EXIT<br />
READ REC FROM CLIENT.FILE, ID THEN<br />
PRINT @(5,I):REC:@(20,I):REC<br />
END ELSE<br />
PRINT "CANNOT FIND RECORD":ID<br />
END<br />
NEXT I<br />
CLEARSELECT<br />
END<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DELETELIST, FORMLIST, READLIST, READNEXT, SELECT, SELECT-<br />
INDEX, SELECTINFO, WRITELIST<br />
UniQuery<br />
DELETE.LIST, GET.LIST, SELECT, SSELECT, SAVE.LIST – For information, see<br />
the UniQuery <strong>Commands</strong> <strong>Reference</strong>.<br />
1-297
UniData SQL<br />
SELECT – For information, see the UniData SQL <strong>Commands</strong> <strong>Reference</strong>.<br />
1-298 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
GETPTR<br />
Syntax<br />
GETPTR(unit.no)<br />
Description<br />
The <strong>UniBasic</strong> GETPTR function returns a string variable containing the values of<br />
the current printer settings for the unit.no specified.<br />
Tip: GETPTR can store the values associated with a print unit so those values can be<br />
reset to their initial values at the end of a process.<br />
GETPTR Function Return Values<br />
The GETPTR function returns a string containing the same set of values as specified<br />
in the ECL SETPTR function, including the print unit and the options. The following<br />
table describes these values.<br />
Return Description<br />
unit The number assigned to a given printer through UniData, from 0 through<br />
255. (The default is 0.)<br />
width The number of characters per line, from 0 to 256 characters.<br />
length The number of lines per page, from 1 to 32,767 lines.<br />
topmargin The number of lines to leave blank at the top of each page, from 0 to 25.<br />
bottommargin The number of lines to leave blank at the bottom of each page, from 0 to<br />
25.<br />
mode Destination of output. For mode values, see SETPTR in the UniData<br />
<strong>Commands</strong> <strong>Reference</strong>.<br />
options Print options such as BANNER, COPIES, NHEAD, and FORM. For<br />
option values, see SETPTR in the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
GETPTR Function Return Values<br />
1-299
STATUS Function Return Values<br />
After you execute GETPTR, the STATUS function returns one of the values<br />
described in the following table.<br />
Example<br />
In the following example, the program segment assigns the printer settings to the<br />
variable PRINTER.STRING:<br />
PRINTER.STRING = GETPTR(1)<br />
Related Command<br />
UniData<br />
SETPTR – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
1-300 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Value Description<br />
0 If success.<br />
1 If there are no more rows.<br />
2 Other error.<br />
STATUS Function Return Values
GETPU<br />
Syntax<br />
GETPU(unit.number)<br />
Description<br />
The <strong>UniBasic</strong> GETPU function returns the full path of the current print or hold file<br />
ID created by the current user process. unit.number is the number of the logical<br />
printer unit.<br />
Tip: Use the ECL SETPTR command to determine the current printer unit of your<br />
system.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
GETPTR<br />
UniData<br />
SETPTR – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
1-301
GETQUEUE<br />
Syntax<br />
GETQUEUE()<br />
Description<br />
The <strong>UniBasic</strong> GETQUEUE function returns a dynamic array containing information<br />
about all records currently locked and waiting to be released.<br />
<strong>UniBasic</strong> commands that check for locks, such as READU and READVU, cause<br />
processes to wait for locks to be released before proceeding.<br />
This command delivers the same information as the ECL command LIST.QUEUE,<br />
but in a different format. A value mark separates these pieces of information. An<br />
attribute mark separates the information about different locks.<br />
If GETQUEUE is successful, UniData sets @SYSTEM.RETURN.CODE to the<br />
number of locks waiting to be released. If unsuccessful, UniData sets<br />
@SYSTEM.RETURN.CODE to -1.<br />
Note: <strong>UniBasic</strong> locks are advisory only. For more information, see Developing<br />
<strong>UniBasic</strong> Applications.<br />
GETQUEUE Function Return Values<br />
The GETQUEUE function returns the values described in the following table.<br />
Value Description<br />
1-302 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
UDTNO The number of the UniData process that locked the file.<br />
USERNBR The ID of the process that ran the UniData application that locked the<br />
file.<br />
UID The user ID of the user who ran the UniData application that locked the<br />
file.<br />
GETQUEUE Function Return Values
Value Description<br />
USERNAME The user name of the user who ran the UniData application that locked<br />
the file.<br />
TTY The terminal ID of the user who ran the UniData application that locked<br />
the file.<br />
FILE NAME The name of the locked file.<br />
INBR The i-node number used by the locked file.<br />
For Windows platforms, this value consists of the high integer and low<br />
integer of the i-node used by the locked file. The high integer and the<br />
low integer are separated by a space.<br />
DNBR The device number used by the locked file.<br />
RECORD ID The ID of the record in the file that is being updated.<br />
MODE The mode of the command that locked the file.<br />
GETQUEUE Function Return Values (continued)<br />
1-303
GETREADU<br />
Syntax<br />
GETREADU()<br />
Description<br />
The <strong>UniBasic</strong> GETREADU function returns a dynamic array containing information<br />
about all records that have been locked by any <strong>UniBasic</strong> or ECL command<br />
that updates any record.<br />
This command delivers the same information as the ECL command LIST.READU,<br />
but in a different format. A value mark separates these pieces of information. An<br />
attribute mark separates the information about different locks.<br />
If GETREADU is successful, UniData sets @SYSTEM.RETURN.CODE to the<br />
number of locks set. If unsuccessful, UniData sets @SYSTEM.RETURN.CODE to<br />
-1.<br />
Note: <strong>UniBasic</strong> locks are advisory only. For more information, see the Developing<br />
<strong>UniBasic</strong> Applications.<br />
GETREADU Function Return Values<br />
1-304 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
The GETREADU function returns the values described in the following table.<br />
Value Description<br />
UDTNO The number of the UniData process that locked the file.<br />
USERNBR The ID of the process that ran the UniData application that locked the<br />
file.<br />
UID The user ID of the user who ran the UniData application that locked the<br />
file.<br />
USERNAME The user name of the user who ran the UniData application that locked<br />
the file.<br />
TTY The terminal ID of the user who ran the UniData application that locked<br />
the file.<br />
FILE NAME The name of the locked file.<br />
INBR The i-node number used by the locked file.<br />
For Windows platforms, this value consists of the high integer and low<br />
integer of the inode used by the locked file. The high integer and the low<br />
integer are separated by a space.<br />
DNBR The device number used by the locked file.<br />
RECORD ID The ID of the record in the file that is being updated.<br />
MODE The mode of the command that locked the file.<br />
TIME The time the lock was set.<br />
DATE The date the lock was set.<br />
GETREADU Function Return Values<br />
1-305
getResponseHeader<br />
Syntax<br />
getResponseHeader(request_handle, header_name, header_value)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
This function gets a specific response header value from response headers returned<br />
by submitRequest(). It can be used to query if a specific header, for example,<br />
Content-encoding, is present in the response.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
The following table describes the status of each return code.<br />
1-306 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
request_handle The handle to the request.<br />
header_name A string containing a response header name.<br />
header_value The value of the header, if present. Otherwise, an empty string.<br />
getResponseHeader Parameters<br />
Return Code Status<br />
0 Success.<br />
1 Invalid request handle.<br />
2 Header not found.<br />
get ResponseHeader Return Code
getSocketInformation<br />
Syntax<br />
getSocketInformation(socket_handle, self_ or_ peer, socket_info)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Use the getSocketInformation function to obtain information about a socket<br />
connection.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
socket_handle The handle to the open socket.<br />
self_ or_ peer Get information on the self end or the peer end of the socket. Specify 0<br />
to return information from the peer end and non-zero for information<br />
from the self end.<br />
socket_info Dynamic Array containing information about the socket connection.<br />
For information about the elements of this dynamic array, see the<br />
following table.<br />
getSocketInformation Parameters<br />
1-307
The following table describes each element of the socket_info dynamic array.<br />
The following table describes the status of each return code.<br />
1-308 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Element Description<br />
1 Open or closed<br />
2 Name or IP<br />
3 Port number<br />
4 Secure or Non-secure<br />
5 Blocking mode<br />
getSocketInformation Parameters<br />
Return Code Status<br />
0 Success.<br />
Non-zero See Socket Function Error Return Codes.<br />
getSocketInformation Return Codes
getSocketOptions<br />
Syntax<br />
getSocketOptions(socket_handle, Options)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The getSocketOptions function gets the current value for a socket option associated<br />
with a socket of any type.<br />
1-309
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
The following table describes the available options (case-sensitive) for<br />
getSocketOptions().<br />
1-310 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
socket_handle The socket handle from openSocket(), acceptSocket(), or<br />
initServerSocket().<br />
options A Dynamic Array containing information about the socket options and<br />
their current settings. When querying for options, the dynamic array is<br />
configured as:<br />
optName1<br />
optName2<br />
optName...<br />
When the options are returned, the dynamic array is configured as:<br />
optName1optValue1a[optValue1b]<br />
optName2optValue2a[optValue2b]<br />
optName3...<br />
Where optName contains an option name string listed below. The first<br />
optValue describes if the option is ON or Off and must be one of two<br />
possible values: “1” for ON or “2” for OFF. The second optValue is<br />
optional and may hold additional data for a specific option. Currently,<br />
for option “LINGER”, it contains the delayed time (in milliseconds)<br />
before closing the socket.<br />
getSocketOptions Parameters<br />
Option Description<br />
DEBUG Enable/disable recording of debug information.<br />
REUSEADDR Enable/disable the reuse of a location address (default).<br />
KEEPALIVE Enable/disable keeping connections alive.<br />
DONTROUTE Enable/disable routing bypass for outgoing messages.<br />
LINGER Linger on close if data is present.<br />
getSocketOptions Options
Option Description<br />
BROADCAST Enable/disable permission to transmit broadcast messages.<br />
OOBINLINE Enable/disable reception of out-of-band data in band..<br />
SNDBUF Get buffer size for output (default 4KB).<br />
RCVBUF Get buffer size for input (default 4KB).<br />
TYPE Get the type of the socket.<br />
ERROR Get and clear error on the socket.<br />
getSocketOptions Options (continued)<br />
The following table describes the status of each return code.<br />
Return Code Status<br />
0 Success.<br />
Non-zero See Socket Function Error Return Codes.<br />
getSocketOptions Return Codes<br />
1-311
GETUSERGROUP<br />
Syntax<br />
GETUSERGROUP(uid)<br />
Description<br />
For UNIX, the <strong>UniBasic</strong> GETUSERGROUP function returns the group number for<br />
the user ID you specify by uid. For Windows platforms, it returns 0.<br />
Examples<br />
In the following example, the program statement assigns the user group to variable X:<br />
X = GETUSERGROUP(@UID)<br />
In the next example, the program statement assigns the user group for 1023 to<br />
variable X:<br />
X = GETUSERGROUP(1023)<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
GETUSERID, GETUSERNAME<br />
1-312 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
GETUSERID<br />
Syntax<br />
GETUSERID(user.name)<br />
Description<br />
The <strong>UniBasic</strong> GETUSERID function returns the user ID for a user name. For UNIX,<br />
this is the system-recognized user ID. For Windows platforms, the returned user ID<br />
is meaningful in UniData only.<br />
Example<br />
In the following example, the program statement assigns the user ID for “John” to<br />
variable X:<br />
X = GETUSERID("John")<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
GETUSERGROUP, GETUSERNAME<br />
1-313
GETUSERNAME<br />
Syntax<br />
GETUSERNAME(uid)<br />
Description<br />
The <strong>UniBasic</strong> GETUSERNAME function returns the user name for a user ID. To<br />
obtain the ID of the current user, use the <strong>UniBasic</strong> @UID variable (or, for UNIX,<br />
enter “id” at the UNIX prompt). After you obtain the user ID, you can specify it<br />
explicitly in the GETUSERNAME function.<br />
Examples<br />
In the following example, the program statement assigns the user name to variable X:<br />
X = GETUSERNAME(@UID)<br />
In the next example, the program statement assigns the user name for 1023 to variable<br />
X:<br />
X = GETUSERNAME(1023)<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
GETUSERGROUP, GETUSERID<br />
1-314 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
GOSUB<br />
Syntax<br />
GOSUB label[:]<br />
Description<br />
The <strong>UniBasic</strong> GOSUB command transfers program control to an internal subroutine.<br />
UniData requires a valid statement label. Control returns to the main program when<br />
the RETURN statement is encountered in the subroutine.<br />
Examples<br />
The following program segment is taken from the sample program in Appendix A,<br />
“Sample Program,” in Developing <strong>UniBasic</strong> Applications. This is an example of<br />
subroutines used in structured programming style.<br />
*-------------- Main Logic -----------------------------<br />
GOSUB INITIALIZE<br />
LOOP<br />
GOSUB DISPLAY_SCREEN<br />
GOSUB GET_ORDER_NUMBER<br />
UNTIL ORDER_NUMBER[1,1] = 'Q'<br />
GOSUB DISPLAY_DATA<br />
IF RECORD_FOUND THEN GOSUB GET_RECORD_COMMAND<br />
RELEASE<br />
REPEAT<br />
GOSUB EXIT<br />
In the next example, the program segment prints:<br />
“Now we go to the subroutine.”<br />
“Now in subroutine BRANCHOUT.”<br />
1-315
1-316 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
“Back from subroutine BRANCHOUT.”<br />
PRINT "Now we go to the subroutine."<br />
GOSUB BRANCHOUT<br />
PRINT "Back from subroutine BRANCHOUT."<br />
STOP<br />
BRANCHOUT:<br />
PRINT "Now in subroutine BRANCHOUT."<br />
RETURN<br />
END<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
GOTO, ON/GOSUB, RETURN
GOTO<br />
Syntax<br />
GOTO label [:]<br />
Synonym<br />
GO<br />
Description<br />
The <strong>UniBasic</strong> GOTO command branches unconditionally to a statement label within<br />
a program or subroutine. A statement label must exist in the program or subroutine.<br />
If the label you specify does not exist, the compiler generates an error message and<br />
the program aborts. After a program executes a GOTO, it does not keep track of the<br />
point of departure, but simply moves to the new statement and begins executing<br />
there.<br />
You cannot use the <strong>UniBasic</strong> RETURN command in conjunction with a GOTO<br />
statement.<br />
Tip: Use GOSUB instead of GOTO to make your programs easier to follow and<br />
maintain.<br />
Examples<br />
In the following example, the program statement transfers program control to the<br />
statement label 2510:<br />
GOTO 2510<br />
In the next example, the program statement transfers control to the statement label<br />
START if the variable RETRY is true:<br />
IF RETRY GOTO START<br />
1-317
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
GOSUB, ON/GOTO<br />
1-318 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
GROUP<br />
Syntax<br />
GROUP(str, delim, start, rtn.num)<br />
Description<br />
The <strong>UniBasic</strong> GROUP function extracts the number of continuous groups you<br />
specify from the given string.<br />
GROUP functions similar to option G of the OCONV Group (G) function (group<br />
extraction conversion), but allows any single character, including a system delimiter,<br />
null value, number, or minus sign (-) as a delimiter. Another difference is that the start<br />
parameter of the GROUP function specifies the starting group to return, while<br />
OCONV specifies the number of leading groups to skip.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
str Specifies the string from which to extract groups.<br />
delim Specifies any ASCII character that delimits groups in the string.<br />
start Specifies the first of the groups to return.<br />
rtn.num Specifies the number of continuous groups included in the result.<br />
If the rtn.num is greater than the number of groups remaining in the string,<br />
the function finishes after the entire remaining string is exhausted.<br />
GROUP Parameters<br />
1-319
Examples<br />
In the following example, the program statement assigns 1231 to the variable A:<br />
1-320 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
A = GROUP("123124125126","2",1,2)<br />
In the next example, the program segment prints “Boulder” because it is the second<br />
group separated by ‘:’, and only one group is returned:<br />
ST = "Denver:Boulder:Aurora:Littleton"<br />
PRINT GROUP(ST,':',2,1)<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
FIELD, OCONV Group (G)
GROUPSTORE<br />
Syntax<br />
GROUPSTORE substr IN str USING start.num,replace.num [,delimiter]<br />
Description<br />
The <strong>UniBasic</strong> GROUPSTORE command inserts a given substring or portion of a<br />
substring into a string, and replaces all, part, or none of the string. The string can be<br />
delimited by the single character delimiter. The unit of replacement is called an<br />
element in this section.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
substr Specifies the substring you want to insert into the string. substr can contain<br />
any combination of numeric, alphabetic, or special characters.<br />
str Specifies the target string into which substr is inserted.<br />
GROUPSTORE Parameters<br />
1-321
Parameter Description<br />
The replace.num option controls whether GROUPSTORE replaces all, part, or none<br />
of the substring. The following table describes these options.<br />
1-322 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
start.num Specifies the position from which to begin replacing elements of the string.<br />
start.num must be at least 1. If you specify a value of less than 1, start.num<br />
defaults to 1. If start.num is negative and replace.num is not negative,<br />
<strong>UniBasic</strong> uses the absolute value of start.num.<br />
If start.num is greater than the number of elements in the target string,<br />
<strong>UniBasic</strong> appends the substr to the end of the string with the appropriate<br />
number of delimiters in between.<br />
replace.num Specifies the number of elements in the string to replace with elements of<br />
substr.<br />
Refer to the next table for values for replace.num.<br />
,delimiter Specifies a single ASCII character to use as a delimiter. The default<br />
delimiter is @AM. If you specify more than one character for delimiter,<br />
<strong>UniBasic</strong> uses the first character.<br />
replace.nu<br />
m Value Description<br />
GROUPSTORE Parameters (continued)<br />
> 0 The first replace.num elements of the substr replaces elements of the string<br />
starting from the position specified by start.num. If the string contains fewer<br />
than replace.num elements starting from start.num, the replacement stops<br />
after the string is exhausted.<br />
0 The entire substr is inserted before the start.num position in the string.<br />
< 0 The number of elements specified in replace.num are deleted starting at<br />
start.num, and substr replaces them.<br />
If both start.num and replace.num are less than 0, replacement does not take<br />
place. Only the number of elements specified in replace.num are deleted,<br />
starting at start.num.<br />
GROUPSTORE Replace Number Values
Examples<br />
In the following example, the program segment assigns the value stored in string<br />
SUB in string A. Because the starting number is 2, and no delimiter is specified,<br />
UniData uses the attribute mark (@AM) as the delimiter.<br />
A = "123":@AM:"ABC":@AM:"456":@VM:"DEF":@AM:"012":@VM:"GHI"<br />
SUB = "***"<br />
GROUPSTORE SUB IN A USING 2,1<br />
This results in:<br />
A =<br />
"123":@AM:"***":@AM:"456":@VM:"DEF":@AM:"012":@VM:"GHI"<br />
In the next example, the program segment replaces both values in the third attribute<br />
in A with SUB. Though the replacement number is 2, UniData replaces only one<br />
attribute because SUB has only one element.<br />
A = "123":@AM:"ABC":@AM:"456":@VM:"DEF":@AM:"012":@VM:"GHI"<br />
SUB = "###"<br />
GROUPSTORE SUB IN A USING 3,2<br />
This results in:<br />
A = "123":@AM:"ABC":@AM:"###":@AM:"012":@VM:"GHI"<br />
In the next example, the program segment inserts SUB before position 1 in A:<br />
A = "123":@AM:"ABC":@AM:"456":@VM:"DEF":@AM:"012":@VM:"GHI"<br />
SUB = "begin"<br />
GROUPSTORE SUB IN A USING 1,0<br />
This results in:<br />
A = "begin":@AM:"123":@AM:"ABC":@AM:"456":<br />
@VM:"DEF":@AM:"012":@VM:"GHI"<br />
In the next example, the program segment replaces the first two attributes and their<br />
associated subvalues with SUB using @VM as the delimiter:<br />
A = "123":@AM:"ABC":@AM:"456":@VM:"DEF":@AM:"012":@VM:"GHI"<br />
SUB = "mv1":@VM:"sub1":@SM:"sub2":@VM:"mv2"<br />
GROUPSTORE SUB IN A USING 1,2,@VM<br />
This results in:<br />
A = "mv1":@AM:"sub1":@AM:"sub2":@VM:"GHI"<br />
1-323
This next example compiles and runs only with null value handling turned on. The<br />
program segment replaces the third element with three asterisks. This program<br />
segment calls the externally cataloged subroutine PRINT.SETUP, which converts the<br />
null value and UniData delimiters to printable characters, and then prints the<br />
converted string.<br />
1-324 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
PRT.STR = ''<br />
A<br />
="123":@AM:"ABC":@AM:"456":@VM:"DEF":@VM:@NULL:@AM:"012":@VM:@NULL<br />
:@VM:"GHI"<br />
SUB = "***"<br />
GROUPSTORE SUB IN A USING 3,1,@VM<br />
STR = A<br />
CALL PRINT.SETUP(STR,PRT.STR)<br />
PRINT "A = ":PRT.STR<br />
This program segment prints:<br />
A = 123@AMABC@AM456@VMDEF@VM***@VM@NULL@VMGHI
GT<br />
Syntax<br />
expr1 GT expr2<br />
Synonym<br />
><br />
Description<br />
The <strong>UniBasic</strong> relational operator GT tests whether expression expr1 is greater than<br />
expr2.<br />
expr1 and expr2 can be any valid <strong>UniBasic</strong> expressions, variables, strings, or literals.<br />
Relational operators make the comparisons that direct program flow in conditional<br />
statements such as the following:<br />
IF VAR1 GT VAR2 THEN GOSUB SUB1<br />
DO UNTIL VAR1 > VAR2<br />
Example<br />
In the following example, the program segment tests whether A is greater than B.<br />
Because A is greater than B, the message “Greater Than” prints.<br />
A = 24<br />
B = 22<br />
IF A GT B THEN<br />
PRINT "Greater Than"<br />
END ELSE<br />
PRINT "Less Than"<br />
END<br />
1-325
Related Command<br />
<strong>UniBasic</strong><br />
GTS<br />
1-326 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
GTS<br />
Syntax<br />
GTS(array1,array2)<br />
Description<br />
The <strong>UniBasic</strong> GTS function compares each value in array1 to its corresponding<br />
value in array2. UniData returns an array with 1 in each position where the value in<br />
array1 is greater than the value in the corresponding position in array2, and 0 in each<br />
position for values that are less than array2.<br />
Example<br />
In the following example, the program segment compares ARRAY1 to ARRAY2 and<br />
returns ARRAY3. ARRAY3 then contains 1}1}0}0}0.<br />
ARRAY1 = 10:@VM:20:@VM:30@VM:40:@VM:50<br />
ARRAY2 = 9:@VM:10:@VM:30:@VM:50:@VM:60<br />
ARRAY3 = GTS(ARRAY1,ARRAY2)<br />
1-327
HASH<br />
Syntax<br />
HASH(rec.key,modulo,type)<br />
Description<br />
The <strong>UniBasic</strong> HASH function determines to which group a particular record key is<br />
hashed, depending on the modulo and the file type. HASH returns the group number<br />
in which a record with a key of rec.key is stored. HASH includes a file type<br />
parameter.<br />
When rec.key, modulo, and type are passed to the function, HASH returns the group<br />
number to which the record key will hash.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-327 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
rec.key Specifies the record key to hash.<br />
modulo Specifies the file modulo, the number of groups specified when the file was<br />
created.<br />
type For the file being tested, specifies static or dynamic and hash type, as determined<br />
when the file was created. You can use the following types:<br />
0 – Test a static file with hash type 0<br />
1 – Test a static file with hash type 1<br />
64 – Test a dynamic file with hash type 0<br />
65 – Test a dynamic file with hash type 1<br />
HASH Parameters
HEADING<br />
Syntax<br />
HEADING [ON expr] str.expr ['option']...<br />
Description<br />
The <strong>UniBasic</strong> HEADING command prints a string you specify at the top of each<br />
report page on the current print device.<br />
Note: The HEADING command clears the screen before displaying a report.<br />
HEADING 1-328
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Examples<br />
In the following example, the HEADING statement sends a heading to print file 3:<br />
“current page number Shareholders Report current date”.<br />
1-329 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ON expr Directs UniData to send output to print file expr. As many as 31 print files<br />
can be active at a time. The print files can have identifiers of 0–254.<br />
str.expr Specifies a string to print at the top of each report page. You can use special<br />
characters, such as unmatched single and double quotation marks, in<br />
str.expr.<br />
'option' option must be enclosed in single quotation marks. You can place option(s)<br />
anywhere in the heading expression. option can be any of the following:<br />
ASCII code – Passes code controlling paging characteristics.<br />
P or S – Prints current page number.<br />
N – Suppresses the pagination prompt after each page.<br />
L – Advances one line. Used for multiline headings.<br />
D – Prints date in MM-DD-YY format.<br />
T – Prints time/date in MM-DD-YY HH:MM:SS format.<br />
C – Centers the heading text.<br />
G – Forces the line to fill the width of the page.<br />
W – Causes a page to fill completely before breaking and printing the<br />
heading when the HEADING statement is first encountered. If you do not<br />
specify W, UniData creates a new page break when it first encounters the<br />
HEADING statement.<br />
HEADING Parameters<br />
HEADING ON 3 "'P' Shareholders Report 'D'"<br />
In the next example, the HEADING statement prints the current page number, and<br />
the current date and time, on the top of the default print device. The N code causes<br />
the report to print continuously, not requiring a carriage return after each page.<br />
HEADING "'PTN'"
This results in the following heading: 1207-21-91 12:13:00.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
FOOTING, GETPTR, PRINTER<br />
UniData<br />
SETPTR – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
HEADING 1-330
HUSH<br />
Syntax<br />
HUSH {ON | OFF | expr} [SETTING pre.status.var]<br />
Description<br />
The <strong>UniBasic</strong> HUSH command enables or disables terminal output.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-331 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ON Disables the terminal output.<br />
OFF Enables the terminal output.<br />
expr Disables the terminal output if expr is not 0. Enables terminal output if<br />
expr is 0. expr must be a numeric value.<br />
SETTING<br />
pre.status.var<br />
The SETTING clause sets the previous terminal status (1 for ON and 0 for<br />
OFF) to pre.status.var.<br />
HUSH Parameters
Example<br />
In the following example, the program segment prints 1 and -1 on the terminal screen<br />
because the HUSH command enables the terminal (A + B evaluates to 0). The second<br />
PRINT statement produces nothing on the screen because HUSH ON is set. The third<br />
PRINT command prints C = 1 on the screen because terminal output is enabled.<br />
A = 1; B = -1<br />
HUSH A + B<br />
PRINT A,B<br />
HUSH ON<br />
PRINT A + B<br />
HUSH OFF SETTING C<br />
PRINT "C = ":C<br />
HUSH 1-332
ICONV<br />
Syntax<br />
ICONV(expr,conv.code.expr)<br />
Description<br />
The <strong>UniBasic</strong> ICONV function converts string or numeric data to internal representation<br />
format based on conversion codes. ICONV supports multibyte languages. If<br />
the input value or conversion code is invalid, UniData returns the input value.<br />
With null value handling turned on, the presence of the null value in data produces a<br />
result of the null value, and the STATUS function return value is set to 5.<br />
Note: In BASICTYPE P, ICONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-333 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
expr Specifies the expression (a string or numeric data) to convert.<br />
conv.code.expr Specifies an internal representation format to use when converting expr.<br />
ICONV Parameters
The following table summarizes the valid conversion codes. A detailed discussion of<br />
each follows under separate headings.<br />
Code Format<br />
D System date.<br />
G Extracts one or more strings separated by a delimiter.<br />
L Length.<br />
MB Binary.<br />
MC Masked character.<br />
MD Masked decimal.<br />
ME Masked extended.<br />
ML Left justify.<br />
MP Packed decimal.<br />
MP1 Convert to packed decimal without truncating at the first CHAR(0) or altering<br />
this character.<br />
MO Octal.<br />
MR Right justify.<br />
MT System time.<br />
MX Hexadecimal.<br />
P Pattern match.<br />
R Range.<br />
S SOUNDEX.<br />
T Text extraction.<br />
Tfile File translation.<br />
ICONV Codes<br />
ICONV 1-334
STATUS Function Return Values<br />
After you execute ICONV, the STATUS function returns one of the values described<br />
in the following table.<br />
Examples<br />
The following program segment demonstrates the date and time conversions:<br />
1-335 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ORDER.REC = ICONV(ORDER_DATE,"D")<br />
ORDER.REC = ICONV(ORDER_TIME,"MT")<br />
The following program segment is taken from the sample program in Appendix A,<br />
“Sample Program,” in Developing <strong>UniBasic</strong> Applications. It demonstrates the<br />
alternate syntax that does not use the ICONV function name. This code right-justifies<br />
a string of 10 characters so that the data lines up on the right.<br />
PRODUCT_LINE := " ":PRODUCT_NUMBER "R#10"<br />
COLOR_LINE := " ":COLOR "R#10"<br />
QUANTITY_LINE := " ":QUANTITY "R#10"<br />
PRICE_LINE := " ":PRICE "R#10"<br />
Related Command<br />
<strong>UniBasic</strong><br />
OCONV<br />
Value Description<br />
0 Successful conversion.<br />
1 Invalid input data.<br />
2 Invalid conversion specification.<br />
3 Invalid date for “D” conversion code only.<br />
5 Null value if null value handling is turned on.<br />
STATUS Function Return Values
ICONV Date (D)<br />
Syntax<br />
ICONV(ext.date, "D [y] [c]")<br />
Description<br />
The ICONV date (D) function converts display representations of dates into simple<br />
integer internal format. Internal date format is the number of days before or since<br />
December 31, 1967. If the input value or conversion code is invalid, UniData returns<br />
the input value.<br />
Note: UniData ignores leading and trailing spaces around the input date.<br />
In BASICTYPE P, ICONV returns an empty string if UDT.OPTIONS 56 is on and the<br />
input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Paramete<br />
r Description<br />
ext.date Specifies the date, in display format, to convert to internal format. Valid<br />
delimiters include the slash, comma, hyphen, and period.<br />
D Indicates a date conversion.<br />
y c The ICONV function does not use y and c, but they are accepted to maintain<br />
consistency with the OCONV Date (D) function.<br />
ICONV Date Parameters<br />
Points to Remember When Entering Dates<br />
To avoid unexpected results when you convert dates into internal date format by<br />
using ICONV, be aware of the following:<br />
ICONV Date (D) 1-336
1-337 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
If you do not enter a year, UniData defaults to the current year. For example,<br />
if you enter 12/1 and the year is 1996, UniData stores 10563 (12/1/96).<br />
If you enter a number between 1 and 12 for month, UniData defaults to the<br />
first day of the month in the current year. For example, if you enter just 12<br />
during 1996, UniData stores 10563 (12/1/96).<br />
Any two-digit year entered in the range 00–29 defaults to the twenty-first<br />
century. For example, UniData interprets 12/31/29 as December 31, 2029.<br />
Any two-digit year entered in the range 30–99 is considered to be 1930–<br />
1999.<br />
Converting More Than Once<br />
Depending on the date range, if an application performs ICONV on an already<br />
converted date, UniData could produce unexpected results. Dates that convert into<br />
four- or five-digit internal formats and meet the following conditions fall into this<br />
category:<br />
The first two digits are 10, 11, or 12.<br />
The second two digits are 01 through 31.<br />
The fifth digit is any number from 0 through 9. Where there is no fifth digit,<br />
UniData assigns the current year.<br />
For example, assuming 5/28/95 is the input, the code segment shown on the left<br />
results in the displays on the right:<br />
INPUT VAR<br />
VAR=ICONV(VAR,'D')<br />
PRINT VAR 10010<br />
PRINT OCONV(VAR,'D') 28 MAY 1995<br />
VAR=ICONV(VAR,'D')<br />
PRINT VAR 11963<br />
PRINT OCONV(VAR,'D') 01 OCT 2000<br />
The first ICONV returns a value of 10010. OCONV correctly returns the external<br />
format. The date matches the initial entry. However, the second ICONV accepts the<br />
internal format, 10010, as input; UniData translates this as October 1, 2000, and<br />
ICONV returns an internal format of 11963. The final OCONV returns 01 OCT 2000.<br />
Note: To prevent the preceding scenario, you can make all numeric input of fewer<br />
than six characters invalid by turning UDT.OPTIONS 82 on. However, your<br />
applications will no longer be able to process the abbreviated input dates.
STATUS Function Return Values<br />
After you execute ICONV D, the STATUS function returns one of the values<br />
described in the following table.<br />
Value Description<br />
0 Successful conversion of a valid date.<br />
1 Invalid input date.<br />
2 Invalid conversion specification.<br />
3 Date was converted correctly, but month and day were inverted in input value.<br />
STATUS Function Return Values<br />
Note: After you execute the ICONV D function, the STATUS function returns a code<br />
indicating the execution status of the conversion of the last array element only.<br />
Examples<br />
The following table describes common date conversions and their results.<br />
Value Code Result<br />
09/15/85 D 6468<br />
12/31/67 D 0<br />
December 31, 1967 D 0<br />
01/29/1988 D 7334<br />
Common Date Conversions<br />
In the following example, the program segment prints the date in internal and display<br />
format:<br />
INPUT IN_DATE<br />
INTERNAL = ICONV(IN_DATE,"D")<br />
OUTPUT = OCONV(INTERNAL, "D4/")<br />
PRINT IN_DATE,INTERNAL,OUTPUT<br />
ICONV Date (D) 1-338
The following table describes various dates you can input in the previous program<br />
and their conversions.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DATE, OCONV Date (D), TIMEDATE<br />
1-339 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
In_Date Internal Output<br />
1 8402 01/01/1991<br />
11 8706 11/01/1991<br />
011 8402 01/01/1991<br />
12 8736 12/01/1991<br />
121 8736 12/01/1991<br />
110389 8709 11/03/1989<br />
1/1 8402 01/01/1991<br />
1/1/89 8402 01/01/1989<br />
1/1/02 12420 01/01/2002<br />
Example Date Conversions
ICONV Group (G)<br />
Syntax<br />
ICONV(str.expr, "G[m]*n")<br />
Description<br />
The ICONV group (G) function extracts one or more strings separated by a delimiter.<br />
If the input value or conversion code is invalid, UniData returns the input value.<br />
Note: In BASICTYPE P, ICONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
str.expr Indicates a string separated by a delimiter.<br />
G Group extraction code.<br />
m Indicates the number of strings to skip. If m is omitted, no strings are<br />
skipped.<br />
* Specifies any single nonnumeric character that is the delimiter. A minus sign<br />
(-) is not valid. UniData system delimiters are valid also.<br />
n The number of strings to be extracted.<br />
ICONV Group (G) Parameters<br />
Example<br />
In the following example, the program segment prints (303):<br />
X = "(303)+555+0988"<br />
PRINT ICONV(X,"G0+1")<br />
ICONV Group (G) 1-340
Related Command<br />
<strong>UniBasic</strong><br />
OCONV Group (G)<br />
1-341 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
ICONV Length (L)<br />
Syntax<br />
ICONV(str.expr, "Ln[,m]")<br />
Description<br />
The ICONV length (L) function extracts a string of a specified length or that falls<br />
within a range of acceptable lengths. If the input value or conversion code is invalid,<br />
UniData returns the input value.<br />
Note: In BASICTYPE P, ICONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
str.expr Indicates a string to be searched.<br />
L Length conversion code.<br />
n Specifies the number of characters the string must match to be extracted.<br />
When m is present, n is the shortest string to be extracted.<br />
m Specifies the longest string to be extracted.<br />
ICONV (L) Conversion Parameters<br />
ICONV Length (L) 1-342
Example<br />
In the following example, the program segment prints “123” and an empty string<br />
because the value of X has fewer than five characters and more than three:<br />
X = 123; Y = 456789<br />
PRINT ICONV(X,"L3,5")<br />
PRINT ICONV(Y,"L3,5")<br />
Related Command<br />
<strong>UniBasic</strong><br />
OCONV Length (L)<br />
1-343 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
ICONV Masked Character (MC)<br />
Syntax<br />
ICONV(expr, "MC [A | /A | B | /B | C | U | L | T | N | /N | P| X[D] | D | D[X] | X]")<br />
Description<br />
The ICONV masked character (MC) function provides many conversion functions<br />
that retrieve and/or convert values in strings and arrays. This function performs the<br />
same conversions and extractions as OCONV Masked Character (MC). UniData<br />
returns the input value if either the value to be converted or the conversion code is<br />
invalid.<br />
Note: In BASICTYPE P, ICONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameters Description<br />
expr The expression to be searched or converted.<br />
A Extracts all alphabetic characters.<br />
/A Extracts all nonalphabetic characters.<br />
B Extracts all alphabetic and numeric characters.<br />
/B Extracts all special characters (not alphabetic nor numeric).<br />
C;x;y Converts all occurrences of substring x to substring y.<br />
U Converts data to uppercase.<br />
L Converts characters to lowercase.<br />
ICONV Masked Character (MC) Parameters<br />
ICONV Masked Character (MC) 1-344
Parameters Description<br />
Example<br />
You can use ICONV to remove special characters in a formatted price. For example,<br />
the following program segment extracts 1234 from $12.34:<br />
1-345 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
T Converts to initial cap style. The first letter of each word is uppercase, and<br />
all other letters are lowercase. Space and tab are word separators.<br />
N Extracts all numeric characters (0–9).<br />
/N Extracts all nonnumeric characters.<br />
P Converts all nonprinting characters to tildes (~).<br />
X[D] or D Assumes input is in decimal; converts to hexadecimal.<br />
D[X] or X Assumes input is in hexadecimal; converts to decimal.<br />
NEW.PRICE = ICONV("$12.34","MCN")<br />
PRINT NEW.PRICE<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
ICONV Masked Character (MC) Parameters (continued)<br />
ALPHA, CONVERT, DOWNCASE, NUM, OCONV Masked Character (MC),<br />
UPCASE
ICONV Masked Decimal (MD)<br />
Syntax<br />
ICONV(num.expr, "MDn [f] [ [ [prefix], [thsnd_mark], [dec_symbl], [suffix] ] ]<br />
[,] [$] [-| < | E | C | D] [P] [Z] [T] [xc]")<br />
Description<br />
The ICONV masked decimal (MD) function converts a decimal number to internal<br />
format after rounding, as specified by f. If the input value or conversion code is<br />
invalid, UniData returns the input value.<br />
Note: In BASICTYPE P, ICONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
The ICONV MD, ML, and MR functions have the same result. They exist separately<br />
to maintain consistency with the OCONV MD, ML, and MR functions, which produce<br />
different results.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
num.expr The decimal number to be converted. num.expr can be any numeric value<br />
with or without a decimal.<br />
n The ICONV function ignores n (for example, if you specify MD32, UniData<br />
ignores the 3), but it is included in the syntax to maintain consistency with<br />
the OCONV Masked Decimal (MD) function.<br />
ICONV Masked Decimal (MD) Parameters<br />
ICONV Masked Decimal (MD) 1-346
Parameter Description<br />
Examples<br />
In the following example, UniData converts the value 12.339 to 1234 by rounding to<br />
two decimal places and converting to internal format:<br />
1-347 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
f Scales the input value num.expr by moving the decimal point f places to the<br />
right. If omitted, f defaults to the value assigned to n (for example, if you<br />
specify MD2, UniData reads it as MD22, and then ignores the first 2).<br />
dec_symbl You can specify a symbol to represent the decimal point in the input number<br />
by including dec_symbl. An example is provided in the following section.<br />
[prefix],<br />
[thsnd_mark],<br />
[suffix]] ] [,]<br />
[$] [-| < | E |<br />
C | D] [P] [Z]<br />
[T] [(xc)]<br />
INTERNAL.VAL = ICONV("12.339","MD2")<br />
The following example demonstrates how to specify that an alternate symbol is used<br />
to represent the decimal point in the input number. This example prints 12350.<br />
PRINT ICONV("123@499","MD2[,,@]")<br />
END<br />
Related Command<br />
<strong>UniBasic</strong><br />
The ICONV function ignores these options, but they are included in the<br />
syntax to maintain consistency with the OCONV Masked Decimal (MD)<br />
function.<br />
ICONV Masked Decimal (MD) Parameters (continued)<br />
OCONV Masked Decimal (MD)
ICONV Left Justify (ML)<br />
Syntax<br />
ICONV(num.expr, "MLn [f] [ [ [prefix], [thsnd_mark], [dec_symbl], [suffix] ] ]<br />
[,] [$] [C] [Z] [(mask)]")<br />
Description<br />
The ICONV left justify (ML) function converts a decimal number to internal format<br />
after rounding, as specified by f. If the input value or conversion code is invalid,<br />
UniData returns the input value.<br />
Note: In BASICTYPE P, ICONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
The ICONV MD, ML, and MR functions have the same result. They exist separately<br />
to maintain consistency with the OCONV MD, ML, and MR functions, which produce<br />
different results.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
num.expr Decimal number to be converted. num.expr can be any numeric value with<br />
or without a decimal.<br />
n The ICONV function ignores n (for example, if you specify ML32,<br />
UniData ignores the 3), but it is included in the syntax to maintain<br />
consistency with the OCONV Left Justify (ML) function.<br />
ICONV Left Justify (ML) Parameters<br />
ICONV Left Justify (ML) 1-348
Parameter Description<br />
Example<br />
In the following example, UniData converts the value 12.339 to 12339 based on the<br />
ML3 conversion code:<br />
1-349 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
f Scales the input value expr by moving the decimal point f places to the right.<br />
If omitted, f defaults to the value assigned to n (for example, if you specify<br />
ML2, UniData reads it as ML22, and then ignores the first 2).<br />
dec_symbl You can specify a symbol to represent the decimal point in the input number<br />
by including dec_symbl. For an example, see the following section.<br />
[prefix],<br />
[thsnd_mark],<br />
[suffix]] ] [,]<br />
[$] [C] [Z]<br />
[(mask)]<br />
INTERNAL.VAL = ICONV("12.339","ML3")<br />
The following example demonstrates how specify an alternate symbol to represent<br />
the decimal point in the input number. This example prints 12350.<br />
PRINT ICONV("123@499","ML2[,,@]")<br />
END<br />
Related Command<br />
<strong>UniBasic</strong><br />
OCONV Left Justify (ML)<br />
The ICONV function ignores these options, but they are included in the<br />
syntax to maintain consistency with the OCONV Left Justify (ML)<br />
function.<br />
ICONV Left Justify (ML) Parameters (continued)
ICONV Packed Decimal (MP)<br />
Syntax<br />
ICONV(expr, "MP")<br />
Description<br />
The ICONV packed decimal (MP) function converts an integer expr into packed<br />
decimal representation by compressing two digits of the integer into one byte.<br />
UniData returns the input value if either the value to be converted or the conversion<br />
code is invalid.<br />
Tip: Use this function to conserve disk space.<br />
In BASICTYPE P, ICONV returns an empty string if UDT.OPTIONS 56 is on and the<br />
input value or conversion code is invalid.<br />
Related Command<br />
<strong>UniBasic</strong><br />
OCONV Packed Decimal (MP)<br />
ICONV Packed Decimal (MP) 1-350
ICONV Packed Decimal (MP1)<br />
Syntax<br />
ICONV(expr, "MP1")<br />
Description<br />
The ICONV packed decimal (MP1) function converts an integer expr in packed<br />
decimal representation into its display format without truncating at the first CHAR(0)<br />
character or altering CHAR(0). If the input value or conversion code is invalid,<br />
UniData returns the input value.<br />
Note: In BASICTYPE P, ICONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Related Command<br />
<strong>UniBasic</strong><br />
OCONV Packed Decimal (MP1)<br />
1-351 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
ICONV Right Justify (MR)<br />
Syntax<br />
ICONV(num.expr, "MRn [f] [ [ [prefix], [thsnd_mark], [dec_symbl], [suffix] ] ] [,]<br />
[$] [C] [Z] [(mask)]")<br />
Description<br />
The ICONV right-justify (MR) function converts a decimal number to internal<br />
format after rounding, as specified by f. If the input value or conversion code is<br />
invalid, UniData returns the input value.<br />
Note: In BASICTYPE P, ICONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
The ICONV MD, ML, and MR functions have the same result. They exist separately<br />
to maintain consistency with the OCONV MD, ML, and MR functions, which produce<br />
different results.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
num.expr Decimal number to be converted. num.expr can be any numeric value with<br />
or without a decimal.<br />
n The ICONV function ignores n (for example, if you specify MR32,<br />
UniData ignores the 3), but it is included in the syntax to maintain consistency<br />
with the OCONV Right Justify (MR) function.<br />
ICONV Right Justify (MR) Parameters<br />
ICONV Right Justify (MR) 1-352
Parameter Description<br />
Example<br />
In the following example, UniData converts the value 12.339 to 1234 based on the<br />
MR2 conversion code:<br />
1-353 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
f Scales the input value expr by moving the decimal point f places to the right.<br />
If omitted, f defaults to the value assigned to n (for example, if you specify<br />
MR2, UniData reads it as MR22, and then ignores the first 2).<br />
dec_symbl You can specify a symbol to represent the decimal point in the input number<br />
by including dec_symbl. An example is provided in the following section.<br />
[prefix],<br />
[thsnd_mark],<br />
[suffix] [,] [$]<br />
[C] [Z]<br />
[(mask)]<br />
INTERNAL.NUM = ICONV("12.339","MR2")<br />
The following example demonstrates how to specify that an alternate symbol is used<br />
to represent the decimal point in the input number. This example prints 12350.<br />
PRINT ICONV("123@499","MR2[,,@]")<br />
END<br />
Related Command<br />
<strong>UniBasic</strong><br />
OCONV Right Justify (MR)<br />
The ICONV function ignores these options, but they are included in the<br />
syntax to maintain consistency with the OCONV Right Justify (MR)<br />
function.<br />
ICONV Right Justify (MR) Parameters (continued)
ICONV Time (MT)<br />
Syntax<br />
ICONV(str.expr, "MT [H] [S] [c]")<br />
Description<br />
The ICONV time (MT) function converts the time of day from display format into<br />
internal format. The value of the internal format is the number of seconds since<br />
midnight (00:00:01 as 1, and 24 as 86400).<br />
Note: In BASICTYPE P, ICONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
str.expr Time input must be in the form HH:MM:SS.<br />
MM and SS are not required and, if you do not specify them, UniData<br />
assumes the values to be zero. You must use a separating character (any<br />
nonnumeric character, such as a colon or comma) between units (for<br />
example, HH, MM, SS). The suffixes AM, PM, A, and P also are accepted<br />
at the end of the string. UniData hours are the same as standard hours, with<br />
12PM as noon (12:00:00) and 12AM as midnight (00:00:00).<br />
A value greater than 24:00:00 (for example, 24:00:01) results in an invalid<br />
conversion.<br />
H S c The remaining options are ignored but are allowed to maintain consistency<br />
with the OCONV Time (MT) function.<br />
ICONV Time (MT) Parameters<br />
ICONV Time (MT) 1-354
Example<br />
The following table describes the time conversion code and the resulting value.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DATE, OCONV Time (MT), TIME, TIMEDATE<br />
1-355 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Value<br />
Code<br />
Specificati<br />
on Result<br />
12:30 MT 45000<br />
12AM MT 0<br />
12PM MT 43200<br />
ICONV Time Examples
ICONV Hex (MX | HEX), Octal (MO), Binary<br />
(MB)<br />
Syntax<br />
ICONV(num.expr, ["HEX | MX [0C] | MO [0C] | MB [0C]"])<br />
Description<br />
The ICONV hex (MX), octal (MO), and binary (MB) functions convert a number<br />
from one of three numbering systems to decimal value. UniData returns the input<br />
value if either the value to be converted or the conversion code is invalid.<br />
Note: In BASICTYPE P, ICONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
num.expr Specifies the decimal value, in display format, to convert to an alternate<br />
numbering system.<br />
HEX |<br />
MX [0C]<br />
Indicates conversion from hexadecimal (base 16). The optional 0C specifier<br />
converts into ASCII character rather than decimal value. HEX is equivalent<br />
to MX0C.<br />
MO [0C] Indicates conversion from octal (base 8). The optional 0C converts to ASCII<br />
character rather than decimal value.<br />
MB [0C] Indicates conversion from binary (base 2). The optional 0C converts to<br />
ASCII character rather than decimal value.<br />
ICONV Numbering System Conversion Parameters<br />
ICONV Hex (MX | HEX), Octal (MO), Binary (MB) 1-356
The following table lists conversion codes to be used with ICONV to convert from<br />
other numbering systems to decimal value or ASCII character.<br />
ICONV conversions into other numbering systems produce multiple characters in the<br />
target numbering system:<br />
1-357 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Hexadecimal – One ASCII character produces two hexadecimal characters.<br />
For example, ASCII character “0” is equal to hexadecimal “30”.<br />
Octal – One ASCII character produces three octal characters. For example,<br />
ASCII character “0” is equal to octal “060”.<br />
Binary – One ASCII character produces eight binary characters. For<br />
example, ASCII character “0” is equal to octal “00110000”.<br />
Examples<br />
From To Function<br />
Binary Decimal value ICONV MB<br />
Binary ASCII character ICONV MB0C<br />
Octal Decimal value ICONV MO<br />
Octal ASCII character ICONV MO0C<br />
Hexadecimal Decimal value ICONV MX<br />
Hexadecimal ASCII character ICONV MX0C<br />
ICONV HEX<br />
ICONV Options for Converting from Alternate Numbering Systems<br />
The following table demonstrates some ICONV MO, MX, and MB conversion codes<br />
and their results.<br />
Input Code Result<br />
123123 MO 42579 (decimal)<br />
123123 (octal) MO0C SS (ASCII characters)<br />
Examples of Numbering System Conversions
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
Input Code Result<br />
100 (hexadecimal) MX 256 (decimal)<br />
101010101010 (binary) MB 170 (decimal)<br />
4B (hexadecimal) MX 75 (ASCII characters)<br />
Examples of Numbering System Conversions (continued)<br />
CHAR; OCONV Hex (MX | HEX), Octal (MO), Binary (MB); SEQ<br />
ICONV Hex (MX | HEX), Octal (MO), Binary (MB) 1-358
ICONV Pattern Match (P)<br />
Syntax<br />
ICONV(str.expr, "P(op)[;(op).....]")<br />
Description<br />
ICONV pattern match (P) function performs the same function as the OCONV<br />
pattern match (P) function. For information, see OCONV Pattern Match (P).<br />
1-359 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
ICONV Range (R)<br />
Syntax<br />
ICONV(num.expr, "Rndm[;ndm.....]")<br />
Description<br />
The ICONV range (R) function returns only those data values that fall within a<br />
specified range of decimal values. When including a negative range, you must<br />
specify the highest negative number first. If range specifications are not met, UniData<br />
returns an empty string. If the input value or conversion code is invalid, UniData<br />
returns the input value.<br />
Note: In BASICTYPE P, ICONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
num.expr Indicates a string to be searched.<br />
n Specifies the smallest number to be extracted.<br />
d Specifies a delimiter separating numbers in a range. Any character except<br />
system delimiters can be used to separate the numbers in a range. However,<br />
the minus sign (-) should not be used as a delimiter because it refers to a<br />
negative number in the range.<br />
m Specifies the longest string to be extracted.<br />
; Separates multiple ranges.<br />
ICONV Range (R) Parameters<br />
ICONV Range (R) 1-360
Example<br />
In the following example, the program segment prints “123” and a blank line because<br />
X is within the range and Y is not:<br />
X = 123; Y = 456789<br />
PRINT ICONV(X,"R100,200")<br />
PRINT ICONV(Y,"R100,200")<br />
Related Command<br />
<strong>UniBasic</strong><br />
OCONV Range (R)<br />
1-361 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
ICONV SOUNDEX (S)<br />
Syntax<br />
ICONV(str.expr, "S")<br />
Description<br />
The ICONV SOUNDEX (S) function converts string or numeric data specified by<br />
str.expr to phonetic format based on SOUNDEX conversion codes. The S conversion<br />
code can be used in an ICONV virtual attribute formula. If the input value or<br />
conversion code is invalid, UniData returns the input value.<br />
For more information about SOUNDEX conversion codes, see the SOUNDEX<br />
command.<br />
Note: In BASICTYPE P, ICONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Example<br />
The following example is virtual attribute, SDX_LNAME, that converts the value of<br />
the variable LNAME to its SOUNDEX expression:<br />
ICONV(LNAME,"S")<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
OCONV SOUNDEX (S), SOUNDEX<br />
ICONV SOUNDEX (S) 1-362
ICONV Text Extraction (T)<br />
Syntax<br />
ICONV(str.expr, "T[m,]n")<br />
Description<br />
The ICONV text extraction (T) function extracts a substring from a string. If the<br />
input value or conversion code is invalid, UniData returns the input value.<br />
Note: In BASICTYPE P, ICONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-363 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
str.expr Indicates a string to be searched.<br />
m Extracts a contiguous string of characters starting from character m.<br />
n Extracts a contiguous string of characters of length n.<br />
ICONV Text Extraction (T) Parameters
Examples<br />
The following table describes some ICONV text extraction codes and their results.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
Input Code Result<br />
QRSTUV “T3” TUV<br />
DAMN THE<br />
TORPEDOES<br />
CONVERSION IS THE<br />
KEY<br />
“T3,5” MN TH<br />
[], FIND, FINDSTR, OCONV Text Extraction (T)<br />
“T1,9” CONVERSIO<br />
457 COLORADO<br />
BLVD<br />
“T4,7” [space]COLORA<br />
ICONV Text Extraction Examples<br />
ICONV Text Extraction (T) 1-364
ICONV File Translation (Tfile)<br />
Syntax<br />
ICONV(rec.id, "T[DICT] [filename;cn;I-Attribute;O-Attribute]")<br />
Description<br />
The ICONV file translation (Tfile) function performs the same action as OCONV<br />
file translation (Tfile). For information, see OCONV File Translation (Tfile).<br />
1-365 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
ICONVS<br />
Syntax<br />
ICONVS(dyn.array.expr, conv.code.expr)<br />
Description<br />
The <strong>UniBasic</strong> ICONVS function converts string or numeric data from display format<br />
to internal format, based on a conversion code, for each element of a dynamic array.<br />
If the input value or conversion code is invalid, UniData returns the input value.<br />
Note: In BASICTYPE P, ICONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Null Value Handling<br />
With null value handling turned on, the presence of the null value in data produces a<br />
result of the null value, and the STATUS function return value is set to 5.<br />
Note: ICONVS conversion codes are the same as ICONV conversion codes. For<br />
information about conversion codes, refer to ICONV.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dyn.array.expr Specifies a dynamic array, each element of which to convert.<br />
conv.code.expr Specifies a code to use in converting each element of the dynamic array.<br />
ICONVS Parameters<br />
ICONVS 1-366
STATUS Function Return Values<br />
After you execute ICONVS, the STATUS function returns one of the values<br />
described in the following table.<br />
Example<br />
In the following example, the program segment converts each element of ARR1 to<br />
internal format:<br />
1-367 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ARR1 = "$12.34":@VM:5678:@VM:9876<br />
ARR2 = ICONVS(ARR1,"MR2")<br />
PRINT ARR2<br />
END<br />
This program segment prints the following converted array elements:<br />
1234 567800 987600<br />
Note: The blanks in the number are value marks, which are nonprinting characters.<br />
The value marks could display as some other character on your terminal screen.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
ICONV, OCONVS<br />
Value Description<br />
0 Successful conversion.<br />
1 Invalid input data.<br />
2 Invalid conversion specification.<br />
3 Invalid date for “D” conversion code only.<br />
5 Null value if null value handling is turned on.<br />
STATUS Function Return Values
IF/THEN/ELSE<br />
Syntax<br />
IF expr THEN statements [ELSE statements]<br />
IF expr THEN<br />
statements...<br />
END [ELSE<br />
statements...<br />
END]<br />
IF expr ELSE statements<br />
IF expr ELSE<br />
statements<br />
END<br />
Description<br />
The <strong>UniBasic</strong> IF/THEN/ELSE command executes one of two blocks of statements<br />
based on a conditional expression. If expr is true, UniData executes the first group of<br />
statements. If expr is false, UniData executes the second group of statements.<br />
Points to Remember when Writing IF/THEN/ELSE<br />
Statements<br />
The ELSE clause is optional.<br />
An IF/THEN/ELSE structure can occupy either a single line or several lines. When<br />
coding single- line and multiline statements:<br />
The single-line form does not require an END before the ELSE.<br />
In the multiline form, each clause must contain at least one statement. If you<br />
do not want to take any action, use the NULL command. THEN and ELSE<br />
clauses must be delimited by END.<br />
IF/THEN/ELSE 1-368
1-369 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
A single-line statement that includes the INPUT command as a part of the<br />
THEN clause might not produce the results you expect. For example, the<br />
following statements produce no output:<br />
IF X = 1 THEN INPUT TEST ELSE PRINT "X NE 1"<br />
To correct this problem, enter each clause of the statement on a separate line,<br />
or use the IN() function to obtain input from theterminal or input queue.<br />
With null value handling turned on, a test on expr that is the null value returns false.<br />
For an overview of how the null value affects <strong>UniBasic</strong>, see Developing <strong>UniBasic</strong><br />
Applications.<br />
Tip: You can nest IF/THEN/ELSE statements, but a CASE statement might be more<br />
efficient.<br />
Examples<br />
In the following example, the program statement tests if the variable SUPPLY is less<br />
than the variable DEMAND. If the comparison is true, program control is transferred<br />
to the statement labeled REORDER.<br />
IF SUPPLY < DEMAND THEN GOSUB REORDER<br />
In the next example, the program segment compares INCOME to TARGET. UniData<br />
executes the first branch if the comparison is true, or executes the second group of<br />
statements if the comparison is false.<br />
IF INCOME < TARGET THEN<br />
PRINT "Income less than target figure."<br />
END ELSE<br />
PRINT "Income equal to or greater than target!"<br />
END<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CASE, LOOP/REPEAT, NULL
IN<br />
Syntax<br />
IN( )<br />
Description<br />
The <strong>UniBasic</strong> IN function captures raw data from an input queue or from a terminal.<br />
Tip: IN can capture function, arrow, and other special keys from the keyboard.<br />
Example<br />
In the following example, the program segment assigns the value y to ANSWER:<br />
DATA y<br />
ANSWER = IN()<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DATA, INPUT, INPUT @, INPUTTRAP, SYSTEM<br />
IN 1-370
INDEX<br />
Syntax<br />
INDEX(str.expr1,str.expr2,num.expr)<br />
Description<br />
The <strong>UniBasic</strong> INDEX function returns the starting position of the num.expr occurrence<br />
of str.expr2 within str.expr1. INDEX supports multibyte languages.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Examples<br />
In the following example, the program segment searches STR.VAR for the second<br />
occurrence of the letter t and returns that location in the variable LOC. In this<br />
example, it returns a value of 8.<br />
1-371 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
str.expr1 Specifies the string to search.<br />
str.expr2 Specifies the string for which to search in str.expr1.<br />
num.expr Specifies which occurrence of str.expr2 to return.<br />
INDEX Parameters<br />
STR.VAR = "It was the best of times"<br />
LOC = INDEX(STR.VAR,"t",2)<br />
In the next example, the INDEX function operates like the COL() functions used in<br />
conjunction with the FIELD function. It returns the beginning position of the string<br />
212 within the string variable STR. The result stored in the variable NY.STR is 15.<br />
STR = "303-433-3199, 212-999-1212"<br />
NY.STR = INDEX(STR,"212",1)
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
COL1, COL2, FIELD<br />
INDEX 1-372
INDICES<br />
Syntax<br />
INDICES(file.var[, index.name.expr])<br />
Description<br />
The <strong>UniBasic</strong> INDICES function returns one of the following:<br />
1-373 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Names of alternate key indexes.<br />
Information about a particular alternate key index.<br />
Retrieving Names of Alternate Key Indexes<br />
If you specify only file.var, the INDICES function returns a dynamic array containing<br />
the alternate key index names for all indexes in the file you specify. The index names<br />
are not returned in any particular order. Index names are separated by attribute marks.<br />
Note: If the index you specify does not exist, the function returns an empty string.<br />
Retrieving Information About Indexes<br />
If you specify the name of an alternate key index (indexname.expr), the INDICES<br />
function returns information about that index in a dynamic array, which consists of<br />
six attributes:<br />
Attribute 1 – Four values representing the following information in this<br />
order:<br />
Type of key (I or D).<br />
Build required (1 or “ ”).<br />
No meaning.<br />
Automatic update enabled (1 or “ ”).<br />
Attribute 2 – Location of the alternate key in the record.<br />
Attribute 3 – An ASCII string with the time stamp of the last time the index<br />
was built (updated by BUILD.INDEX).
Attributes 4 and 5 – Empty.<br />
Attribute 6 – Type of attribute:<br />
S for singlevalued.<br />
M for multivalued.<br />
MS for multi-subvalued.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
file.var Specifies the file about which to return index information.<br />
, index.name.expr Specifies an alternate key index about which to return<br />
information.<br />
INDICES Parameters<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
SELECTINDEX, SETINDEX<br />
UniData<br />
BUILD.INDEX, CREATE.INDEX – For information, see the UniData <strong>Commands</strong><br />
<strong>Reference</strong>.<br />
INDICES 1-374
initSecureServerSocket function<br />
Syntax<br />
initSecureServerSocket(name_or_IP, port, backlog, svr_socket, context)<br />
Description<br />
Use the initSecureServerSocket() function to create a secured connection-oriented<br />
stream server socket. It does exactly the same as the initServerSocket() function<br />
except that the connection will be secure.<br />
Once the server socket is opened, any change in the associated security context will<br />
not affect the opened socket.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-375 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
name_or_IP DNS name (x.com) or IP address of a server or empty. Empty is<br />
equivalent to INADDR_ANY which means the system will<br />
choose one for you. Generally,<br />
this parameter should be left empty.<br />
port Port number. If the port number is specified as a value
The following table describes the status of each return code.<br />
Return Code Status<br />
0 Success.<br />
1 - 41 See Socket Function Error Return Codes.<br />
101 Invalid security context handle.<br />
Return Code Status<br />
initSecureServerSocket function 1-376
initServerSocket<br />
Syntax<br />
initServerSocket(name_or_IP, port, backlog, svr_socket)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Use the initServerSocket function to create a connection-oriented (stream) socket.<br />
Associate this socket with an address (name_or_IP) and port number (port), and<br />
specify the maximum length the queue of pending connections may grow to.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-377 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
name_or_IP DNS name (x.com) or IP address of a server or empty. Empty is equivalent<br />
to INADDR_ANY which means the system will choose one for<br />
you. Generally, this parameter should be left empty.<br />
port Port number. If the port number is specified as a value
The following table describes the status of each return code.<br />
Return Code Status<br />
0 Success.<br />
Non-zero See Socket Function Error Return Codes.<br />
initServerSocket Return Codes<br />
initServerSocket 1-378
INMAT<br />
Syntax<br />
INMAT( )<br />
INMAT(array.name)<br />
Description<br />
The <strong>UniBasic</strong> INMAT function, in the first form, returns the number of elements<br />
(rows) in a dimensioned array. The second form returns the current dimension of the<br />
dimensioned array array.name. If the dimensioned array has two dimensions, the<br />
bounds are separated by value marks.<br />
After you open a file, the value of INMAT contains the number of modulos that make<br />
up the file. Subsequent file operations using dimensioned array commands also set<br />
the value returned by INMAT.<br />
INMAT Function Return Values<br />
INMAT is set by the dimensioned array-oriented commands, as shown in the<br />
following table.<br />
Command Meaning<br />
1-379 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
DIM 0 – The array was created.<br />
1 – Not enough memory was available to create the array.<br />
INMAT Function Return Values
Command Meaning<br />
MATREAD<br />
MATREADL<br />
MATREADU<br />
MATPARSE<br />
Examples<br />
In the following example, the program segment fills the array MAIN.MAT with<br />
values from REC. If a sufficient number of elements are available in the target array,<br />
the value of INMAT is set to the number of elements filled. If the number of values<br />
exceeds the number of elements in the target array, excess data is lumped in the 0<br />
position, and the value of INMAT is set to 0.<br />
MATPARSE MAIN.MAT FROM REC, @VM<br />
PRINT INMAT()<br />
In the next example, the program segment dimensions two arrays and then prints the<br />
dimensions using the PRINT statement and INMAT function:<br />
DIM LARGE.ARRAY(23,14)<br />
DIM SMALL.ARRAY(9)<br />
PRINT INMAT(LARGE.ARRAY)<br />
PRINT INMAT(SMALL.ARRAY)<br />
This results in the following:<br />
23}14<br />
9<br />
n – The number of attributes loaded into the array.<br />
0 – More attributes existed in the record than elements existed in the array.<br />
Excess data is stored in the 0,0 element.<br />
OPEN n – The number of modulos in the file.<br />
0 – The file opened is a directory (DIR type).<br />
OSBWRITE n – The number of bytes written to a file or named pipe.<br />
INMAT Function Return Values (continued)<br />
INMAT 1-380
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DIM, MAT, MATBUILD, MATPARSE, MATREAD, MATREADL, MATREADU,<br />
MATWRITE, MATWRITEU<br />
1-381 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
INPUT<br />
Syntax<br />
INPUT var [,length [ _ ]] [:] [{FOR | WAITING} time.expr] [UNFILTERED]<br />
[THEN statements | ELSE statements]<br />
INPUT var [,-l] [{FOR | WAITING} time.expr] [UNFILTERED] [THEN<br />
statements | ELSE statements]<br />
Description<br />
The <strong>UniBasic</strong> INPUT command requests data from an input queue or from the<br />
terminal screen. INPUT supports multibyte languages.<br />
If INPUT is successful, UniData sets @SYSTEM.RETURN.CODE to 0. If unsuccessful<br />
(the INPUT statement with a FOR or WAITING clause timed out), UniData<br />
sets @SYSTEM.RETURN.CODE to -1.<br />
One variable is read by each INPUT statement. If you press ENTER in response to<br />
an INPUT statement, an empty string is assigned to the variable.<br />
Tip: Precede INPUT with a PRINT statement to display a prompt.<br />
UDT.OPTIONS 83 enables the escape character (usually ASCII code 27) to be<br />
accepted by INPUT while screening out or converting other control characters.<br />
THEN | ELSE is associated with the WAITING clause except in the case described<br />
in the following warning note.<br />
INPUT 1-382
Warning: Processing differs when you include INPUT within a single-line<br />
IF/THEN/ELSE statement, which is illustrated by the following program segment:<br />
RESP = 5<br />
IF RESP = 10 THEN INPUT TEST ELSE PRINT "NO INPUT"<br />
END<br />
This program produces no output because UniData interprets the ELSE as being a<br />
part of the INPUT statement, even though no WAITING clause is included. To avoid<br />
this, place the INPUT statement on its own line, as shown in the following example:<br />
RESP = 5<br />
IF RESP = 10 THEN<br />
INPUT TEST<br />
END ELSE<br />
PRINT "NO INPUT"<br />
END<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-383 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
var Specifies a variable to receive the input. In the first form, if data<br />
(received by a DATA statement) is present in an input queue, INPUT<br />
assigns the next value to the variable var. If a DATA statement was not<br />
executed, INPUT prompts the user for input by displaying a question<br />
mark on the terminal.<br />
,length Specifies the maximum number of characters accepted.<br />
_ UniData waits for the user to press ENTER before processing data input<br />
at the keyboard. If the underscore is not included, UniData stops<br />
accepting input when the user enters the maximum number of characters.<br />
Use the underscore parameter to allow the user to backspace after<br />
entering the maximum number of characters. For example, if you specify<br />
“INPUT X,5_”, the user can backspace to modify the entry after entering<br />
five characters.<br />
INPUT Parameters
Parameter Description<br />
: Normally, when a user types something and presses ENTER in response<br />
to an INPUT statement, UniData issues a line feed. The : parameter<br />
inhibits this line feed.<br />
,-l UniData checks the type-ahead buffer. The following values are returned<br />
in var:<br />
1 – Data is present in the buffer.<br />
0 – No data is present in the type-ahead buffer.<br />
Use the -1 parameter to periodically check for input in an application that<br />
runs continuously.<br />
FOR |<br />
WAITING<br />
time.expr<br />
Examples<br />
In the following example, the program segment reads the first value established by<br />
the DATA statement and assigns it to the variable TEST. In this case, the value 10 is<br />
read.<br />
DATA 10,20,30,40,50<br />
INPUT TEST<br />
Specifies the length of time to wait for input. If you do not enter the input<br />
before the wait period expires, var does not change, and the ELSE clause<br />
executes. If no ELSE nor THEN clause exists, the session terminates at<br />
the end of the wait period.<br />
UNFILTERED Sets INPUT to capture raw characters (such as backspace, up arrow,<br />
down arrow, or ENTER) from the keyboard.<br />
THEN<br />
statements<br />
ELSE<br />
statements<br />
Specifies statements to execute when input is received within the time<br />
specified in the FOR | WAITING clause and input is not an empty string.<br />
Specifies statements to execute if no input is received by the time<br />
specified in the FOR | WAITING clause or if the input is an empty string.<br />
INPUT Parameters (continued)<br />
In the next example, the program statement prints the prompt “Enter name:”. The<br />
INPUT statement then enables the user to enter any number of characters, stopping<br />
only when the user presses ENTER. The first 10 characters the user enters are<br />
assigned to the variable NAME.<br />
PRINT "Enter name: "; INPUT NAME,10_<br />
INPUT 1-384
In the next example, the INPUT statement with the -1 parameter checks the typeahead<br />
buffer. If S.FLAG is 0, the buffer is empty. If it is 1, the buffer contains data.<br />
In the latter case, UniData prints the current value of RECS.PROCESSED.<br />
1-385 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
INPUT S.FLAG,-1<br />
IF S.FLAG THEN PRINT RECS.PROCESSED<br />
In the next example, the user has 30 seconds to input data. Otherwise, the program<br />
prints “No input within 30 seconds”.<br />
INPUT ANSWER FOR 30<br />
ELSE PRINT "No input within 30 seconds"<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLEARINPUT, DATA, IN, INPUT @, INPUTERR, INPUTIF, INPUTNULL,<br />
INPUTTRAP, PROMPT, SYSTEM
INPUT @<br />
Syntax<br />
INPUT @ (col,row | option) [ , | : ] var [,length] [ _ ] [mask] [{FOR | WAITING}<br />
time.expr] [UNFILTERED] [THEN statements | ELSE statements]<br />
Description<br />
The <strong>UniBasic</strong> INPUT @ command places the cursor at a specific location on the<br />
terminal screen and prompts the user for input. INPUT @ supports multibyte<br />
languages.<br />
Tip: The <strong>UniBasic</strong> @ function also positions the cursor on the terminal screen, but<br />
does not accept input as does INPUT @.<br />
If INPUT @ is successful, UniData sets @SYSTEM.RETURN.CODE to 0. If unsuccessful<br />
(the INPUT @ statement with a FOR or WAITING clause timed out),<br />
UniData sets @SYSTEM.RETURN.CODE to -1.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
col,row Specifies the column and row on the screen at which the cursor is to<br />
be placed for input.<br />
: Normally, when you type a value and press ENTER in response to an<br />
INPUT statement, UniData issues a line feed. The : parameter inhibits<br />
this line feed.<br />
var Specifies a variable to receive the input data.<br />
,length Specifies the maximum number of characters accepted.<br />
INPUT @ Parameters<br />
INPUT @ 1-386
Parameter Description<br />
1-387 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
_ UniData waits for you to press ENTER before processing data input at<br />
the keyboard. If you do not use the underscore parameter, UniData<br />
stops accepting input when you exceed the maximum number of<br />
characters.<br />
Use the underscore parameter you want the capability of backspacing<br />
after entering the maximum number of characters. For example, if you<br />
specify “INPUT X,5_”, you can backspace to modify the entry after<br />
entering five characters.<br />
mask Specifies a format or conversion mask. For format options and instructions<br />
about building a conversion mask, see OCONV Masked Decimal<br />
(MD).<br />
FOR | WAITING<br />
time.expr<br />
Specifies the amount of time to wait for input. If the input is not<br />
entered when this period expires, var does not change, and the ELSE<br />
clause executes. If no ELSE nor THEN clause exists, the session<br />
terminates at the end of the wait time.<br />
UNFILTERED Sets INPUT @ to capture raw characters (such as backspace, up arrow,<br />
down arrow, or RETURN) from the keyboard.<br />
THEN<br />
statements |<br />
ELSE statements<br />
If the ECL TIMEOUT command has been executed:<br />
THEN executes if the input variable contains at least one character.<br />
ELSE executes if the input variable contains an empty string. If no<br />
ELSE clause is coded, UniData logs you out and displays the ECL<br />
prompt.<br />
If the ECL TIMEOUT command has not been executed, the program<br />
waits indefinitely for input.<br />
INPUT @ Parameters (continued)
Examples<br />
The following example is taken from the sample program in Appendix A, “Sample<br />
Program,” in Developing <strong>UniBasic</strong> Applications. Notice that the DISPLAY<br />
command is combined with the <strong>UniBasic</strong> @ function to clear the screen and display<br />
messages. Then INPUT @ accepts the user’s response (a corrected price).<br />
ALTER_RECORD:<br />
* Create a new screen, and allow PRICE and ADDRESS to be changed.<br />
* Initialize variables and draw the screen<br />
NEED.TO.WRITE = 0<br />
DISPLAY @(-1):@(15,5):"Alter ORDER":<br />
DISPLAY @(10,8):"(Press RETURN to leave un-changed)"<br />
DISPLAY @(8,9):"Old Price":@(42,9):"New Price (Enter 2 decimal<br />
places)"<br />
* Change the PRICE field (if desired)<br />
FOR ENTRY = 1 TO NUM_ENTRIES<br />
NEW.PRICE = ""<br />
DISPLAY @(10,9+ENTRY):OCONV(ORDER.REC,"MR2$,"):<br />
INPUT @(45,9+ENTRY):NEW.PRICE<br />
Later in the same sample program, the @ function is again combined with DISPLAY<br />
to paint the screen with prompts. After all prompts have been displayed, INPUT @<br />
returns the cursor to the end of the first line, accepting input on that line before<br />
moving to the end of the next. In this manner, it accepts input at the end of each line<br />
in turn.<br />
* Display the current ADDRESS information<br />
DISPLAY @(21,12):"Change Address to: ":<br />
DISPLAY @(21,13):"Street Line1: ":@(40,13):ADDRESS<br />
DISPLAY @(21,14):"Street Line2:"<br />
DISPLAY<br />
@(40,14):ADDRESS:@(21,15):"City:":@(40,15):CLIENT.REC<br />
DISPLAY @(21,16):"State:":<br />
DISPLAY<br />
@(40,16):CLIENT.REC:@(21,17):"Zip:":@(40,17):CLIENT.REC<br />
* Accept INPUT to change values of address<br />
INPUT @(40,13):STREET1<br />
IF STREET1 = '' THEN STREET1 = CLIENT.REC<br />
INPUT @(40,14):STREET2<br />
IF STREET2 = '' THEN STREET2 = CLIENT.REC<br />
INPUT @(40,15):CITY<br />
IF CITY = '' THEN CITY = CLIENT.REC<br />
INPUT @(40,16):STATE<br />
IF STATE = '' THEN STATE = CLIENT.REC<br />
INPUT @(40,17):ZIP<br />
IF ZIP = '' THEN ZIP = CLIENT.REC<br />
INPUT @ 1-388
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLEARINPUT, DATA, IN, INPUT, INPUTERR, INPUTIF, INPUTNULL,<br />
INPUTTRAP, PROMPT, SYSTEM<br />
UniData<br />
TIMEOUT – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
1-389 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
INPUTCLEAR<br />
INPUTCLEAR is a synonym for the CLEARINPUT command. For more information,<br />
see CLEARINPUT.<br />
Synonym<br />
CLEARINPUT<br />
INPUTCLEAR 1-390
INPUTERR<br />
Syntax<br />
INPUTERR error.expr<br />
Description<br />
The <strong>UniBasic</strong> INPUTERR command displays an error message at the bottom line of<br />
the terminal screen. error.expr can be any valid <strong>UniBasic</strong> statement, including a<br />
literal string enclosed in quotation marks.<br />
Tip: Use INPUTERR to prompt for errors when soliciting data with an INPUT<br />
statement.<br />
The next INPUT command erases previous error messages printed on the bottom line<br />
of the screen. The <strong>UniBasic</strong> program must control the movement of the cursor so it<br />
does not enter the bottom line.<br />
Note: INPUTERR sends output to the screen regardless of PRINTER on/off status.<br />
Example<br />
In the following example, the program segment prints an error message at the bottom<br />
of the screen if the input does not match the pattern mask:<br />
1-391 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
PRINT @(-1)<br />
PRINT @(5,5):'Hourly Wage'<br />
LOOP<br />
PRINT @(16,5)<br />
INPUT HOURLY.WAGE<br />
UNTIL HOURLY.WAGE MATCHES '1NON.2N'<br />
INPUTERR 'Hourly wage must be entered as x.xx'<br />
REPEAT<br />
PRINT @(5,7):'Accepted.'<br />
END
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
INPUT, INPUT @<br />
INPUTERR 1-392
INPUTIF<br />
Syntax<br />
INPUTIF var [THEN statements] [ELSE statements]<br />
Description<br />
The <strong>UniBasic</strong> INPUTIF command retrieves input from the type-ahead buffer and<br />
assigns the input to a variable.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLEARINPUT, INPUT, INPUT @, PROMPT, SYSTEM<br />
1-393 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
var Specifies the target variable for input data.<br />
THEN statements Executes statements if data is available in the type-ahead buffer.<br />
ELSE statements Executes statements if data is not available in the type-ahead<br />
buffer.<br />
INPUTIF Parameters
INPUTNULL<br />
Syntax<br />
INPUTNULL 'expr'<br />
Description<br />
The <strong>UniBasic</strong> INPUTNULL command enables you to change the default<br />
INPUTNULL character from the default, underscore, to any other single character.<br />
When you enter the INPUTNULL character in response to an INPUT or INPUT @<br />
prompt, UniData stores an empty string in place of the character entered. expr<br />
specifies the character to serve as the INPUTNULL character for this session.<br />
Note: You must enclose expr in quotation marks.<br />
Example<br />
In the following example, the pound sign (#) is set as the new INPUTNULL<br />
character:<br />
PROMPT ""<br />
INPUTNULL "#"<br />
PRINT @(-1):@(0,10):"Enter a character: "<br />
INPUT @(20,10):inpt<br />
PRINT "Input is ":inpt<br />
PRINT "SEQ = ":SEQ(inpt)<br />
PRINT "LEN = ":LEN(inpt)<br />
The preceding program segment results in the following output when user input is an<br />
underscore character:<br />
Enter a character: _<br />
Input is _<br />
SEQ = 95<br />
LEN = 1<br />
INPUTNULL 1-394
INPUTTRAP<br />
Syntax<br />
INPUTTRAP string.expr GOSUB label [:] [,label [:]]<br />
INPUTTRAP string.expr GOTO label [:] [,label [:]]<br />
Description<br />
The <strong>UniBasic</strong> INPUTTRAP command sets a trap for a particular character or<br />
characters in a program. INPUTTRAP enables you to specify characters which, if<br />
entered at an INPUT or INPUT @ statement, will branch to another statement label.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-395 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
string.expr Specifies the user input upon which to branch to another statement label. To<br />
set a trap for both uppercase and lowercase characters, use the following<br />
pattern INPUTTRAP ‘Xx’, as in the following: INPUTTRAP ‘Aa’ GOSUB<br />
10,10.<br />
GOSUB<br />
GOTO<br />
These keywords direct program execution to execute or branch to a specified<br />
label in the program.<br />
GOSUB ensures that program execution returns to the statement below the<br />
subroutine call.<br />
GOTO is a branch only, and does not return processing to the calling routine.<br />
These keywords operate just like the commands of the same names. For<br />
more information about the GOTO and GOSUB commands, see their entries<br />
in this manual.<br />
label Specifies the label to which to branch.<br />
INPUTTRP Parameters
Example<br />
In the following example, the program statement performs a GOSUB to label ASUB<br />
if the user enters H or to label BSUB if the user enters B:<br />
INPUTTRAP 'HB' GOSUB ASUB,BSUB<br />
INPUT@ (10,10) VALUE<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
IN, INPUT, INPUT @, INPUTERR<br />
INPUTTRAP 1-396
INS<br />
Syntax<br />
INS expr BEFORE dyn.array<br />
Description<br />
The <strong>UniBasic</strong> INS command inserts an expression with the appropriate delimiter<br />
before the specified attribute, value, or subvalue mark in a dynamic array.<br />
Note: UniData does not insert a delimiter at the end of the array.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Examples<br />
In the following example, the program segment inserts Zelda, with a new attribute<br />
mark, before the second attribute:<br />
1-397 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
expr Specifies an expression to insert.<br />
dyn.array<br />
<br />
ARRAY = "H.L. Mencken":@AM:"John":@AM:"Mary"<br />
INS "Zelda" BEFORE ARRAY<br />
This results in:<br />
Specifies a dynamic array and attribute, value, and subvalue at which to<br />
insert the expression. If any one of these expressions is -1, UniData inserts<br />
the expr as the last element in the array position.<br />
INS Parameters<br />
ARRAY = "H.L. Mencken":@AM:"Zelda":@AM:"John":@AM:"Mary"
In the next example, the program segment inserts Stephen at the end of the array<br />
because val.expr is -1:<br />
ARRAY = "Carmen":@AM:"Sally":@AM:"Billy":@AM:"Mark"<br />
INS "Stephen" BEFORE ARRAY<br />
This results in:<br />
ARRAY="Carmen":@AM:"Sally":@AM:"Billy":@AM:"Mark":@AM:"Ste<br />
phen"<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
FIELDSTORE, INSERT<br />
INS 1-398
INSERT<br />
Syntax<br />
INSERT(dyn.array.expr,attrib.expr,val.expr, subval.expr, insert.expr)<br />
Description<br />
The <strong>UniBasic</strong> INSERT function inserts an expression (with its delimiter) before or<br />
after the specified attribute, value, or subvalue mark in a dynamic array.<br />
There is no short form for the INSERT function. However, you can append data by<br />
using the short version of the REPLACE function.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dyn.array.expr,<br />
attrib.expr,<br />
val.expr,<br />
subval.expr,<br />
Elements in dyn.array.expr,attrib.expr,val.expr, and subval.expr can be any of the<br />
following three types.<br />
1-399 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Specifies a dynamic array and attribute, value, and subvalue of that<br />
dynamic array at which to insert the expression. For more information<br />
about the type of insertions available, see the following table.<br />
insert.expr Specifies the string to insert.<br />
INSERT Parameters<br />
If the element is: then insert expr:<br />
a positive number after delimiter, before data.<br />
-1 (attrib.expr,val.expr, subval.expr) after the position indicated.<br />
0 (val.expr, subval.expr) at the next higher level.<br />
Determining Insertion Points
Examples<br />
In the following example, the program statement inserts HARRY at the end of the<br />
values in attribute 2:<br />
STR = INSERT(STR,2,-1,0,'HARRY')<br />
In the next example, the program statement inserts HARRY in the first value of<br />
attribute 2:<br />
STR = INSERT(STR,2,1,0,'HARRY')<br />
In the next example, the program statement inserts HARRY in the first subvalue of<br />
the first value of attribute 2:<br />
STR = INSERT(STR,2,1,1,'HARRY')<br />
In the next example, the program segment specifies Alias in the second attribute<br />
position:<br />
ARRAY = "#111":@AM:"Jones":@AM:"Smith"<br />
ARRAY2 = INSERT(ARRAY,2,0,0,"Alias")<br />
When you execute this program segment, UniData inserts Alias in the second<br />
attribute position:<br />
ARRAY2 = "#111":@AM:"Alias":@AM:"Jones":@AM:"Smith"<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DEL, FIELDSTORE, INS, REMOVE, REPLACE, SUBSTRINGS<br />
INSERT 1-400
INT<br />
Syntax<br />
INT(num.expr)<br />
Description<br />
The <strong>UniBasic</strong> INT function returns the integer value of numeric expression<br />
num.expr.<br />
Note: This function does not round num.expr, but truncates decimals.<br />
Example<br />
In the following example, the program segment prints 1, which is the integer part of<br />
the number 1.734:<br />
A = 1.734<br />
PRINT INT(A)<br />
1-401 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
ISMB<br />
Syntax<br />
ISMB()<br />
Description<br />
The <strong>UniBasic</strong> ISMB function returns a code indicating whether the currently<br />
installed language is made up of a single-byte or multibyte character set.<br />
This function returns 0 to indicate a single-byte character set, or 1 for a multibyte<br />
character set. For example, if you execute the ISMB function in a UniData session<br />
for which the language is English, the function returns 0. If you execute this function<br />
in a UniData session for which the language is Japanese, the function returns 1.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
BYTELEN, CHARLEN, DISPLAYWIDTH, LEN, MBLEN<br />
ISMB 1-402
ISNV<br />
Syntax<br />
ISNV(expr)<br />
Description<br />
The <strong>UniBasic</strong> ISNV function tests an expression for the null value. If expr is the null<br />
value, this function returns a code of 1. If the expression is not null, or if it contains<br />
a null value as well as other characters, this function returns a code of 0.<br />
Note: The udtconfig parameter NULL_FLAG must be on for a program that contains<br />
ISNV to compile. With this flag on, the null value represents an unknown value (represented<br />
by @NULL in <strong>UniBasic</strong> programs), as opposed to an empty string<br />
(represented as “”). IBM recommends that you use @ variables to represent UniData<br />
delimiters and the null value because the ASCII value used to represent these<br />
characters can vary with language group.<br />
Examples<br />
The following program example demonstrates testing for the null value in a variable:<br />
1-403 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
A=@NULL<br />
IF ISNV(A) THEN PRINT "A is the null value."<br />
This program results in the following output:<br />
A is the null value.<br />
The following program uses the function ISNV to determine if a string consists of the<br />
null value:<br />
PRINT "1.a ISNV(@NULL) = ":ISNV(@NULL)<br />
PRINT "2.a NOT(ISNV(@NULL)) = ":NOT(ISNV(@NULL))<br />
A = "abc":@NULL:"def"<br />
PRINT "1.b ISNV('abc':@NULL:'def') = ":ISNV(A)<br />
PRINT "2.b NOT(ISNV('abc':@NULL:'def')) = ":NOT(ISNV(A))
This program produces the following results. Notice that ISNV executed on a string<br />
containing the null value and other characters produces a negative result (0).<br />
1.a ISNV(@NULL) = 1<br />
2.a NOT(ISNV(@NULL)) = 0<br />
1.b ISNV('abc':@NULL:'def') = 0<br />
2.b NOT(ISNV('abc':@NULL:'def')) = 1<br />
Related Command<br />
<strong>UniBasic</strong><br />
ISNVS<br />
ISNV 1-404
ISNVS<br />
Syntax<br />
ISNVS(dynamic.array)<br />
Description<br />
The <strong>UniBasic</strong> ISNVS function tests dynamic array elements to see if any of them is<br />
the null value. This function is meaningful only when null value handling is on. It<br />
returns an array with 0 or 1 in each element. If the array element is the null value, this<br />
function returns a code of 1. If the element is not null, or if it contains the null value<br />
as well as other characters, this function returns a code of 0.<br />
Note: The udtconfig parameter NULL_FLAG must be on for a program that contains<br />
ISNVS to compile. With this flag on, the null value represents an unknown value<br />
(represented BY @NULL in <strong>UniBasic</strong> programs), as opposed to an empty string<br />
(represented as “”). IBM recommends that you use @ variables to represent UniData<br />
delimiters and the null value because the ASCII value used to represent these<br />
characters can vary with language group.<br />
Example<br />
1-405 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
The following program demonstrates the ISNVS function by printing<br />
the return values stored in array D:<br />
B=@FM:"stereo":@FM:@NULL:@FM:"234":@FM<br />
D=ISNVS(B)<br />
STG=B<br />
GOSUB PRINT.SETUP<br />
PRINT "Dynamic array = "<br />
PRINT PRT.STG<br />
FOR X = 1 TO 4<br />
PRINT "D = ":D<br />
NEXT X<br />
PRINT.SETUP:<br />
PRT.STG = CHANGE(STG, @NULL, "@NULL")<br />
PRT.STG = CHANGE(PRT.STG, @FM, "@FM")<br />
PRT.STG = CHANGE(PRT.STG, @AM, "@AM")<br />
PRT.STG = CHANGE(PRT.STG, @VM, "@VM")<br />
RETURN
This program results in the following output:<br />
Dynamic array =<br />
@FMstereo@FM@NULL@FM234@FM<br />
D = 0<br />
D = 0<br />
D = 1<br />
D = 0<br />
Related Command<br />
<strong>UniBasic</strong><br />
ISNV<br />
ISNVS 1-406
ITYPE<br />
Syntax<br />
ITYPE(itype.expr)<br />
Description<br />
The <strong>UniBasic</strong> ITYPE function enables a <strong>UniBasic</strong> program to execute a UniData<br />
virtual attribute from the dictionary of a UniData file. The value of the function is the<br />
same as if it were run using UniQuery or UniData SQL.<br />
Note: ITYPE generally requires you to open both the dictionary and data portions of<br />
the file. Before you use this function, you must compile the dictionary of the file by<br />
using the ECL COMPILE.DICT or CD command.<br />
In most cases, you also must assign the @ID and @RECORD variables. These<br />
variables resolve the value of the ITYPE function. However, if neither the ID of the<br />
file nor the data from the record is used in the ITYPE, you do not need to assign these<br />
variables.<br />
Note: Conversion or formatting codes in the dictionary record of the virtual attribute<br />
does not affect the value ITYPE returns.<br />
Examples<br />
The following virtual attribute exists in the dictionary file of the demonstration<br />
database file ORDERS:<br />
YV<br />
PRICE*QTY; SUM(SUM(@1))<br />
MD2,$<br />
Grand Total<br />
14R<br />
S<br />
1-407 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
The following program segment opens both the ORDERS file and the dictionary of<br />
the ORDERS file, then reads the compiled virtual attribute into the program variable<br />
GRAND_TOTAL. After prompting for an order number and reading the record, the<br />
virtual attribute is evaluated with the ITYPE function. In this case, it performs a<br />
summation on the value of GRAND_TOTAL in @RECORD. ITYPE does not<br />
invoke the conversion and format functions in the dictionary item.<br />
OPEN 'ORDERS' TO ORDERS.FILE ELSE STOP<br />
OPEN 'DICT','ORDERS' TO DICT.ORDER ELSE STOP<br />
READ GRAND_TOTAL FROM DICT.ORDER,'GRAND_TOTAL' ELSE<br />
PRINT 'DICTIONARY ITEM GRAND_TOTAL NOT FOUND'<br />
STOP<br />
END<br />
LOOP<br />
PRINT 'Enter order number ':<br />
INPUT ORDER.ID<br />
WHILE ORDER.ID DO<br />
@ID = ORDER.ID<br />
READ @RECORD FROM ORDERS.FILE,ORDER.ID ELSE<br />
PRINT 'ORDER NOT FOUND'<br />
@RECORD = ''<br />
END<br />
IF @RECORD THEN<br />
TOT.AMT = ITYPE(GRAND_TOTAL)<br />
TOT.AMT = OCONV(TOT.AMT,'MD2,$')<br />
PRINT "Total accounts receivable is ":TOT.AMT<br />
END<br />
REPEAT<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CALCULATE<br />
UniData<br />
COMPILE.DICT – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
Virtual attributes – For information, see Using UniData.<br />
ITYPE 1-408
LE<br />
Syntax<br />
expr1 LE expr2<br />
Synonyms<br />
#>, =
Related Command<br />
<strong>UniBasic</strong><br />
LES<br />
LE 1-409
LEN<br />
Syntax<br />
LEN(str.expr)<br />
Description<br />
The <strong>UniBasic</strong> LEN function returns the length of character expression str.expr. LEN<br />
supports multibyte languages.<br />
With null value handling on, the null value has a length of one byte.<br />
Examples<br />
In the following example, the program segment displays 14, the length of the string<br />
NAME:<br />
NAME = "Arthur Fiedler"<br />
PRINT LEN(NAME)<br />
The following figure illustrates a string that indicates below each “character” the<br />
number of bytes required to store that character. The string contains eight bytes.<br />
Therefore, LEN would return 8 for this string.<br />
Number<br />
of bytes<br />
1-410 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
2 3 1 2
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
BYTELEN, CHARLEN, DISPLAYWIDTH, ISMB, LENS, MBLEN<br />
LEN 1-411
LENS<br />
Syntax<br />
LENS(dyn.array)<br />
Description<br />
The <strong>UniBasic</strong> LENS function returns the length of the values within each element of<br />
a dynamic array. LENS supports multibyte languages.<br />
With null value handling on, the null value has a length of one byte.<br />
Example<br />
In the following example, the program segment creates a new array ARRAY1, which<br />
contains the length of each element of ARRAY:<br />
1-412 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ARRAY = '1':@VM:'22':@VM:'333':@VM:'4444':@VM:'55555'<br />
ARRAY1 = LENS(ARRAY)<br />
ARRAY1 now contains 1}2}3}4}5.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
BYTELEN, CHARLEN, DISPLAYWIDTH, ISMB, LEN, MBLEN
LES<br />
Syntax<br />
LES(array1,array2)<br />
Description<br />
The <strong>UniBasic</strong> LES function compares each value in array1 to its corresponding<br />
value in array2. UniData returns an array with 1 in each position where the value in<br />
array1 is less than or equal to the value in the corresponding value in array2, and 0<br />
in each position when the value in array1 is greater than that in array2.<br />
Example<br />
In the following example, the program segment compares ARRAY1 to ARRAY2 and<br />
returns ARRAY3. ARRAY3 then contains 1}1}1}0}0.<br />
ARRAY1 = 9:@VM:10:@VM:30:@VM:50:@VM:60<br />
ARRAY2 = 10:@VM:20:@VM:30@VM:40:@VM:50<br />
ARRAY3 = LES(ARRAY1,ARRAY2)<br />
LES 1-413
LISTUSER<br />
Syntax<br />
LISTUSER()<br />
Description<br />
The LISTUSER function returns information about UniData processes currently<br />
running in a dynamic array.<br />
In the event a UniData user session aborts through a power failure or other abnormal<br />
circumstance, UniData registers the aborted process as an active user, and it appears<br />
as such in the LISTUSER array. Eventually, the cleanupd daemon will detect these<br />
processes and remove the aborted process from the user list.<br />
LISTUSER Dynamic Array (UNIX)<br />
The following table describes the information in the LISTUSER array, by position.<br />
Parameter Description<br />
1-414 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
UDTNO Sequential number UniData assigns to each user.<br />
USRNBR System-level process ID (pid) assigned to a UniData session.<br />
UID System-level ID assigned to a user.<br />
USRNAME Login name of the user.<br />
USRTYPE Type of process the user is running.<br />
TTY Device ID.<br />
TIME Time the user process started.<br />
DATE Date the user process started.<br />
LISTUSER Array
Example<br />
The following example displays the output from the LISTUSER function on UNIX:<br />
1}5131}0}root}udt}pts/1}10:20:03}Oct 16 2002<br />
LISTUSER Dynamic Array (Windows Platforms)<br />
The following table lists the LISTUSER command display attributes.<br />
Parameter Description<br />
UDTNO Sequential number UniData assigns to each user.<br />
USRNBR Process ID of the UniData session.<br />
UID Windows ID of the user.<br />
USRNAME Login name of the user.<br />
USRTYPE Type of process the user is running.<br />
TTY Session identifier, formed by concatenating the string “pts/” and the<br />
UDTNO.<br />
IP-ADDRESS Location where the session is logged in; either “Console” or a valid IP<br />
address.<br />
TIME The time at which the user process started.<br />
DATE The date on which the user process started.<br />
LISTUSER Display Attributes<br />
LISTUSER 1-415
LN<br />
Syntax<br />
LN(num.expr)<br />
Description<br />
The <strong>UniBasic</strong> LN function returns the natural base logarithm of numeric expression<br />
num.expr. This function is the inverse of the EXP function.<br />
Example<br />
In the following example, the program statement assigns the natural logarithm of 12<br />
to the variable VAL. The result is 2.4849.<br />
VAL = LN(12)<br />
Related Command<br />
<strong>UniBasic</strong><br />
EXP<br />
1-416 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
loadSecurityContext<br />
Syntax<br />
loadSecurityContext(context, name, passPhrase)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The loadSecurityContext() function loads a saved security context record into the<br />
current session.<br />
The name and passPhrase parameters are needed to retrieve and decrypt the saved<br />
context. UniData creates an internal data structure and returns its handle in the<br />
context parameter.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
context The handle to be returned.<br />
name String containing the name of the file storing the security contents.<br />
PassPhrase String containing the passPhrase needed to decrypt the saved data.<br />
loadSecurityContext Parameters<br />
loadSecurityContext 1-417
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success.<br />
1-418 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
1 Context record does not exist.<br />
2 Context record could not be accessed (e.g. wrong password).<br />
3 Invalid content (file was not saved by the saveSecurityContext()<br />
function).<br />
4 Other problems that caused context load failure. Refer to the log file for<br />
more information.<br />
loadSecurityContext Return Codes
LOCATE<br />
Syntax<br />
LOCATE element IN dyn.array[,var]<br />
[BY search.type] SETTING location [THEN statements END]<br />
ELSE statements END<br />
For backward compatibility, UniData supports the following alternate syntax:<br />
LOCATE(element,dyn.array [,attrib.expr[,val.expr[,subval.expr]]];location<br />
[;search.type]) [THEN statements] [END] ELSE statements<br />
Description<br />
The <strong>UniBasic</strong> LOCATE command locates an element within a dynamic array. For<br />
LOCATE to be successful, the search string, element, must match the entire array<br />
element (including any associated lower-level elements). LOCATE does not modify<br />
the data in the array.<br />
Note: UDT.OPTIONS 85 changes the sort order for an array of mixed negative and<br />
positive numbers. With UDT.OPTIONS 85 on, negative and positive numbers are<br />
sorted in numeric order regardless of sign. This is effective for the first form of the<br />
syntax only.<br />
LOCATE 1-419
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-420 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
element Specifies the string to search for. element can be a variable, array<br />
element, function, or literal.<br />
dyn.array <br />
Specifies a dynamic array and level (attribute, value, or<br />
subvalue) to search. The search operates as follows:<br />
The search begins at the lowest level specified.<br />
Only the specified level is searched.<br />
Returns the position of the located string relative to the<br />
beginning of the search.<br />
1 in attrib.expr causes a search starting with the first attribute in<br />
the file.<br />
0 in any expression is treated as 1.<br />
If the arguments cause the search to begin beyond the end of the<br />
dynamic array, the ELSE clause executes.<br />
See also the LOCATE in BASICTYPEs U, P, and M table.<br />
,var Specifies the attribute, value, or subvalue in the array at which<br />
to begin the search.<br />
BY search.type Selects a type of search appropriate for the physical arrangement<br />
of a sorted array.<br />
AL – Ascending, contents left-justified.<br />
AR – Ascending, contents right-justified.<br />
DL – Descending, contents left-justified.<br />
DR – Descending, contents right-justified.<br />
When UniData first retrieves the data, it sorts the data in the<br />
requested order.<br />
Do not use a BY clause in a LOCATE statement on an unsorted<br />
array. The search could terminate before checking all elements.<br />
UDT.OPTIONS 85 modifies the sort to place negative numbers<br />
first rather than sort them in ASCII order.<br />
LOCATE Parameters
Parameter Description<br />
SETTING location Returns the location of the string. If the search is not successful,<br />
execution depends on the presence of the BY clause:<br />
If the BY clause is included, the array is assumed to be sorted,<br />
and a location is returned indicating where the element should be<br />
inserted to maintain the array in sorted order.<br />
If the BY clause is not included, the array is assumed to be<br />
unsorted, and the location returned is of the last element plus<br />
one.<br />
THEN statements END THEN (optional) is executed when the search is successful.<br />
Multiple line THEN or ELSE statements require an END<br />
keyword.<br />
ELSE statements END ELSE (required) is executed if the search is unsuccessful.<br />
Multiple line THEN or ELSE statements require an END<br />
keyword.<br />
Note: The syntax for BASICTYPEs P and M differs in the number of array elements<br />
you can include and the search driven by those elements. Syntax variants for P and<br />
M are as follows:<br />
LOCATE element IN dyn.array [BY search.type]<br />
SETTING location [THEN statements END] ELSE statements END<br />
and<br />
LOCATE Parameters (continued)<br />
LOCATE(element,dyn.array [,attrib.expr[,val.expr]];location [;search.type])<br />
[THEN statements] [END] ELSE statements<br />
LOCATE 1-421
LOCATE in BASICTYPEs U, P, and M<br />
The following table compares the searches performed in BASICTYPEs U, P, and M.<br />
Examples<br />
The following program segment is taken from the sample program in Appendix A,<br />
“Sample Program,” in Developing <strong>UniBasic</strong> Applications. LOCATE returns the<br />
position of the order number to be deleted.<br />
1-422 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
LOCATE Parameter in BASICTYPE U in BASICTYPEs P and M<br />
no expr Performs no search; invalid<br />
syntax.<br />
attrib.expr Searches the attribute<br />
specified; match must<br />
include associated values<br />
and subvalues.<br />
val.expr Searches the value specified;<br />
match must include<br />
associated subvalues.<br />
subval.expr Searches subvalues<br />
associated with the specified<br />
value; begins with the<br />
specified subvalue.<br />
Comparison of BASICTYPEs U, P, and M<br />
Searches all attributes; match<br />
must include associated values<br />
and subvalues.<br />
Searches values associated with<br />
the specified attribute; match<br />
must include associated<br />
subvalues.<br />
Searches subvalues associated<br />
with the specified value.<br />
Performs no search; invalid<br />
syntax.<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
In the following example, the program statement searches the entire array, FILMS,<br />
element by element, for the literal string “BATMAN.” If the search is successful,<br />
UniData assigns the location of the element to the variable NDX. If UniData does not<br />
find the string, it sets NDX to the location of the last value plus 1, and it executes the<br />
STOP command. The LOCATE command performs the search on the attribute level.<br />
LOCATE "BATMAN" IN FILMS SETTING NDX ELSE STOP<br />
Because the LOCATE statement compares the entire element (including associated<br />
lower-level elements), a match will not be successful on either of the following<br />
arrays:<br />
or<br />
"CARMEN":@AM:"BATMANII":@AM:"JAWS"<br />
"CARMEN":@AM:"BATMAN":@VM:"KEATON":@VM:"DEVITO"@VM:"CARREY<br />
":@AM:"JAWS"<br />
In the next example, the program segment prints “BATMAN IS IN POSITION 2 IN<br />
THE ARRAY”:<br />
FILMS = "CARMEN":@AM:"BATMAN":@AM:"JAWS"<br />
LOCATE "BATMAN" IN FILMS SETTING NDX ELSE<br />
PRINT "NOT FOUND"<br />
STOP<br />
END<br />
PRINT "BATMAN IS IN POSITION ":NDX:" IN THE ARRAY"<br />
In the next example, the program segment searches the array FILMS, starting at<br />
attribute 2, value 2, for the contents of the variable DEVITO. UniData assumes the<br />
array elements are in ascending order and left-justified.<br />
LOCATE DEVITO IN FILMS BY "AL" SETTING NDX THEN<br />
PRINT "THIS TITLE IS IN THE LIBRARY"<br />
END ELSE<br />
PRINT "TITLE NOT FOUND, TRY AGAIN."<br />
END<br />
When executed on the following array, DEVITO is located in position 3 in the array<br />
at the value level, and UniData executes the first PRINT statement:<br />
"CARMEN":@AM:"BATMAN":@VM:"KEATON":@VM:"DEVITO"@VM:"CARREY<br />
":@AM:"JAWS"<br />
LOCATE 1-423
However, in the following array, the LOCATE command does not find DEVITO, and<br />
UniData executes the second PRINT statement:<br />
1-424 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
"CARMEN":@AM:"BATMAN":@VM:"KEATON"@VM:"CARREY":@AM:"BATMAN<br />
III": @VM:"KILMER":@VM:"DEVITO"@AM:"JAWS"<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
FIND, FINDSTR
LOCK<br />
Syntax<br />
LOCK resource.num {THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> LOCK command reserves a computer resource (such as a device or<br />
file) for the current user process.<br />
The lock is associated with resource.num, not the resource itself. Therefore, a<br />
command that does not check for locks against the resource number will access the<br />
resource even if it is locked. For example, an installation might assign locks 1<br />
through 4 to four system printers. When an application needs to reserve printer 1, the<br />
application executes LOCK 1. For lock effectiveness, all other applications must<br />
check for locks before accessing the resource.<br />
Resources are not automatically unlocked by the termination of the locking program.<br />
The <strong>UniBasic</strong> UNLOCK or ECL QUIT commands must release them. Otherwise,<br />
you can release resources by executing the ECL CLEAR.LOCKS command at<br />
UniData level.<br />
For more information about UniData locks, see Developing <strong>UniBasic</strong> Applications.<br />
LOCK 1-425
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Examples<br />
In the following example, the program statement reserves resource 12 if another<br />
program is not using it. If resource 12 is already in use, the current program suspends<br />
execution and waits until UniData unlocks resource 12.<br />
LOCK 12<br />
In the next example, the program segment locks resource 44 if it is available. If it has<br />
already been locked, the program attempts to lock resource 45. If both resources are<br />
unavailable, the program stops.<br />
1-426 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
resource.num Specifies a number associated with a resource. resource.num can<br />
be any number from 0 through 63.<br />
For assistance in assigning resource numbers, see your system<br />
administrator.<br />
THEN statements END Specifies statements to execute if the LOCK statement executes<br />
successfully.<br />
ELSE statements END Specifies statements to execute if another user has reserved the<br />
resource (using the same resource number) so that the LOCK<br />
statement fails to lock it.<br />
If you do not specify an ELSE clause and the requested resource<br />
has already been locked, the current program waits until that<br />
resource is released.<br />
Use the ECL command DEFAULT.LOCKED.ACTION BELL<br />
to make the terminal beep while you wait for UniData to release<br />
the lock.<br />
LOCK Parameters<br />
T1 = 44; T2 = 45<br />
LOCK T1 ELSE LOCK T2 ELSE STOP
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
UNLOCK<br />
UniData<br />
CLEAR.LOCKS, LIST.LOCKS, SUPERCLEAR.LOCKS,<br />
DEFAULT.LOCKED.ACTION – For information, see the UniData <strong>Commands</strong><br />
<strong>Reference</strong>.<br />
LOCK 1-427
LOOP/REPEAT<br />
Syntax<br />
LOOP<br />
[statements]<br />
[UNTIL expr [DO]<br />
statements]<br />
[WHILE expr [DO]<br />
statements]<br />
REPEAT<br />
LOOP {WHILE | UNTIL} expr DO<br />
statements<br />
REPEAT<br />
LOOP<br />
statements<br />
{WHILE | UNTIL} expr DO REPEAT<br />
Description<br />
The <strong>UniBasic</strong> LOOP/REPEAT command repeats any contained statements while or<br />
until a specified condition is met, depending on whether you use the WHILE or<br />
UNTIL clause. statements can precede and/or follow the test condition. If space<br />
permits, you can write the structure on one line. Otherwise, you can extend the<br />
structure on as many lines as necessary. REPEAT is required and finishes the LOOP<br />
operation.<br />
UniData executes the first set of statements on the first entry into the loop, and then<br />
evaluates the WHILE or UNTIL clause. If expr is true (using the WHILE keyword)<br />
or false (using the UNTIL keyword), UniData executes the second set of statements.<br />
If you have statements after a WHILE or UNTIL clause, the DO clause is required.<br />
Otherwise, it is optional. When the program execution reaches REPEAT, it returns to<br />
the first set of statements.<br />
1-428 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Tip: IBM recommends that you construct loops that terminate based on the WHILE<br />
or UNTIL condition. The LOOP statement is flexible enough to incorporate almost<br />
any logical progression. Use the CONTINUE keyword to transfer control to the<br />
beginning of the next loop.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
expr Specifies an expression to check to for the UNTIL or WHILE<br />
clause.<br />
expr can be any valid statement that includes a READNEXT<br />
statement or LOCATE statement.<br />
statements Specifies statements to execute each time the loop statement<br />
repeats.<br />
WHILE statements Specifies statements to execute if the expression in the WHILE<br />
clause is true.<br />
UNTIL statements Specifies statements to execute if the expression in the UNTIL<br />
clause is false.<br />
LOOP/REPEAT Parameters<br />
LOOP/REPEAT 1-429
Examples<br />
The following example is taken from the sample program in Appendix A, “Sample<br />
Program,” in Developing <strong>UniBasic</strong> Applications. This subroutine loops until the user<br />
enters a valid order number, or Q (the prompt for order number is already displayed<br />
on the screen).<br />
1-430 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
GET_ORDER_NUMBER:<br />
* Have the user enter a valid key to a record in the ORDERS file.<br />
LOOP<br />
DISPLAY @(15,6):<br />
INPUT ORDER_NUMBER<br />
ORDER_NUMBER = OCONV(ORDER_NUMBER,"MCU")<br />
IF NUM(ORDER_NUMBER) OR ORDER_NUMBER[1,1] = "Q" THEN<br />
VALID_ORDER_NUMBER = 1<br />
END ELSE<br />
VALID_ORDER_NUMBER = 0<br />
MESSAGE = "Order # must be a Number, or the letter 'Q'"<br />
CALL DISPLAY_MESSAGE(MESSAGE)<br />
END<br />
UNTIL VALID_ORDER_NUMBER<br />
REPEAT<br />
In the next example, the program segment prints and increments POS until it reaches<br />
the value of 10:<br />
POS=0<br />
LOOP WHILE POS < 10 DO<br />
PRINT POS<br />
POS +=1<br />
REPEAT<br />
In the next example, the program segment prints “Counting” and then increments C.<br />
It then evaluates C to see if it is less than eight, and if so, executes the second<br />
statement. On the eighth iteration, the program executes the top statement and the<br />
loop stops because the condition (C > 8) is met. The program continues execution at<br />
the statement following REPEAT. The program does not execute the second<br />
statement on the final iteration.<br />
C = 0<br />
PRINT "Counting:"<br />
LOOP<br />
C = C+1<br />
UNTIL C > 8 DO<br />
PRINT "C = ":C<br />
REPEAT
The result of this program:<br />
Counting:<br />
C = 1<br />
C = 2<br />
C = 3<br />
C = 4<br />
C = 5<br />
C = 6<br />
C = 7<br />
C = 8<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CASE, CONTINUE, FOR/NEXT<br />
LOOP/REPEAT 1-431
LOWER<br />
Syntax<br />
LOWER(dyn.array.expr)<br />
Description<br />
The <strong>UniBasic</strong> LOWER function converts all attribute marks to value marks, and, in<br />
a dynamic array, it converts all value marks to subvalue marks.<br />
Example<br />
In the following example, the program segment lowers the dynamic array D.STR:<br />
1-432 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
D.STR = "A":@AM:"B":@AM:"C":@VM:"D"<br />
D.STR = LOWER(D.STR)<br />
The dynamic array D.STR now contains the string:<br />
D.STR = "A":@VM:"B":@VM:"C":@SM:"D"<br />
Related Command<br />
<strong>UniBasic</strong><br />
RAISE
LT<br />
Syntax<br />
expr1 LT expr2<br />
Synonym<br />
<<br />
Description<br />
The <strong>UniBasic</strong> LT relational operator tests whether expression expr1 is less than<br />
expr2.<br />
expr1 and expr2 can be any valid <strong>UniBasic</strong> expressions, variables, strings, or literals.<br />
Relational operators make the comparisons that direct program flow in conditional<br />
statements such as the following:<br />
IF VAR1 LT VAR2 THEN GOSUB SUB1<br />
DO UNTIL VAR1 < VAR2<br />
Example<br />
In the following example, the program segment tests whether A is less than B.<br />
Because A is less than B, the message “Less than” prints.<br />
A = 21<br />
B = 22<br />
IF A LT B THEN<br />
PRINT "Less than"<br />
END ELSE<br />
PRINT "Greater than"<br />
END<br />
LT 1-433
Related Command<br />
<strong>UniBasic</strong><br />
LTS<br />
1-434 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
LTS<br />
Syntax<br />
LTS(array1,array2)<br />
Description<br />
The <strong>UniBasic</strong> LTS function compares each element in array1 to its corresponding<br />
value in array2. UniData returns an array with 1 in each position where the value in<br />
array1 is less than the value in the corresponding position in array2, and 0 in each<br />
position for values in array1 that are greater than those in array2.<br />
Example<br />
In the following example, the program segment compares ARRAY1 to ARRAY2 and<br />
returns ARRAY3. ARRAY3 then contains 1}1}0}0}0.<br />
ARRAY1 = 9:@VM:10:@VM:30:@VM:50:@VM:60<br />
ARRAY2 = 10:@VM:20:@VM:30@VM:40:@VM:50<br />
ARRAY3 = LTS(ARRAY1,ARRAY2)<br />
LTS 1-435
MAT<br />
Syntax<br />
MAT dim.array = expr<br />
MAT dim.array = MAT dim.array2<br />
Description<br />
The first form of the <strong>UniBasic</strong> MAT command assigns new values to all elements of<br />
a dimensioned array based on an expression.<br />
The second form assigns the contents of a dimensioned array to another dimensioned<br />
array.<br />
If you assign a dimensioned array the values of a second dimensioned array, the<br />
assignment proceeds from element to element in consecutive order. The program<br />
assigns the first element of the first array to the first element of the second array, then<br />
assigns the second element to the second element of the second array, and so on. The<br />
two arrays do not have to match in configuration of dimensions, but must contain the<br />
same number of elements. UniData does not alter the second dimensioned array in<br />
the assignment process.<br />
Use the DIM command to dimension all arrays before you assign new values to the<br />
elements. You can place MAT in any looping structure and assign the elements with<br />
a variable or function.<br />
1-436 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dim.array Specifies a dimensioned array to receive new values.<br />
expr Specifies the value to assign to the array elements. expr can be any<br />
<strong>UniBasic</strong> expression.<br />
expr can be an empty string, a formula, a single value, a literal string, or a<br />
function.<br />
dim.array2 Specifies a dimensioned array from which to assign values.<br />
MAT Parameters<br />
Examples<br />
In the following example, the program segment assigns 1.5 to all elements of the<br />
array FEES:<br />
DIM FEES(100,100)<br />
MAT FEES = 1.5<br />
In the next example, the program segment assigns the values in dimensioned array<br />
FEE2 to the dimensioned array FEE1. Note the differing dimensions but the same<br />
number of elements in the two matrices.<br />
DIM FEE1(2,4),FEE2(4,2)<br />
MAT FEE1 = MAT FEE2<br />
If the arrays contain the following values before the assignment:<br />
dimensioned array FEE1 dimensioned array FEE2<br />
1 2 3 4<br />
5 6 7 8<br />
10 11<br />
12 13<br />
14 15<br />
16 17<br />
MAT 1-437
the values assigned to FEE1 would be:<br />
Notice how the elements are assigned: from left to right, top to bottom, element by<br />
element. UniData maintains all values in dimensioned array FEE2. The positions are<br />
shifted to fit the dimensions of dimensioned array FEE1.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DIM, INMAT, MATBUILD, MATPARSE, MATREAD, MATREADL,<br />
MATREADU, MATWRITE, MATWRITEU<br />
1-438 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
dimensioned array FEE1<br />
10 11 12 13<br />
14 15 16 17
MATBUILD<br />
Syntax<br />
MATBUILD dyn.array FROM dim.array [,start.num [,end.num [USING delim]]]<br />
Description<br />
The <strong>UniBasic</strong> MATBUILD command generates a dynamic array from a dimensioned<br />
array based on specified starting and ending positions and the delimiter given.<br />
The dimensioned array can be multidimensional. The statement retrieves elements<br />
from the multidimensional array according to the order in which its elements are<br />
stored.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dyn.array Specifies the dynamic array to be created.<br />
FROM dim.array Specifies the dimensioned array from which to build the dynamic<br />
array.<br />
MATBUILD Parameters<br />
MATBUILD 1-439
Parameter Description<br />
Examples<br />
In the following example, A is a dimensioned array with five elements:<br />
1-440 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
,start.num Specifies the starting position in the dimensioned array. If start.num<br />
is less than or equal to 0, UniData defaults to 1. The dynamic array<br />
is not generated if start.num is greater than end.num.<br />
,end.num Specifies the ending position in the dimensioned array.<br />
If end.num is less than or equal to 0, or if it is beyond the end of the<br />
dimensioned array, UniData retrieves data to the end of the<br />
dimensioned array.<br />
USING delim The USING clause specifies the delimiter delim in the dyn.array<br />
generation. If you do not specify delim, or if you specify an empty<br />
string, delim defaults to @AM (attribute mark). If you specify more<br />
than one character, only the first character is used. UniData inserts<br />
delim between the elements if dyn.array.<br />
A(1)=11, A(2)=22, A(3)=33, A(4)=44, and A(5)=55<br />
The following program statement:<br />
MATBUILD NEW.ARRAY FROM A ,2,4<br />
generates the following dynamic array:<br />
NEW.ARRAY = "22":@AM:"33":@AM:"44"<br />
The next program statement:<br />
MATBUILD ARRAY FROM A ,1 USING ','<br />
generates the following dynamic array:<br />
ARRAY = "11,22,33,44,55"<br />
MATBUILD Parameters (continued)
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DIM, INMAT, MAT, MATPARSE, MATREAD, MATREADL, MATREADU,<br />
MATWRITE, MATWRITEU<br />
MATBUILD 1-441
MATCH<br />
Syntax<br />
var MATCH "[~] len [X, A, N] [text]"<br />
Synonym<br />
MATCHES<br />
Description<br />
The <strong>UniBasic</strong> MATCH or MATCHES function determines if a variable matches a<br />
specific pattern of characters, numbers, or a literal string. If var matches the pattern,<br />
MATCH or MATCHES returns 1. If var does not match the pattern, MATCH or<br />
MATCHES returns 0.<br />
Tip: You can mix codes and literal strings. To differentiate between the two, enclose<br />
the literal in single quotation marks within the larger pattern, which is enclosed in<br />
double quotation marks.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-442 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
var Specifies the variable to compare with the MATCH expression.<br />
~ Reverses the pattern. To match 4N, a string must contain four numeric<br />
characters. To match ~4N, a string must contain four characters that are not<br />
all numeric.<br />
len Specifies the number of characters to match.<br />
X Specifies that characters can be of any type.<br />
MATCH Parameters
Parameter Description<br />
A Specifies that only alphabetic characters match the pattern.<br />
N Specifies that only numbers match the pattern.<br />
text Specifies a literal string to search for. Enclose this literal text within single<br />
quotation marks if combined with a pattern (made up of X, A, and N).<br />
Examples<br />
MATCH Parameters (continued)<br />
In the following example, the program segment determines if the variable SSN is a<br />
valid social security number:<br />
SSN = "522-13-5124"<br />
SSNTEST = SSN MATCH "3N'-'2N'-'4N"<br />
The following program accepts as input a pattern to match and a string to search:<br />
PRINT "This program tests the MATCH function"<br />
PRINT "Enter pattern ":<br />
INPUT pattern<br />
PRINT "Enter string to match":<br />
INPUT string1<br />
answer = string1 MATCH pattern<br />
PRINT \"\ : answer : \"\<br />
In the following test executions of the preceding program, the user tests for a string<br />
that consists of three alphabetic characters followed by the literal “3A”. The literal<br />
(3A) is enclosed in quotation marks to differentiate it from the pattern 3A.<br />
:RUN BP match.test<br />
This program tests the MATCH function<br />
Enter pattern ?3A'3A'<br />
Enter string to match?AAA3A<br />
"1"<br />
:RUN BP match.test<br />
This program tests the MATCH function<br />
Enter pattern ?3A'3A'<br />
Enter string to match?3AAAA<br />
"0"<br />
MATCH 1-443
MATCHFIELD<br />
Syntax<br />
MATCHFIELD(str.expr,"[~] {len [X | ,A | ,N]} [text]", field.expr)<br />
Description<br />
The <strong>UniBasic</strong> MATCHFIELD function returns a substring that matches a pattern or<br />
literal. If no match is made, UniData returns an empty string. MATCHFIELD<br />
supports multibyte languages.<br />
You can mix the codes and a text string to search for specific patterns separated by<br />
characters.<br />
With null value handling on, if a function encounters the null value in a parameter<br />
when a number is expected (field.expr), a warning message displays and <strong>UniBasic</strong><br />
uses 0.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Paramete<br />
r Description<br />
1-444 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
str.expr Specifies the variable to compare with the MATCH expression.<br />
~ Inverses the pattern. To match 4N, a string must contain four numeric<br />
characters. To match ~4N, a string must contain four characters that are not<br />
numeric.<br />
len Specifies the number of characters to match.<br />
X Specifies that characters can be of any data type.<br />
A Specifies that only alphabetic characters match the pattern.<br />
MATCHFIELD Parameters
Paramete<br />
r Description<br />
N Specifies that only numbers match the pattern.<br />
text Specifies a literal string to search for.<br />
field.expr Specifies a portion of the str.expr to return. Each code segment is considered<br />
to be a field for the purposes of field.expr.<br />
Examples<br />
MATCHFIELD Parameters (continued)<br />
In the following example, the program segment returns the value 56 because the<br />
entire string matches the specified criteria, and the third field contains the number 56:<br />
SSN = "534-56-5565"<br />
MID = MATCHFIELD(SSN,"3N'-'2N'-'4N",3)<br />
In the next example, the program segment searches the string and returns the second<br />
and fourth fields and prints “99922”:<br />
STRING = "ALL999WERE22ABSENT"<br />
NUM1 = MATCHFIELD(STRING,'3A3N4A2N6A',2)<br />
NUM2 = MATCHFIELD(STRING,'3A3N4A2N6A',4)<br />
PRINT NUM1:NUM2<br />
MATCHFIELD 1-445
MATPARSE<br />
Syntax<br />
MATPARSE dim.array FROM str.expr, delim.expr<br />
Description<br />
The <strong>UniBasic</strong> MATPARSE command distributes elements of a delimited string or<br />
dynamic array to consecutive elements of a dimensioned array. Delimiters can be the<br />
standard UniData delimiters or any other ASCII character.<br />
When you specify an alternate delimiter, UniData returns a two-dimensional array.<br />
The delimited string is placed in the first dimensioned array element, and the<br />
delimiter is placed in the second element. When UniData encounters two delimiters<br />
in a row, both are placed in the first element.<br />
Note: BASICTYPEs P and R do not support the 0,0 element in dimensioned arrays.<br />
If more elements are delimited in the string than can be placed in the dimensioned<br />
array, a runtime error results and data is lost.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-446 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
dim.array Specifies the target dimensioned array.<br />
str.expr Specifies a delimited string to place in the dimensioned array.<br />
delim.expr Specifies the delimiter to use for parsing str.expr. You can use any ASCII<br />
character including commas or spaces.<br />
MATPARSE Parameters
INMAT Function Return Values<br />
After you execute MATPARSE, the INMAT function returns one of the values<br />
described in the following table.<br />
Value Description<br />
n The number of elements loaded into the array.<br />
0 The array was too small to contain all elements in the string. All excess data<br />
(including delimiters) is placed in the 0,0 element.<br />
INMAT Function Return Values<br />
Examples<br />
In the following example, the program segment fills the dimensioned array ALPHA<br />
with consecutive characters from a literal string. An empty string is the delimiter,<br />
causing one character to be assigned to each dimensioned array cell. In this case, the<br />
value returned by the INMAT function would be 7.<br />
DIM ALPHA(7)<br />
MATPARSE ALPHA FROM "ABCDEFG",""<br />
The preceding program segment produces the following dimensioned array:<br />
ALPHA(1) = "A"<br />
.<br />
.<br />
.<br />
ALPHA(7) = "G"<br />
In the next example, the program segment dimensions the dimensioned array T and<br />
then fills it with data from a dynamic array. The delimiter specified is the attribute<br />
mark, so each attribute is assigned to consecutive elements of the array. Note that the<br />
string “ITEM” has five elements, but the array is dimensioned with four elements.<br />
After the MATPARSE command, the INMAT function is 0 and the value of the zero<br />
element T(0) is 443.<br />
DIM T(4)<br />
ITEM = "123:@AM:33:@AM:199:@AM:821:@AM:443"<br />
MATPARSE T FROM ITEM, CHAR(254)<br />
MATPARSE 1-447
The preceding program segment produces the following dimensioned array:<br />
T(0) = 443<br />
T(1) = 123<br />
T(2) = 33<br />
T(3) = 199<br />
T(4) = 821<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DIM, INMAT, MAT, MATBUILD, MATREAD, MATREADL, MATREADU,<br />
MATWRITE, MATWRITEU<br />
1-448 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
MATREAD<br />
Syntax<br />
MATREAD dim.array [FROM [file.var,]record.ID.expr [ON ERROR statements]<br />
{THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> MATREAD command assigns the values found in successive attributes<br />
of a record to corresponding elements of a dimensioned array — regardless of<br />
lock status.<br />
You must use the DIM command to create a dimensioned array before you execute<br />
MATREAD.<br />
Note: This command does not check for locks. If you are operating in a multiuser<br />
environment, you must use record locks to prevent users from overlaying data<br />
updated by others. For more information about the <strong>UniBasic</strong> record locking, see<br />
Developing <strong>UniBasic</strong> Applications.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dim.array Specifies the dimensioned array into which the values are read.<br />
FROM file.var, Specifies the file from which to read.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal READ error occurs.<br />
A default file is one for which no file variable is assigned in the<br />
OPEN statement.<br />
record.ID.expr Specifies the record from which to read.<br />
MATREAD Parameters<br />
MATREAD 1-449
Parameter Description<br />
INMAT Function Return Values<br />
After you execute MATREAD, the INMAT function returns one of the values<br />
described in the following table.<br />
Note: BASICTYPEs P and R do not support the 0,0 element. If more attributes are<br />
read from the file than can be placed in the dimensioned array, a runtime error results<br />
and data is lost.<br />
Examples<br />
In the following example, the program segment reads the record with ID NAMES<br />
from the CUSTFILE, and assigns the elements to the dimensioned array TEST. If the<br />
program does not find the record, it assigns the value 0 to the variable FOUND.<br />
1-450 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ON ERROR statements Specifies statements to execute if the MATREAD statement fails<br />
with a fatal error because the file is not open, an I/O error occurs,<br />
or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record (or ID)<br />
does not exist. END is required to terminate multiline ELSE<br />
statements.<br />
Value Meaning<br />
MATREAD Parameters (continued)<br />
n The number of attributes loaded into the array.<br />
0 The array was too small to contain all attributes in the record. The excess data<br />
(including delimiters) is placed in the 0,0 element.<br />
INMAT Function Return Values<br />
DIM TEST(10,10)<br />
MATREAD TEST FROM CUSTFILE,"NAMES" ELSE FOUND = 0
In the next example, the program segment reads the record with ID NAMES and<br />
assigns the data from the record to the dimensioned array TEST:<br />
OPEN "CUSTFILE" TO CF ELSE STOP "NO CUSTFILE"<br />
MATREAD TEST FROM CF,"NAMES" ELSE FOUND = 0<br />
In the next example, the MATREAD statement includes multiline THEN and ELSE<br />
clauses:<br />
FILE.ERR = 0<br />
DIM CUST.ITEM(22)<br />
MATREAD CUST.ITEM FROM CUST.FILE,CUST.ID THEN<br />
GOSUB PROCESS.CUSTOMER:<br />
END ELSE<br />
MAT CUST.ITEM = "<br />
FILE.ERR = 1<br />
END<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DIM, INMAT, MAT, MATBUILD, MATPARSE, MATREADL, MATREADU,<br />
MATWRITE, MATWRITEU<br />
MATREAD 1-451
MATREADL<br />
Syntax<br />
MATREADL dim.array FROM [file.var,]record.ID.expr [ON ERROR statements]<br />
[LOCKED statements] {THEN statements [END] | ELSE statements [END]}<br />
MATREADL dim.array FROM [file.var,]record.ID.expr [LOCKED statements]<br />
[ON ERROR statements] {THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> MATREADL command assigns the values found in successive attributes<br />
of a record to corresponding elements of a dimensioned array. MATREADL<br />
checks for locks and will not read a record locked with an exclusive (U) lock. If the<br />
record is available, MATREADL reads and sets a shared (L) lock on it.<br />
Note: <strong>UniBasic</strong> locks are advisory only. They prevent access by other lock-checking<br />
commands only. For more information about <strong>UniBasic</strong> locks, see Developing<br />
<strong>UniBasic</strong> Applications.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-452 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
dim.array Specifies the dimensioned array into which the values are read.<br />
FROM file.var, Specifies the file from which to read.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal READ error occurs.<br />
A default file is one for which no file variable is assigned in the<br />
OPEN statement.<br />
record.ID.expr Specifies the record from which to read the attributes.<br />
MATREADL Parameters
Parameter Description<br />
ON ERROR statements Specifies statements to execute if the MATREADL statement<br />
fails with a fatal error because the file is not open, an I/O error<br />
occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
LOCKED statements Specifies statements to execute if the record is locked by another<br />
user. If you do not specify a LOCKED clause, the program waits<br />
until UniData releases the lock on the record. You can place the<br />
LOCKED clause after the FROM clause.<br />
Use the ECL command DEFAULT.LOCKED.ACTION BELL<br />
to make the terminal beep while you wait for UniData to unlock<br />
the record.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record (or ID)<br />
does not exist. END is required to terminate multiline ELSE<br />
statements.<br />
INMAT Function Return Values<br />
After you execute MATREADL, the INMAT function returns one of the values<br />
described in the following table.<br />
Value Description<br />
MATREADL Parameters (continued)<br />
n The number of attributes loaded into the array.<br />
0 The array was too small to contain all attributes in the record. The excess data<br />
(including delimiters) is placed in the zero element.<br />
INMAT Function Return Values<br />
Note: BASICTYPEs P and R do not support the 0,0 element. If UniData reads more<br />
attributes from the file than it can place in the dimensioned array, a runtime error<br />
results and data is lost.<br />
MATREADL 1-453
Example<br />
In the following example, the program segment reads a tape record with the ID<br />
specified in TAPE.ID from the TAPES.FILE. If the program finds the record, it<br />
transfers control to the subroutine TAPE.PROCESS. Otherwise, the program<br />
displays a message and aborts. If the record is locked with an exclusive lock, the<br />
program does not execute the subroutine. Instead, it displays the message “RECORD<br />
LOCKED” and waits for the lock to be released.<br />
1-454 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
MATREADL TAPE.REC FROM TAPES.FILE,TAPE.ID THEN<br />
GOSUB TAPE.PROCESS:<br />
PRINT "TAPE PROCESSED:":TAPE.ID<br />
END<br />
LOCKED PRINT "RECORD LOCKED"<br />
ELSE PRINT "RECORD NOT FOUND:":TAPE.ID; ABORT<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DIM, INMAT, MAT, MATBUILD, MATPARSE, MATREAD, MATREADU,<br />
MATWRITE, MATWRITEU<br />
UniData<br />
DEFAULT.LOCKED.ACTION – For more information, see the UniData <strong>Commands</strong><br />
<strong>Reference</strong>.
MATREADU<br />
Syntax<br />
MATREADU dim.array FROM [file.var,] record.ID.expr [ON ERROR statements]<br />
[LOCKED statements] {THEN statements [END] | ELSE statements [END]}<br />
MATREADU dim.array FROM [file.var,] record.ID.expr [LOCKED statements]<br />
[ON ERROR statements] {THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> MATREADU command assigns the values found in successive attributes<br />
of a record to corresponding elements of a dimensioned array. MATREADU<br />
checks for locks and will not read a locked record. If the record is available,<br />
MATREADU reads and sets an exclusive (U) lock on it.<br />
Note: <strong>UniBasic</strong> locks are advisory only. They prevent access by other lock-checking<br />
commands only. For more information about <strong>UniBasic</strong> locks, see Developing<br />
<strong>UniBasic</strong> Applications.<br />
BASICTYPEs P and R do not support the 0,0 element. If UniData reads more attributes<br />
from the file than it can place in the dimensioned array, a runtime error results<br />
and data is lost.<br />
MATREADU 1-455
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-456 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
dim.array Specifies the dimensioned array into which the values are read.<br />
FROM file.var Specifies the file from which to read.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal READ error occurs.<br />
A default file is one for which no file variable is assigned in the<br />
OPEN statement.<br />
record.ID.expr Specifies the record from which to read the attributes.<br />
ON ERROR statements Specifies statements to execute if the MATREADU statement<br />
fails with a fatal error because the file is not open, an I/O error<br />
occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
LOCKED statements Specifies statements to execute if the record is locked by another<br />
user. If you do not specify a LOCKED clause, the program waits<br />
until the lock on the record is released. You can place the<br />
LOCKED clause after the FROM clause.<br />
Use the ECL command DEFAULT.LOCKED.ACTION BELL<br />
to beep the terminal while waiting for the record to be unlocked.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record (or ID)<br />
does not exist. END is required to terminate multiline ELSE<br />
statements.<br />
MATREADU Parameters
INMAT Function Return Values<br />
After you execute MATREADU, the INMAT function returns one of the values<br />
described in the following table.<br />
Value Description<br />
n The number of attributes loaded into the array.<br />
0 The array was too small to contain all attributes in the record. All excess data<br />
(including delimiters) is placed in the zero element.<br />
INMAT Function Return Values<br />
Examples<br />
In the following example, the program segment reads the record with ID “NAMES”<br />
from the CUST file. Because no LOCKED clause is provided, the program waits for<br />
access if the record is locked by another user.<br />
DIM TEST(10,10)<br />
MATREADU TEST FROM CUST,"NAMES" ELSE GOSUB 105<br />
In the next example, the program segment reads the record with the ID CUST.ID and<br />
assigns each attribute to successive elements in the dimensioned array CUST.REC.<br />
If the record is found, UniData executes the THEN clause. If the record is locked,<br />
UniData displays RECORD LOCKED and waits for the lock to be released. If the<br />
record is not found, UniData displays RECORD NOT FOUND FOR CUSTOMER<br />
and the customer ID.<br />
MATREADU CUST.REC FROM CUSTFILE,CUST.ID THEN<br />
PRINT "PROCESSING CUSTOMER: ":CUST.ID<br />
GOSUB PROCESS.CUSTOMER:<br />
END LOCKED<br />
PRINT 'RECORD LOCKED '<br />
END ELSE<br />
PRINT 'RECORD NOT FOUND FOR CUSTOMER ':CUST.ID<br />
END<br />
MATREADU 1-457
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DIM, INMAT, MAT, MATBUILD, MATPARSE, MATREAD, MATREADL,<br />
MATWRITE, MATWRITEU<br />
UniData<br />
DEFAULT.LOCKED.ACTION – For information, see the UniData <strong>Commands</strong><br />
<strong>Reference</strong>.<br />
1-458 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
MATWRITE<br />
Syntax<br />
MATWRITE dim.array {ON | TO file.var,} record.ID.expr<br />
[ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> MATWRITE command writes successive elements of a dimensioned<br />
array to the corresponding attributes of a record.<br />
If the dimensioned array size exceeds the number of attributes in the target record,<br />
the MATWRITE command does not write the trailing spaces. If the 0 element is not<br />
empty, the command writes the contents of the element after the final element in the<br />
record (as element N+1).<br />
Note: This command must be preceded by MATREADU or another locking command<br />
to prevent the type of inconsistency that results when multiple users access files at the<br />
same time. For more information, see Developing <strong>UniBasic</strong> Applications.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dim.array Specifies the dimensioned array from which to assign the values<br />
read to the successive attributes of the record record.ID.expr.<br />
You must name and dimension an array before you can use it in<br />
the MATWRITE statement.<br />
MATWRITE Parameters<br />
MATWRITE 1-459
Parameter Description<br />
STATUS Function Return Values<br />
After you execute MATWRITE, the STATUS function returns one of the values<br />
described in the following table.<br />
Example<br />
In the following example, the program segment writes the dimensioned array<br />
RECEIPTS to the file REC87 as a record with ID “RENTALS”:<br />
1-460 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ON | TO file.var, Specifies the file on which to write the record. You must specify<br />
an ON or TO clause.<br />
record.ID.expr Specifies the record on which to write the attributes.<br />
ON ERROR statements Specifies statements to execute if MATWRITE fails with a fatal<br />
error because the file is not open, an I/O error occurs, or UniData<br />
cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
Value Description<br />
MATWRITE Parameters (continued) (continued)<br />
0 The record was locked before MATWRITE executed. You are in danger of simultaneously<br />
updating a record being updated by another user.<br />
-2 The record was not locked before MATWRITE executed.<br />
STATUS Function Return Values<br />
COMMON RECEIPTS(12)<br />
MATWRITE RECEIPTS ON REC87,"RENTALS"
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DIM, INMAT, MAT, MATBUILD, MATPARSE, MATREAD, MATREADL,<br />
MATREADU, MATWRITEU<br />
MATWRITE 1-461
MATWRITEU<br />
Syntax<br />
MATWRITEU dim.array {ON | TO} [file.var,] record.ID.expr<br />
[ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> MATWRITEU command writes successive elements of a dimensioned<br />
array to the corresponding attributes of a specified record. MATWRITEU<br />
does not release locks set by READU, READVU, or MATREADU statements.<br />
Note: <strong>UniBasic</strong> locks are advisory only. For more information, see Developing<br />
<strong>UniBasic</strong> Applications.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-462 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
dim.array Specifies the dimensioned array from which to assign the values read<br />
to the successive attributes of the record record.ID.expr.<br />
You must name and dimension an array before you can use it in the<br />
MATWRITE statement.<br />
ON | TO file.var, Specifies the target file. You must specify an ON or TO clause.<br />
record.ID.exp Specifies the target record.<br />
ON ERROR<br />
statements<br />
Specifies statements to execute if MATWRITEU fails with a fatal<br />
error because the file is not open, an I/O error occurs, or UniData<br />
cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error occurs,<br />
the program terminates.<br />
MATWRITEU Parameters
STATUS Function Return Values<br />
After you execute MATWRITEU, the STATUS function returns one of the values<br />
described in the following table.<br />
Value Meaning<br />
0 The record was locked before MATWRITEU executed. You are in danger of<br />
simultaneously updating a record being updated by another user.<br />
-2 The record was not locked before MATWRITEU executed.<br />
STATUS Function Return Values<br />
Example<br />
In the following example, the program statement writes the dimensioned array<br />
NEW.CLIENTS to the file CLIENTS as a record with an ID of ‘050887’. If the record<br />
is locked, UniData maintains the lock.<br />
MATWRITEU NEW.CLIENTS TO CLIENTS,'050887'<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DIM, INMAT, MAT, MATBUILD, MATPARSE, MATREAD, MATREADL,<br />
MATREADU, MATWRITE<br />
MATWRITEU 1-463
MAXIMUM<br />
Syntax<br />
MAXIMUM(dyn.array.var)<br />
Description<br />
The <strong>UniBasic</strong> MAXIMUM function returns the largest numeric value found in a<br />
dynamic array. This function ignores nonnumeric elements. If the array you specify<br />
contains only nonnumeric elements, MAXIMUM returns an empty string. If an<br />
element is empty, UniData treats it as 0.<br />
UniData treats all system marks (attribute, value, and subvalue marks)<br />
indiscriminately. That is, any value between two marks of any kind is taken as an<br />
element with respect to this function.<br />
Examples<br />
In the following example, the program segment prints 22:<br />
1-464 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
X = "12":@VM:"2":@FM:"dd":@FM:"9":@FM:"22"<br />
PRINT MAXIMUM(X)<br />
In the next example, the program segment prints 0 because W contains an empty<br />
element and no other numeric elements exist:<br />
W = "A":@FM:"B":@VM:"":@SM:"C"<br />
PRINT MAXIMUM(W)<br />
Related Command<br />
<strong>UniBasic</strong><br />
MINIMUM
MBLEN<br />
Syntax<br />
MBLEN (str.expr)<br />
Description<br />
The <strong>UniBasic</strong> MBLEN function returns the number of bytes in the first character of<br />
a string.<br />
Example<br />
The following figure illustrations a string that indicates below each “character” the<br />
number of bytes required to display that character. MBLEN returns 2 for this string,<br />
which indicates that the first character is made up of two bytes.<br />
Number<br />
of bytes<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
2 3 1 2<br />
BYTELEN, CHARLEN, DISPLAYWIDTH, ISMB, LEN<br />
MBLEN 1-465
MDPERFORM<br />
Syntax<br />
MDPERFORM str.expr [CAPTURING, dyn.array.var]<br />
[RETURNING, dyn.array.var] [RTNLIST int.expr] [PASSLIST int.expr]<br />
[PASSCOM]<br />
MDPERFORM str.expr [RETURNING, dyn.array.var]<br />
[CAPTURING, dyn.array.var] [RTNLIST int.expr] [PASSLIST int.expr]<br />
[PASSCOM]<br />
Description<br />
The <strong>UniBasic</strong> MDPERFORM command executes various UniData commands,<br />
sentences, or paragraphs within a <strong>UniBasic</strong> program while transferring lists to and<br />
from the executed commands.<br />
You can nest MDPERFORM. For example, in program A an MDPERFORM<br />
statement, which has a “CAPTURING var1” clause, invokes program B. Program B<br />
contains a second MDPERFORM statement that also has a “CAPTURING var2”<br />
clause. The output of programs A and B is sent to var1 and var2 respectively.<br />
You can nest only two MDPERFORM statements. To increase the number of nested<br />
levels:<br />
For the entire system – Enter a higher number for the udtconfig file variable<br />
MAX_CAPT_LEVEL.<br />
For this process only – Enter a higher number for the environment variable<br />
MAX_CAPT_LEVEL.<br />
Note: MDPERFORM does not pass select lists unless you explicitly specify them. In<br />
this way, you maintain full control and protection over them.<br />
STACKCOMMON<br />
The ECL STACKCOMMON command makes use of common areas more flexible,<br />
although it requires additional memory. STACKCOMMON settings have the<br />
following effects:<br />
1-466 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
If STACKCOMMON is off when one program executes another, the<br />
unnamed common is passed to the executed program and back to the<br />
executing program.<br />
If STACKCOMMON is on when one program executes another program,<br />
unnamed common is not passed to the program you execute. Instead,<br />
unnamed common is saved, and the unnamed common of the called<br />
program is initialized to 0. When control is passed back to the calling<br />
program, unnamed common is restored to its value before the program call.<br />
Unnamed common is never passed to a phantom program.<br />
Note: STACKCOMMON is always on in BASICTYPEs P and M. The default setting<br />
for STACKCOMMON is off in BASICTYPEs R and U.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
str.expr Specifies a UniData command with appropriate parameters. If you pass<br />
a file name to MDPERFORM, you must use the actual file name, not a<br />
file variable (which is assigned in the OPEN statement).<br />
CAPTURING,<br />
dyn.array.var<br />
RETURNING,<br />
dyn.array.var<br />
The CAPTURING clause stores the output in a dynamic array instead<br />
of on the display terminal. Each line of the text becomes an attribute in<br />
the array. Output sent to the printer is not affected by this clause.<br />
The RETURNING clause captures error messages resulting from the<br />
command executed with MDPERFORM. This variable contains a<br />
string of error message numbers separated by spaces. If the executed<br />
command creates a spooler hold file, UniData also returns the hold file<br />
number in the same variable.<br />
MDPERFORM Parameters<br />
MDPERFORM 1-467
Parameter Description<br />
Examples<br />
In the following example, the program segment lists all the items in the VOC file and<br />
returns the result in select list 2:<br />
1-468 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
RTNLIST int.expr The RTNLIST clause must evaluate to an integer 0–9, designating the<br />
list to return to the calling program. You can use the resulting list with<br />
subsequent READNEXT statements or in the PASSLIST clause of a<br />
MDPERFORM statement. If you do not include an expression after<br />
RTNLIST, the generated list replaces the contents of list 0. If you do not<br />
specify RTNLIST, the MDPERFORM command does not return a list.<br />
PASSLIST<br />
int.expr<br />
The PASSLIST clause must evaluate to an integer 0, 1, or 2,<br />
designating the select list to be sent to the called program. If you do not<br />
specify int.expr, UniData assumes list 0.<br />
The passed list can be the result of previous SELECT or GETLIST<br />
commands, or the RTNLIST clause of an MDPERFORM statement.<br />
PASSCOM This parameter is provided for backward compatibility for releases<br />
before 3.1.<br />
MDPERFORM Parameters (continued)<br />
list_var = 2<br />
MDPERFORM "list dict VOC all" RTNLIST list_var<br />
In the next example, the program segment performs a selection on the CUSTOMER<br />
file, passes the result back in select list 1, and then sorts the result:<br />
list_var = 1<br />
cmd1 = "select CUSTOMER with @ID = '200'"<br />
cmd2 = "sort CUSTOMER by DATE_OUT"<br />
MDPERFORM cmd1 RTNLIST list_var<br />
MDPERFORM cmd2 PASSLIST list_var
In the next example, the program segment builds different commands based on<br />
conditions generated by MDPERFORM. According to the value of input_var, one of<br />
three UniQuery commands is executed.<br />
list_var = 1<br />
frg1 = "select CUSTOMER with "<br />
frg2 = " NAME like '...Jones...' "<br />
frg3 = " DATE_DUE > '04/22/87' "<br />
frg4 = " AMT_DUE < 30"<br />
frg5 = " by NAME"<br />
BEGIN CASE<br />
CASE input_var = 1<br />
MDPERFORM frg1:frg2:frg5 RTNLIST list_var<br />
CASE input_var = 2<br />
MDPERFORM frg1:frg3:frg5 RTNLIST list_var<br />
CASE input_var = 3<br />
MDPERFORM frg1:frg4:frg5 RTNLIST list_var<br />
END CASE<br />
In the next example, the program segment performs the command stored in cmd3,<br />
passing the list specified by list_var, and sends output to a dynamic array cpt_var:<br />
MDPERFORM cmd3 PASSLIST list_var CAPTURING cpt_var<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
COMMON, EXECUTE, EXECUTESQL, PCPERFORM, UDTEXECUTE<br />
UniData<br />
STACKCOMMON – For more information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
MDPERFORM 1-469
MINIMUM<br />
Syntax<br />
MINIMUM(dyn.array.var)<br />
Description<br />
The <strong>UniBasic</strong> MINIMUM function returns the smallest numeric element found in a<br />
dynamic array.<br />
UniData ignores nonnumeric elements with this function. If dyn.array.var contains<br />
only nonnumeric elements, the function returns an empty string. If an array element<br />
is empty, it is treated as 0.<br />
All system marks (attribute, value, and subvalue marks) are treated indiscriminately.<br />
That is, any value between two marks is taken as an element.<br />
Examples<br />
In the following example, the program segment prints 2:<br />
1-470 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
X = "12":@VM:"2":@AM:"dd":@AM:"9":@AM:"22"<br />
PRINT MINIMUM(X)<br />
In the next example, the program segment assigns U an empty string because V<br />
contains only nonnumeric elements:<br />
V = "":@AM:"assignment":@AM:"test"<br />
U = MINIMUM(V)<br />
Related Command<br />
<strong>UniBasic</strong><br />
MAXIMUM
MOD<br />
Syntax<br />
MOD(num.expr1, num.expr2)<br />
Synonym<br />
REM<br />
Description<br />
The <strong>UniBasic</strong> MOD and REM functions return the remainder of the division of<br />
num.expr2 into num.expr1. These functions divide integers and decimals. The sign of<br />
the result is the same as that of num.expr1.<br />
The formula used by MOD and REM is:<br />
REM(x,y) = x - (INT(x/y) * y)<br />
where x and y are numeric expressions. The first expression, x, is divided by y, and<br />
INT truncates the result. UniData multiplies the resulting integer by y, and subtracts<br />
the result from the value of x.<br />
Note: The value of num.expr2 cannot be 0.<br />
Example<br />
In the following example, the program segment assigns to Z the remainder of the<br />
division of Y into X. In this case, the remainder is 2.<br />
X = 12 ; Y = 5<br />
Z = MOD(X,Y)<br />
MOD 1-471
NE<br />
Syntax<br />
expr1 NE expr2<br />
Synonyms<br />
#, , ><<br />
Description<br />
The <strong>UniBasic</strong> NE relational operator tests whether expression expr1 is not equal to<br />
expr2.<br />
expr1 and expr2 can be any valid <strong>UniBasic</strong> expressions, variables, strings, or literals.<br />
Tip: You can also use the # symbol to negate other relational operators. For example,<br />
the following statement uses the # symbol to negate the > symbol. In this case, if X is<br />
not greater than Y, the program branches to label 1000.<br />
IF X #> Y THEN GOSUB 1000<br />
Examples<br />
The following program segment is taken from the sample program in Appendix A,<br />
“Sample Program,” in Developing <strong>UniBasic</strong> Applications. In the first statement, if<br />
the variable NEW.PRICE is not equal to an empty string, the variable is written to the<br />
seventh element in array ORDER.REC.<br />
1-474 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
IF NEW.PRICE NE '' AND NUM(NEW.PRICE) THEN<br />
ORDER.REC = NEW.PRICE<br />
NEED.TO.WRITE = 1<br />
END
Related Command<br />
<strong>UniBasic</strong><br />
NES<br />
NE 1-475
NEG<br />
Syntax<br />
NEG(expr)<br />
Description<br />
The <strong>UniBasic</strong> NEG function changes the value of expr to its opposite sign. If the<br />
value of expr is positive, NEG returns a negative value. If the value of expr is<br />
negative, NEG returns a positive value.<br />
Example<br />
In the following example, the program segment changes the value of variable A to a<br />
negative number and prints -1:<br />
A = 1<br />
A = NEG(A)<br />
PRINT A<br />
Related Command<br />
<strong>UniBasic</strong><br />
ABS<br />
1-476 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
NES<br />
Syntax<br />
NES(array1, array2)<br />
Description<br />
The <strong>UniBasic</strong> NES function compares each value in array1 to its corresponding<br />
value in array2. UniData returns an array with a one in each position where the value<br />
in array1 is not equal to the value in the corresponding position in array2, and a zero<br />
in each position for values that are equal to array2.<br />
Example<br />
In the following example, the program segment compares ARRAY1 to ARRAY2 and<br />
returns ARRAY3. ARRAY3 now contains 0}0}0}1}1.<br />
ARRAY1 = 10:@VM:20:@VM:30@VM:40:@VM:50<br />
ARRAY2 = 10:@VM:20:@VM:30:@VM:50:@VM:60<br />
ARRAY3 = NES(ARRAY1,ARRAY2)<br />
NES 1-477
NFAUSER<br />
Syntax<br />
NFAUSER(“username”, “password”)<br />
Description<br />
Beginning at UniData 5.0, a Network File Access (NFA) connection from an NFA<br />
client requires a valid user name and password. If the client connection is made<br />
through udtelnet, this information is available and passed to the NFA server for<br />
connecting. If the session is a console session, the system prompts for the user name<br />
and password when a connection is requested, such as when you OPEN the first NFA<br />
file on a database.<br />
<strong>UniBasic</strong> now provides the NFAUSER function which enables you to set the user<br />
name and password in a <strong>UniBasic</strong> program.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
After running this function and providing a valid user name and password combination,<br />
an NFA connection no longer prompts for this information, regardless if it is<br />
from the console or via udtelnet. NFAUSER does not validate the user<br />
name/password combination, but registers them in an internal variable for later use.<br />
1-478 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
username A valid user name on the NFA server to which you are connecting.<br />
password The password corresponding to username.<br />
NFAUSER Parameters
NOCONVERT<br />
Syntax<br />
NOCONVERT {OFF | ON}<br />
Description<br />
The <strong>UniBasic</strong> NOCONVERT command controls the conversion of the special<br />
character CHAR(0). The following <strong>UniBasic</strong> commands read and write non-UniData<br />
files or tapes and convert CHAR(0) to CHAR(128) on input. They also convert<br />
CHAR(128) to CHAR(0) on output. This can cause problems under some circumstances,<br />
especially if you use the character CHAR(128) in an application or in stored<br />
data. NOCONVERT provides a way of switching the conversion OFF or ON. The<br />
default is OFF.<br />
The following <strong>UniBasic</strong> commands convert CHAR(0) and CHAR(128) when<br />
NOCONVERT is turned on:<br />
OSBREAD, OSBWRITE, OSREAD, OSWRITE, READT, WRITET<br />
Note: The PRINT and CRT functions do not work with strings that contain CHAR(0).<br />
Warning: Do not use <strong>UniBasic</strong> READ and WRITE commands to open or modify<br />
binary data in DIR-type files (for example, BP). Doing so can corrupt data in the file.<br />
Instead, use OSREAD or OSBREAD after executing the <strong>UniBasic</strong> NOCONVERT<br />
command.<br />
The following functions work with strings containing CHAR(0), regardless of the<br />
setting of the NOCONVERT command:<br />
Assignment (X = Y)<br />
Bracket function ([])<br />
Substring assignment (A[1,3] = B)<br />
String concatenation (A:B)<br />
CHAR<br />
CONVERT<br />
COUNT<br />
NOCONVERT 1-479
DCOUNT<br />
INDEX<br />
LEN<br />
SEQ<br />
SWAP<br />
1-480 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
NOT<br />
Syntax<br />
NOT(expr)<br />
Description<br />
The <strong>UniBasic</strong> NOT Boolean operator inverts the logical result of the argument expr.<br />
If the expression is true, the function returns 0 (false). If the expression is not true,<br />
the function returns 1 (true).<br />
Example<br />
In the following example, the program segment compares X to Y (false because X is<br />
not greater than Y) and inverts the result, evaluating to true instead. Next, the THEN<br />
statement executes, sending program control to the label specified by RETRY.<br />
X = 1 ; Y = 2<br />
IF NOT(X > Y) THEN GOSUB RETRY:<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
#, NOTS<br />
NOT 1-481
NOTS<br />
Syntax<br />
NOTS(dyn.array)<br />
Description<br />
The <strong>UniBasic</strong> NOTS Boolean operator inverts the logical result of each element of a<br />
dynamic array. If the element is true, the operator returns 0 (false) in the corresponding<br />
position of the new array. If the expression is not true, the operator returns<br />
1 (true) in the corresponding position of the new array.<br />
Example<br />
In the following example, the program segment evaluates the dynamic array A,<br />
inverts each result of the evaluation, and returns the results in a corresponding array.<br />
B now contains 0}1}0}0.<br />
A = 1:@FM:0:@FM:1:@FM:30<br />
B = NOTS(A)<br />
1-482 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
NULL<br />
Syntax<br />
NULL<br />
Description<br />
The <strong>UniBasic</strong> NULL command acts as a dummy statement. You can use the NULL<br />
statement anywhere a statement is required.<br />
Tip: Use NULL when a statement or command clause is mandatory, but you do not<br />
want to initiate any action.<br />
Example<br />
In the following example, if the length of the variable NAME$ is zero, the program<br />
prints nothing:<br />
PRINT "NAME: ": ; INPUT NAME$<br />
BEGIN CASE<br />
CASE LEN(NAME$) = 0<br />
NULL<br />
CASE LEN(NAME$) > 0<br />
PRINT "HI, ":NAME$<br />
END CASE<br />
NULL 1-483
NUM<br />
Syntax<br />
NUM(expr)<br />
Description<br />
The <strong>UniBasic</strong> NUM function determines if an expression is numeric. If expr is<br />
numeric, NUM returns 1. Otherwise, it returns 0. expr can be any valid <strong>UniBasic</strong><br />
expression. The NUM function returns 0 for any multibyte character.<br />
With null value handling on, this function returns 1 for the null value.<br />
The nonnumeric characters in the following table produce a result of 1.<br />
Examples<br />
In the following example, the program segment prints 0 because VAR contains alphabetic<br />
characters:<br />
VAR = 'ABC'<br />
PRINT NUM(VAR)<br />
In the next example, the program segment prints 1 because VAR contains an integer:<br />
VAR = -123<br />
PRINT NUM(VAR)<br />
1-484 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Character Description<br />
+ Plus sign<br />
- Negative sign<br />
. Decimal point<br />
Nonprinting Null value<br />
Nonnumeric Characters
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
ALPHA, ICONV Masked Character (MC), NUMS, OCONV Masked Character<br />
(MC)<br />
NUM 1-485
NUMS<br />
Syntax<br />
NUMS(dyn.array)<br />
Description<br />
The <strong>UniBasic</strong> NUMS function determines, for each element of an array, if that<br />
element is numeric. If the element is numeric, NUM returns 1 in the corresponding<br />
position of the new array. For nonnumeric and multibyte characters, it returns 0.<br />
With null value handling on, this function returns 1 for the null value.<br />
The nonnumeric characters in the following table produce a result of 1.<br />
Example<br />
In the following example, the program segment determines whether each element of<br />
array CHARACTERS is numeric. The resulting array B contains 1}1}1}0}0.<br />
1-486 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Character Description<br />
+ Plus sign<br />
- Negative sign<br />
. Decimal point<br />
Nonprinting Null value<br />
Nonnumeric Characters<br />
CHARACTERS = 123:@FM:456:@FM:-789:@FM:"ABC":@FM:"CDE"<br />
B = NUMS(CHARACTERS)
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
ICONV Masked Character (MC), OCONV Masked Character (MC)<br />
NUMS 1-487
OCONV<br />
Syntax<br />
OCONV(expr, conv.code.expr)<br />
Description<br />
The <strong>UniBasic</strong> OCONV function converts string or numeric data from internal format<br />
to display format based on conversion codes. If the input value or conversion code is<br />
invalid, UniData returns the input value. OCONV supports multibyte languages.<br />
Note: In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
The following table summarizes the valid conversion codes. A detailed discussion of<br />
each follows under separate headings.<br />
1-487 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
expr Specifies the expression, a string or numeric data, to convert.<br />
conv.code.expr Specifies an internal representation format to use when converting expr.<br />
OCONV Parameters<br />
Code Format<br />
D System date.<br />
G Extracts one or more strings separated by a delimiter.<br />
L Length.<br />
MB Binary.<br />
OCONV Codes
Related Command<br />
<strong>UniBasic</strong><br />
ICONV<br />
Code Format<br />
MC Masked character.<br />
MD Masked decimal.<br />
ML Left-justify.<br />
MP Packed decimal.<br />
MP1 Convert to packed decimal without truncating at the first CHAR(0) or<br />
altering this character.<br />
MO Octal.<br />
MR Right-justify.<br />
MT System time.<br />
MX Hexadecimal.<br />
P Pattern match.<br />
R Range.<br />
S SOUNDEX.<br />
T Text extraction.<br />
Tfile File translation.<br />
OCONV Codes (continued)<br />
OCONV 1-488
OCONV Date (D)<br />
Syntax<br />
OCONV(integer.exp, "D [y] [c] [fmt]")<br />
Description<br />
The OCONV date (D) function converts an integer in internal date format to date<br />
display format. If the input value or conversion code is invalid, UniData returns the<br />
input value. UniData ignores leading zeros in the input date.<br />
Note: The internal format of the date is the number of days before or after December<br />
31, 1967. Days before are represented as negative numbers.<br />
With UDT.OPTIONS 4 on, this command converts the text of dates to uppercase. For<br />
example, May 13 is converted to MAY 13.<br />
With UDT.OPTIONS 29 on, this command converts Sunday to 7 instead of 0. For<br />
information about UDT.OPTIONS, see the UDT.OPTIONS <strong>Commands</strong> <strong>Reference</strong>.<br />
In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on and the<br />
input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-489 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
integer.exp Indicates a date in internal format.<br />
OCONV Date (D) Parameters
Parameter Description<br />
y Number of digits to represent the year in the formatted date.<br />
c Delimiter separating day, month, and year. Can be a space, slash, period,<br />
comma, hyphen, or asterisk.<br />
fmt Format for date display. The following formats are available:<br />
mm dd yy[yy]<br />
day month year<br />
yy[yy] mm dd<br />
Combine the output format codes in the following table to format the date.<br />
The syntax for format codes is the following:<br />
[D | W | WA] [ [M] [Y] | Q | QA]] [J] [[,] {An | Zn} [[,] {An | Zn}...]<br />
Format Codes<br />
OCONV Date (D) Parameters (continued)<br />
The following table describes the valid output format codes.<br />
Code Description<br />
D Includes day in the output date.<br />
M Includes month in the output date.<br />
Y Includes year in the output date.<br />
Q Converts to quarter numeric format.<br />
QA Converts to quarter alphabetic format.<br />
W Valid for day only. Specifies numeric format.<br />
WA Valid for day only. Specifies alphabetic format.<br />
OCONV Date Output Format Codes<br />
OCONV Date (D) 1-490
Note: Following SMA standards, Monday is the first day of the week (1). If<br />
UDT.OPTIONS 29 is on, Sunday converts to 7 instead of 0.<br />
STATUS Function Return Values<br />
After you execute OCONV D, the STATUS function returns one of the values<br />
described in the following table.<br />
Examples<br />
The following statements are taken from the sample program in Appendix A,<br />
“Sample Program,” in Developing <strong>UniBasic</strong> Applications. It converts the date stored<br />
in internal format in the ORDERS file. The formatted date is in MM/DD/YYYY<br />
format.<br />
1-491 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Code Description<br />
An Valid for day, quarter, and month only (WAn, QAn, and<br />
MAn respectively). A specifies alphabetic format, and n<br />
indicates number of characters.<br />
Zn Valid for month and day only. Z specifies numeric format;<br />
and n indicates number of digits. Z without a digit and Z0<br />
suppress zeros.<br />
J Displays the Julian date (the number of days since<br />
January 1).<br />
OCONV Date Output Format Codes (continued)<br />
Value Description<br />
0 Successful conversion of a valid date.<br />
1 The input date was invalid.<br />
2 The conversion code was invalid.<br />
STATUS Function Return Values<br />
ORDER_DATE = OCONV(ORDER.REC,"D4/")
In the following example, the program statement prints a three-character month<br />
name, a numeric day, and a four-digit year (suppressing zeros if necessary):<br />
PRINT OCONV(ORDER.REC, "DMDYA3,Z,Z4")<br />
In the following example, the program statement prints J 1970 4:<br />
PRINT OCONV(732,"dmywa1z3")<br />
Some sample format codes are applied in the following table.<br />
Input Value Conversion Code Output<br />
744 DDMY 13 Jan 1970<br />
744 DMDY 01 13 1970<br />
1006 D 02 Oct 1970<br />
1006 DDMY 02 10 1970<br />
1006 DDMYZ0,Z,Z 2 10 1970<br />
0 D4/ 12/31/1967<br />
7334 D 29 Jan 1988<br />
7334 DDMY,A,Z4 29 January 1988<br />
7334 DDMY,A3 29 Jan 1988<br />
7334 DDMY 29 01 1988<br />
7334 DD 29<br />
7334 DM 01<br />
7334 DW 5<br />
7334 DWA Friday<br />
7334 DQ 1<br />
7334 DQA Winter<br />
7334 DJY 029 1988<br />
OCONV Date Examples<br />
OCONV Date (D) 1-492
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DATE, ICONV Date (D), TIMEDATE<br />
UniData<br />
DATE, DATE.FORMAT, SET.TIME – For information, see the UniData <strong>Commands</strong><br />
<strong>Reference</strong>.<br />
1-493 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
OCONV Group (G)<br />
Syntax<br />
OCONV(str.expr, "G[m]x n")<br />
Description<br />
The OCONV group (G) function extracts one or more strings separated by a<br />
delimiter. If the input value or conversion code is invalid, UniData returns the input<br />
value.<br />
Note: In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Paramete<br />
r Description<br />
str.exp Indicates a string separated by a delimiter.<br />
m Indicates the number of strings to skip. If m is omitted, no strings are skipped.<br />
x Specifies any single nonnumeric character to be the delimiter. UniData system<br />
delimiters are valid. Hyphen or minus sign is not valid.<br />
n The number of strings to be extracted.<br />
OCONV Group (G) Parameters<br />
Example<br />
In the following example, the program segment prints (303):<br />
X = "(303)+555+0988"<br />
PRINT OCONV(X,"G0+1")<br />
OCONV Group (G) 1-494
Related Command<br />
<strong>UniBasic</strong><br />
ICONV Group (G)<br />
1-495 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
OCONV Length (L)<br />
Syntax<br />
OCONV(str.expr, "Ln[,m]")<br />
Description<br />
The OCONV length (L) function extracts a string of a specified length or that falls<br />
within a range of acceptable lengths. If the input value or conversion code is invalid,<br />
UniData returns the input value.<br />
Note: In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
str.exp Indicates a string to be searched.<br />
n Specifies the number of characters the string must match to be extracted.<br />
When m is present, n is the shortest string to be extracted.<br />
m Specifies the longest string to be extracted.<br />
OCONV Length (L) Parameters<br />
Example<br />
In the following example, the program segment prints “123” and an empty string<br />
because X has fewer than five characters and more than three:<br />
X = 123; Y = 456789<br />
PRINT OCONV(X,"L3,5")<br />
PRINT OCONV(Y,"L3,5")<br />
OCONV Length (L) 1-496
Related Command<br />
<strong>UniBasic</strong><br />
ICONV Length (L)<br />
1-497 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
OCONV Masked Character (MC)<br />
Syntax<br />
OCONV(str.expr, "MC [A | /A | B | /B | C;x;y | U | L | T | N | /N | P | X[D] | D | D[X]<br />
| X]")<br />
Description<br />
The OCONV mask character (MC) function converts alphabetic characters to<br />
uppercase or lowercase, or extracts alphabetic or numeric characters from strings.<br />
This function performs the same conversions and extractions as ICONV MC. If the<br />
input value or conversion code is invalid, UniData returns the input value.<br />
Note: In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
str.expr The expression to be searched or converted.<br />
A Extracts all alphabetic characters.<br />
/A Extracts all nonalphabetic characters.<br />
B Extracts all alphabetic and numeric characters.<br />
/B Extracts all special characters (not alphabetic nor numeric).<br />
C;x;y Converts all occurrences of substring x to substring y.<br />
U Converts data to uppercase.<br />
L Converts characters to lowercase.<br />
OCONV Masked Character (MC) Parameters<br />
OCONV Masked Character (MC) 1-498
Parameter Description<br />
Examples<br />
The following subroutine is taken from the sample program in Appendix A, “Sample<br />
Program,” in Developing <strong>UniBasic</strong> Applications. The subroutine converts user input<br />
to uppercase, then compares that input with Q to determine if the user is ready to quit<br />
the application. The user can enter any string starting with Q or q, or an order number.<br />
1-499 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
T Converts to initial cap style. First letter of each word is uppercase, and all<br />
other letters are lowercase. Space and tab are considered word separators.<br />
N Extracts all numeric characters (0-9).<br />
/N Extracts all nonnumeric characters.<br />
P Converts all nonprinting characters to tildes (~).<br />
X[D] or D Assumes input is in hexadecimal; converts to decimal.<br />
D[X] or X Converts input to hexadecimal.<br />
OCONV Masked Character (MC) Parameters (continued)<br />
GET_ORDER_NUMBER:<br />
* Have the user enter a valid key to a record in the ORDERS file.<br />
LOOP<br />
DISPLAY @(15,6):<br />
INPUT ORDER_NUMBER<br />
ORDER_NUMBER = OCONV(ORDER_NUMBER,"MCU")<br />
IF NUM(ORDER_NUMBER) OR ORDER_NUMBER[1,1] = "Q" THEN<br />
VALID_ORDER_NUMBER = 1<br />
END ELSE<br />
VALID_ORDER_NUMBER = 0<br />
MESSAGE = "Order # must be a Number, or the letter 'Q'"<br />
CALL DISPLAY_MESSAGE(MESSAGE)<br />
END<br />
UNTIL VALID_ORDER_NUMBER<br />
REPEAT<br />
The following statement, taken from the same sample program, extracts the numbers<br />
from user input. This use of OCONV removes the special characters the user might<br />
have entered in a formatted date. For example, the statement extracts 1234 from<br />
$12.34.<br />
NEW.PRICE = OCONV(NEW.PRICE,"MCN")
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
ALPHA, CONVERT, DOWNCASE, ICONV Masked Character (MC), NUM,<br />
UPCASE<br />
OCONV Masked Character (MC) 1-500
OCONV Masked Decimal (MD)<br />
Syntax<br />
OCONV(num.expr, "MDn [f] [ [ [prefix], [thsnd_mark], [dec_symbl], [suffix] ] ]<br />
[,] [$] [- | < | E | C | D] [P] [Z] [T] [xc]")<br />
Description<br />
The OCONV masked decimal (MD) function scales, rounds, and formats a number<br />
for display with up to nine decimal places. num.expr can be any numeric value. If the<br />
input value or conversion code is invalid, UniData returns the input value.<br />
Note: In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or the conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Some parameters set the same values. Results are unpredictable if you make<br />
conflicting assignments.<br />
Parameter Description<br />
1-501 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
num.expr Indicates a number to be formatted.<br />
n Sets precision (the number of decimal places represented). It can be a<br />
number between 0 and 9. If n is less than the number of decimal points in the<br />
input data, the resulting value is rounded.<br />
f Scales the input value num.expr by moving the decimal point f places to the<br />
left. If omitted, f defaults to the value assigned to n (for example, if you<br />
specify MD2, UniData reads it as MD22).<br />
OCONV Masked Decimal (MD) Parameters
Parameter Description<br />
prefix],<br />
[thsnd_mark]<br />
,<br />
[dec_symbl],<br />
[suffix]<br />
The square brackets enclosing these parameters are required.<br />
prefix – Nonnumeric character(s) to precede the formatted number. For<br />
example, MD2[**] produces "**nnn...".<br />
thsnd_mark – Nonnumeric character(s) to delimit thousands. To specify a<br />
comma, enclose it in single quotation marks, and then use double quotation<br />
marks to enclose the conversion code. For example, " MD2[,',' ]" produces<br />
"...,nnn,nnn".<br />
dec_symbl – Alternate symbol to represent the decimal point.<br />
suffix – Nonnumeric character(s) to follow the formatted number. For<br />
example, MD2[, , ,**] produces "...nnn**".<br />
, Inserts commas to separate thousands, millions, and so forth.<br />
$ Precedes the output with a dollar sign ($).<br />
- Specifies the negative sign (for negative data) to precede negative numbers.<br />
< or E Specifies that negative data is surrounded by brackets.<br />
C Specifies that negative data is followed by CR, indicating a credit.<br />
D Specifies that negative data is followed by DB, indicating a debit.<br />
P Specifies that no scaling is performed if a decimal is present in the input<br />
value.<br />
Z Specifies that zeros are to be suppressed.<br />
T Specifies that the number is to be truncated, not rounded to the number of<br />
decimal places specified in n.<br />
xc Specifies that the character c is used to fill spaces left to the left of the<br />
number after output data is formatted. x indicates the size of the mask.<br />
OCONV Masked Decimal (MD) Parameters (continued)<br />
OCONV Masked Decimal (MD) 1-502
Examples<br />
The following table describes some OCONV masked decimal conversion codes and<br />
their results.<br />
The following statement is taken from the sample program in Appendix A, “Sample<br />
Program,” in Developing <strong>UniBasic</strong> Applications. It converts the price stored in<br />
internal format in the ORDERS file for display, including two decimal places,<br />
commas separating thousands of dollars, preceded by a dollar sign.<br />
1-503 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
PRICE = OCONV(ORDER.REC,"MD2$,")<br />
Related Command<br />
<strong>UniBasic</strong><br />
Input Code Result<br />
12.339 MD3 0.012<br />
12.339 MD32 0.123<br />
1234 MD2,$ $12.34<br />
-1234 MD2$,- <br />
912391 MD2$,D $9,123.91DB<br />
456789 MD2$,11* $**4,567.89<br />
123.456 MD24P 123.46<br />
11111112339 MD12[@,*,,%] @111*111*123.4%<br />
OCONV Masked Decimal (MD) Examples<br />
ICONV Masked Decimal (MD)
OCONV Left Justify (ML)<br />
Syntax<br />
OCONV(str.expr, "MLn [f] [ [ [prefix], [thsnd_mark], [dec_symbl], [suffix] ] ] [,] [$]<br />
[C] [Z] [(mask)]")<br />
Description<br />
The OCONV left justify (ML) function scales, rounds, and formats a number, or leftjustifies<br />
it in a mask. str.expr can be any valid text or a numeric value with or without<br />
a decimal. If the input value or conversion code is invalid, UniData returns the input<br />
value.<br />
Note: The OCONV ML and MR functions produce the same output. However,<br />
formatting differs slightly in the following way: if a mask is specified that is larger<br />
than the formatted number, UniData left- or right-justifies the number within a<br />
“column” the width of the mask.<br />
In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on and the<br />
input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Note: Some parameters set the same values. Results are unpredictable if you make<br />
conflicting assignments.<br />
Parameter Description<br />
str.expr Indicates a text string or number to be left-justified and formatted.<br />
n Sets precision (number of decimal places represented). It can be a<br />
number from 0 through 9. If n is less than the number of decimal points<br />
in the input data, the resulting value is rounded.<br />
f Scales the input value num.expr by moving the decimal point f places to<br />
the left. If omitted, f defaults to the value assigned to n (for example, if<br />
you specify ML2, UniData reads it as ML22).<br />
OCONV Left Justify (ML) Parameters<br />
OCONV Left Justify (ML) 1-504
Parameter Description<br />
[ [prefix],<br />
[thsnd_mark],<br />
[dec_symbl],<br />
[suffix] ]<br />
Examples<br />
In the following statement, UniData moves the decimal three places to the left<br />
(0.012339), rounds to three decimal places, and then prints 0.012:<br />
PRINT OCONV("12.339","ML3")<br />
In the following statement, UniData moves the decimal two places to the left<br />
(0.12339), rounds to three decimal places, and then prints 0.123:<br />
1-505 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
The square brackets enclosing these parameters are required.<br />
prefix – Nonnumeric character(s) to precede the formatted number. For<br />
example, ML2[**] produces "**nnn...".<br />
thsnd_mark – Nonnumeric character(s) to delimit thousands. To specify<br />
a comma, enclose it in single quotation marks, and then use double<br />
quotation marks to enclose the conversion code. For example, " ML2[,','<br />
]" produces "...,nnn,nnn".<br />
dec_symbl – Alternate symbol to represent the decimal point.<br />
suffix – Nonnumeric character(s) to follow the formatted number. For<br />
example, ML2[, , ,**] produces "...nnn**".<br />
, Inserts commas to separate thousands.<br />
$ Precedes the number with a dollar sign ($).<br />
C Specifies negative data to be followed by CR indicating a credit.<br />
Z Suppresses zeros.<br />
mask Specifies a mask to be used for formatting. Use # to represent number<br />
placement. Include special characters as desired.<br />
Results are adversely affected if the mask contradicts other parameters.<br />
For example, placement of the decimal in the mask overrides n.<br />
OCONV Left Justify (ML) Parameters (continued)<br />
PRINT OCONV("12.339","ML32")<br />
In the following example, UniData converts the value 123456789 to 1234-56-789<br />
because it left-justifies it in the mask “####-##-####”:<br />
OUTPUT.VAL = OCONV("123456789","ML(####-##-####)")
In the following example, UniData converts the value 12.339 to 0.012 based on the<br />
ML3 external conversion:<br />
INTERNAL.VAL = OCONV("12.339","ML3")<br />
Related Command<br />
<strong>UniBasic</strong><br />
ICONV Left Justify (ML)<br />
OCONV Left Justify (ML) 1-506
OCONV Packed Decimal (MP)<br />
Syntax<br />
OCONV(expr, "MP")<br />
Description<br />
The OCONV packed decimal (MP) function converts an integer from packed<br />
decimal representation into display format. If the input value or conversion code is<br />
invalid, UniData returns the input value.<br />
Note: In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Related Command<br />
<strong>UniBasic</strong><br />
ICONV Packed Decimal (MP)<br />
1-507 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
OCONV Packed Decimal (MP1)<br />
Syntax<br />
OCONV(expr, MP1)<br />
Description<br />
The OCONV packed decimal (MP1) function converts an integer from packed<br />
decimal representation into its display format without truncating at the first CHAR(0)<br />
character or altering CHAR(0). If the input value or conversion code is invalid,<br />
UniData returns the input value.<br />
Note: In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Related Command<br />
<strong>UniBasic</strong><br />
ICONV Packed Decimal (MP1)<br />
OCONV Packed Decimal (MP1) 1-508
OCONV Right Justify (MR)<br />
Syntax<br />
OCONV(str.expr, "MRn [f] [ [ [prefix], [thsnd_mark], [dec_symbl], [suffix] ] ] [,] [$]<br />
[C] [Z] [(mask)]")<br />
Description<br />
The OCONV right justify (MR) function scales, rounds, and formats a number, or<br />
right-justifies it in a mask. str.expr can be any valid text or a numeric value with or<br />
without a decimal. If the input value or conversion code is invalid, UniData returns<br />
the input value.<br />
Note: The OCONV ML and MR functions produce the same output. However,<br />
formatting differs slightly in the following way: if you specify a mask that is larger<br />
than the formatted number, UniData left- or right-justifies the number within a<br />
“column” the width of the mask.<br />
In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on and the<br />
input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
1-509 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Some parameters set the same values. Results are unpredictable if you make<br />
conflicting assignments.<br />
Parameter Description<br />
str.exp Indicates a text string or number to be right-justified and formatted.<br />
n Sets precision (number of decimal places represented). It can be a<br />
number from 0 through 9. If n is less than the number of decimal points<br />
in the input data, the resulting value is rounded.<br />
f Scales the input value num.expr by moving the decimal point f places<br />
to the left. If omitted, f defaults to the value assigned to n (for example,<br />
if you specify MR2, UniData reads it as MR22).<br />
[prefix],<br />
[thsnd_mark],<br />
[dec_symbl],<br />
[suffix]<br />
The square brackets enclosing these parameters are required.<br />
prefix – Nonnumeric character(s) to precede the formatted number. For<br />
example, MR2[**] produces "**nnn...".<br />
thsnd_mark – Nonnumeric character(s) to delimit thousands. To<br />
specify a comma, enclose it in single quotation marks, and then use<br />
double quotation marks to enclose the conversion code. For example, "<br />
MR2[,',' ]" produces "...,nnn,nnn".<br />
dec_symbl – Alternate symbol to represent the decimal point.<br />
suffix – Nonnumeric character(s) to follow the formatted number. For<br />
example, MR2[, , ,**] produces "...nnn**".<br />
, Inserts commas to separate thousands.<br />
$ Precedes the formatted number with a dollar sign ($).<br />
C Specifies that a negative number is to be followed by CR, indicating a<br />
credit.<br />
Z Suppresses zeros.<br />
mask Specifies a mask to be used for formatting. Use # to represent number<br />
placement. Include special characters as desired.<br />
Results are adversely affected if the mask contradicts other parameters.<br />
For example, placement of the decimal in the mask overrides n.<br />
OCONV Right Justify (MR) Parameters<br />
If the conversion to display format is unsuccessful, UniData returns the original<br />
value.<br />
OCONV Right Justify (MR) 1-510
Examples<br />
In the following statement, UniData moves the decimal three places to the left<br />
(0.012339), rounds to three decimal places, and then prints 0.012:<br />
PRINT OCONV("12.339","MR3")<br />
In the following statement, UniData moves the decimal two places to the left<br />
(0.12339), rounds to three decimal places, and then prints 0.123:<br />
1-511 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
PRINT OCONV("12.339","MR32")<br />
In the following example, UniData converts the value 123456789 to 123-45-6789<br />
because it right-justifies it into the mask “####-##-####”:<br />
OUTPUT.VAL = OCONV("123456789","MR(####-##-####)")<br />
The following example is taken from the sample program in Appendix A, “Sample<br />
Program,” in Developing <strong>UniBasic</strong> Applications. It converts a price stored in internal<br />
format in the ORDERS file to display format, including two decimal places, commas<br />
separating thousands of dollars, and a preceding $.<br />
DISPLAY @(10,9+ENTRY):OCONV(ORDER.REC,"MR2$,"):<br />
The following statement is taken from the same sample program. This statement<br />
displays the price right-justified and formatted with commas separating thousands of<br />
dollars and a preceding $ as in $12,386.34. The right justification aligns data on the<br />
right.<br />
DISPLAY @(10,9+ENTRY):OCONV(ORDER.REC,"MR2$,"):<br />
In the following example, UniData converts the value 123456 to 1,234.56:<br />
OUTPUT.VAL = OCONV("123456","MR2$,")<br />
Related Command<br />
<strong>UniBasic</strong><br />
ICONV Right Justify (MR)
OCONV Time (MT)<br />
Syntax<br />
OCONV(num.expr, "MT [H] [S] [c]")<br />
Description<br />
The OCONV time (MT) function converts the internal time of day from an integer<br />
between 0 and 86400 (the number of seconds in a day) to display format. Time is<br />
output in the following form:<br />
HH MM [SS]<br />
If the input value or conversion code is invalid, UniData returns the input value.<br />
Note: In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
num.expr Indicates a number to be converted.<br />
H Indicates that hours are to be formatted in 12-hour format with a.m. or p.m.<br />
suffixes.<br />
S Indicates that seconds are to be included in the output.<br />
c Specifies a delimiter to be placed between hours, seconds, and fractions of<br />
seconds.<br />
OCONV Time Conversion (MT) Parameters<br />
Note: A program that you can use to try out ICONV and OCONV conversion codes<br />
is provided in Developing <strong>UniBasic</strong> Applications..<br />
OCONV Time (MT) 1-512
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DATE, ICONV Time (MT), TIME, TIMEDATE<br />
1-513 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
OCONV Hex (MX | HEX), Octal (MO), Binary<br />
(MB)<br />
Syntax<br />
OCONV(str.expr, ["HEX | MX [0C] | MO [0C] | MB [0C]"])<br />
Description<br />
The OCONV hex (MX), octal (MO), and binary (MB) functions convert from<br />
decimal or ASCII characters into other numbering systems. If the input value or<br />
conversion code is invalid, UniData returns the input value.<br />
Note: In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
str.exp Specifies the number to convert to an alternate numbering system.<br />
HEX |<br />
MX [0C]<br />
Indicates conversion to hexadecimal (base 16). The optional 0C converts<br />
from ASCII character rather than decimal value. HEX is equivalent to<br />
MX0C.<br />
MO [0C] Indicates conversion to octal (base 8). The optional 0C converts from ASCII<br />
character rather than decimal value.<br />
MB [0C] Indicates conversion to binary (base 2). The optional 0C converts from<br />
ASCII character rather than decimal value.<br />
OCONV Numbering System Conversion Parameters<br />
OCONV Hex (MX | HEX), Octal (MO), Binary (MB) 1-514
The following table indicates which parameters to use with OCONV to convert from<br />
decimal value or ASCII character to other numbering systems.<br />
Examples<br />
The following table demonstrates some OCONV MX, MO, and MB conversion<br />
codes and their results.<br />
1-515 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
From To Function<br />
Decimal value Binary OCONV MB<br />
Decimal value Octal OCONV MO<br />
Decimal value Hexadecimal OCONV MX<br />
ASCII character Binary OCONV MB0C<br />
ASCII character Octal OCONV MO0C<br />
ASCII character Hexadecimal OCONV MX0C<br />
OCONV HEX<br />
OCONV Options for Converting to Alternate Numbering Systems<br />
Input Code Result<br />
SS (ASCII character) MO0C 123123 (octal)<br />
256 (decimal) MX 100 (hexadecimal)<br />
0 (ASCII character) MX 4F (hexadecimal)<br />
5 (decimal) MB 00000101 (binary)<br />
33288 (decimal) MO 101010 (octal)<br />
Qat (ASCII character) MX0C 516174<br />
(hexadecimal)<br />
U (ASCII character) MB0C 01010101 (binary)<br />
OCONV Hex, Octal, and Binary Examples
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CHAR, ICONV Hex (MX | HEX), Octal (MO), Binary (MB), SEQ<br />
OCONV Hex (MX | HEX), Octal (MO), Binary (MB) 1-516
OCONV Pattern Match (P)<br />
Syntax<br />
OCONV(str.expr, "P(op)[;(op).....]")<br />
Description<br />
The OCONV pattern match (P) function checks a string for a match with one of the<br />
patterns or strings specified in op. If the entire string does not match one of the<br />
patterns or strings, UniData returns an empty string. If the input value or conversion<br />
code is invalid, UniData returns the input value. OCONV pattern match performs the<br />
same function as the ICONV pattern match function.<br />
Note: In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Paramete<br />
r Description<br />
1-517 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
str.expr Indicates a string to be searched.<br />
op Specifies the pattern to search for in str.expr.<br />
nN – Integer followed by N tests for that number of numeric characters.<br />
nA – Integer followed by A tests for that number of alpha characters.<br />
nX – Integer followed by X tests for that number of alphanumeric characters.<br />
lit.str – Indicates a literal string to be searched for in str.expr.<br />
; Separates multiple patterns.<br />
OCONV Pattern Match (P) Parameters
Examples<br />
The following statement prints an empty string because the entire input string does<br />
not match a pattern or string specified in op:<br />
PRINT OCONV("abc123","P(3N);(abc)")<br />
The following statement prints “abc” because the input string matches the string<br />
provided in op:<br />
PRINT OCONV("abc","P(3N);(abc)")<br />
OCONV Pattern Match (P) 1-518
OCONV Range (R)<br />
Syntax<br />
OCONV(num.expr, "Rndm[;ndm.....]")<br />
Description<br />
The OCONV range (R) function returns only those data values that fall into a<br />
specified range of decimal values. When including a negative range, you must<br />
specify the highest negative number first. If range specifications are not met, UniData<br />
returns an empty string. If the input value or conversion code is invalid, UniData<br />
returns the input value.<br />
Note: In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-519 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
num.expr Indicates a string to be searched.<br />
n Specifies the smallest number to be extracted.<br />
d Specifies a delimiter separating numbers in a range. Any character except<br />
system delimiters can be used to separate the numbers in a range.<br />
Do not use the minus sign (-) as a delimiter because it refers to a negative<br />
number in the range.<br />
m Specifies the longest string to be extracted.<br />
; Separates multiple ranges.<br />
OCONV Range (R) Parameters
Example<br />
In the following example, the program segment prints “123” and a blank line because<br />
X is within the range and Y is not:<br />
X = 123; Y = 456789<br />
PRINT OCONV(X,"R100,200")<br />
PRINT OCONV(Y,"R100,200")<br />
Related Command<br />
<strong>UniBasic</strong><br />
ICONV Range (R)<br />
OCONV Range (R) 1-520
OCONV SOUNDEX (S)<br />
Syntax<br />
OCONV(str.expr, "S")<br />
Description<br />
The OCONV SOUNDEX (S) function converts string or numeric data to phonetic<br />
format based on SOUNDEX conversion codes. You can use the S conversion code in<br />
a virtual attribute formula. If the input value or conversion code is invalid, UniData<br />
returns the input value.<br />
For more information on SOUNDEX conversion codes, see the SOUNDEX<br />
command.<br />
Note: In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Example<br />
The following example is a virtual attribute (SDX_LNAME) that converts the value<br />
of the variable LNAME to its SOUNDEX expression:<br />
OCONV(LNAME,"S")<br />
1-521 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Parameter Description<br />
str.expr Indicates a string to be converted.<br />
OCONV SOUNDEX (S) Parameters
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
ICONV SOUNDEX (S), SOUNDEX<br />
OCONV SOUNDEX (S) 1-522
OCONV Text Extraction (T)<br />
Syntax<br />
OCONV(str.expr, "T[m,]n")<br />
Description<br />
The OCONV text extraction (T) function extracts a substring from a string. If you<br />
omit m, extraction begins from the rightmost character, and n characters to the left are<br />
extracted. If you include m, extraction begins with the position specified, and n<br />
characters to the right are extracted.<br />
If the input value or conversion code is invalid, UniData returns the input value.<br />
Note: In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-523 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
str.expr Indicates a string to be searched.<br />
m Extracts a contiguous string of characters starting from character m.<br />
n Extracts a contiguous string of characters of length n.<br />
OCONV Text Extraction (T) Parameters
Examples<br />
The following table describes some OCONV text extraction codes and their results.<br />
Input Code Result<br />
1234567890 “T3” 890<br />
Three characters are extracted, counting<br />
to the left from 0.<br />
1234567890 "T1,3" 123<br />
Three characters are extracted, counting<br />
to the right from 1.<br />
DAMN THE TORPEDOES “T3,5” MN TH<br />
CONVERSION IS THE KEY “T1,9” CONVERSIO<br />
457 COLORADO BLVD “T4,7” [space]COLORA<br />
OCONV Text Extraction (T) Examples<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
[], FIND, FINDSTR, ICONV Text Extraction (T)<br />
OCONV Text Extraction (T) 1-524
OCONV File Translation (Tfile)<br />
Syntax<br />
OCONV(rec.id, "T[DICT] [filename;cn;I-Attribute;O-Attribute]")<br />
Description<br />
The OCONV file translation (Tfile) function retrieves attributes from a file without<br />
the file being explicitly opened first. This function performs the same conversion as<br />
the ICONV file translation function. If the input value or conversion code is invalid,<br />
UniData returns the input value.<br />
Note: In BASICTYPE P, OCONV returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-525 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
rec.id Specifies the ID of the record to be accessed. Can be a literal or a variable.<br />
DICT Include to access the dictionary file.<br />
filename Specifies the name of the file to be accessed (any valid UniData file in your<br />
VOC file containing the required attribute or data).<br />
c One of the following translate subcodes:<br />
V – If the record does not exist, or if the attribute is an empty string, return<br />
an empty string and print an error message.<br />
C – If the record does not exist, or if the attribute is an empty string, substitute<br />
id.expr for the value of the function.<br />
X – If the record does not exist, or if the attribute is an empty string, return<br />
an empty string.<br />
OCONV File Translation (Tfile) Parameters
Parameter Description<br />
n Indicates the number of the value of a multivalued attribute to retrieve. If n is<br />
not included, UniData retrieves all values of the attribute.<br />
I-Attribute Specifies the number of the attribute to be retrieved during input conversion.<br />
If I-Attribute is omitted, UniData retrieves the record ID.<br />
O-Attribute Number of the attribute to be retrieved during output conversion (OCONV).<br />
If the O-Attribute is omitted, UniData retrieves the record ID.<br />
Examples<br />
OCONV File Translation (Tfile) Parameters (continued)<br />
The first line of the following program segment reads the demo database file<br />
ORDERS, accessing the record with @ID 912, and retrieving the second attribute.<br />
OCONV T also converts the internal date to display format. The second line prints<br />
the value in that attribute.<br />
record.ret = OCONV("912","TORDERS;V;;2")<br />
PRINT "Record retrieved: ":record.ret<br />
END<br />
The following output is obtained by running the preceding program:<br />
Record retrieved: 12:30PM<br />
In the next example, the program statement translates the TAPE_ID to the TAPES file<br />
and returns the name of the tape:<br />
TAPE_ID = CUSTOMER.REC<br />
TAPE_NAME = OCONV("TAPE_ID","TTAPES;X;;1")<br />
Related Command<br />
ICONV File Translation (Tfile)<br />
OCONV File Translation (Tfile) 1-526
OCONVS<br />
Syntax<br />
OCONVS(dyn.array.expr, conv.code.expr)<br />
Description<br />
The <strong>UniBasic</strong> OCONVS function converts string or numeric data from internal<br />
format to output format, based on a conversion code, for each element of a dynamic<br />
array. If the input value or conversion code is invalid, UniData returns the input<br />
value.<br />
Note: In BASICTYPE P, OCONVS returns an empty string if UDT.OPTIONS 56 is on<br />
and the input value or conversion code is invalid.<br />
OCONVS conversion codes are the same as OCONV conversion codes. For<br />
information about conversion codes, see OCONV.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-527 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
dyn.array.expr Specifies a dynamic array, each element of which to convert.<br />
conv.code.expr Specifies a code to use in converting each element of the<br />
dynamic array.<br />
OCONVS Parameters
Examples<br />
In the following example, the program segment converts each element of ARR1 to<br />
output format:<br />
ARR1 = 1234:@VM:5678:@VM:9876<br />
ARR2 = OCONVS(ARR1,"MR2$")<br />
PRINT ARR2<br />
END<br />
The preceding program segment prints the following output:<br />
$12.34 $56.78 $98.76<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
OCONV, ICONVS<br />
OCONVS 1-528
ON/GOSUB<br />
Syntax<br />
ON expr GOSUB label[:][, label[:]...]<br />
Description<br />
The <strong>UniBasic</strong> ON/GOSUB command transfers program control to a subroutine label<br />
based on the value of expr.<br />
ON GOSUB can appear on one line, or it can be spread over as many successive lines<br />
as necessary. Labels must be separated by commas.<br />
When the program encounters a RETURN statement in the called subroutine,<br />
UniData transfers control to the statement immediately following ON GOSUB. If the<br />
subroutine contains a RETURN TO label statement, control resumes at the label<br />
specified in the RETURN statement.<br />
Note: In BASICTYPE M or P, if expr is nonnumeric or less than 1, UniData bypasses<br />
the GOSUB clause and the next program statement executes.<br />
1-529 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
expr Specifies a numeric expression. UniData evaluates the expression, and then<br />
truncates it to an integer. Control passes to a subroutine based on the<br />
following rules.<br />
If expr is less than or equal to 1, UniData transfers program control to the<br />
subroutine starting at the first label in the list. If the number is 2, UniData<br />
transfers control to the subroutine starting at the second label, and so forth.<br />
If expr is higher than the number of labels, UniData transfers control to the<br />
last label in the list.<br />
If expr is nonnumeric, control transfers to the first label.<br />
label Specifies a subroutine label or multiple subroutine labels.<br />
: Optional. A colon is required to identify a nonnumeric label in the statement<br />
label itself only, not in the reference to it in the ON/GOSUB statement.<br />
ON/GOSUB Parameters<br />
Examples<br />
In the following example, the program segment divides the variable BALANCE by<br />
100. If the result is less than or equal to 1, the program transfers control to subroutine<br />
U100. If the value is 2 or 3, it transfers control to U200 or U300 respectively. If the<br />
value is greater than or equal to 4, UniData transfers control to subroutine U400.<br />
ON BALANCE/100 GOSUB U100,U200,U300,U400<br />
In the next example, the program segment transfers control to a subroutine after<br />
prompting the user for a screen item to modify. In this case, depending on the number<br />
the user enters, UniData transfers control to one of the five subroutines in the<br />
GOSUB clause. If the user response is nonnumeric or less than 1, UniData transfers<br />
control to the first subroutine. If the user enters a value greater than 5, UniData<br />
transfers control to the last subroutine (500).<br />
GOSUB DISPLAY.SCREEN:<br />
PRINT "Enter Item number to modify (1-5): ":<br />
INPUT ACTION<br />
ON ACTION GOSUB 100,200,300,400,500<br />
ON/GOSUB 1-530
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
GOSUB, GOTO, ON/GOTO, RETURN<br />
1-531 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
ON/GOTO<br />
Syntax<br />
ON expr GOTO label1[:] [, label2[:] ...]<br />
Description<br />
The <strong>UniBasic</strong> ON/GOTO command transfers program control to a statement label<br />
based on a numeric expression.<br />
The ON GOTO statement, like the GOTO statement, is one-way branch. If you use<br />
an ON GOTO statement to transfer control to a subroutine with a RETURN<br />
statement, the subroutine’s RETURN statement works if a previous GOSUB<br />
statement is still waiting for a RETURN statement in the subroutine. Otherwise, the<br />
program aborts with a runtime error.<br />
Tip: Use ON/GOSUB instead of ON/GOTO to make your programs easier to follow<br />
and maintain.<br />
ON/GOTO 1-532
Parameters<br />
The following table describes each parameter of the syntax.<br />
Paramete<br />
r Description<br />
Note: In BASICTYPE M or P, if expr is nonnumeric or less than 1, UniData bypasses<br />
the GOTO clause and the next program statement executes.<br />
Example<br />
In the following example, the program statement transfers program control to the<br />
statement label TEST if the variable X is less than or equal to 1. If X is 2, UniData<br />
transfers control to statement label 2500. If X is greater than or equal to 3, UniData<br />
transfers control to statement label YESNO.<br />
ON X GOTO TEST,2500, YESNO<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
GOSUB, GOTO, ON/GOSUB<br />
1-533 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
expr Specifies a numeric expression. UniData evaluates the expression, and then<br />
truncates it to an integer. Control passes to a statement label based on the<br />
following rules:<br />
If expr is less than or equal to 1, UniData transfers program control to the label<br />
starting at the first label in the list. If the number is 2, UniData transfers control<br />
to the label starting at the second label, and so forth.<br />
If expr is higher than the number of labels, UniData transfers control to the last<br />
label in the list.<br />
If expr is nonnumeric, control transfers to the first label.<br />
label Specifies a statement label or multiple statement labels.<br />
: Optional. A colon is required to identify a nonnumeric label in the statement<br />
label itself only, not in the reference to it in the ON/GOTO statement.<br />
ON/GOTO Parameters
OPEN<br />
Syntax<br />
OPEN ["expr",] "filename" [READONLY] [TO file.var] [ON ERROR statements]<br />
{THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> OPEN command opens a UniData hashed data or dictionary file, so<br />
you can read, write, or delete records from it. The number of files you can open is<br />
determined by operating system and UniData configuration parameters. For information<br />
about file performance, see Administering UniData on UNIX or<br />
Administering UniData on Windows Platforms.<br />
Warning: Do not use <strong>UniBasic</strong> READ commands to open or modify binary data in<br />
DIR-type files (for example, BP). Doing so could corrupt data in the file. Instead, use<br />
OSREAD or OSBREAD after executing the <strong>UniBasic</strong> NOCONVERT command.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
expr Specifies the portion of file type to open:<br />
“” – UniData opens a data file.<br />
DICT – UniData open a dictionary file.<br />
filename Specifies the name of the file to open.<br />
READONLY Directs UniData to open the file for reading only. If the program<br />
attempts to write to a file opened in READONLY mode, UniData<br />
displays a runtime error message and does not update the file. For<br />
information about security procedures, see Administering UniData on<br />
UNIX or Administering UniData on Windows Platforms.<br />
OPEN Parameters<br />
OPEN 1-534
Parameter Description<br />
1-535 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
TO file.var Specifies a file variable in which to place a pointer to the opened file.<br />
If you do not specify file.var, the file you open becomes the default file.<br />
UniData performs all default file operations on this file. (Default file<br />
statements include all types of read, write, or delete when no file<br />
variable specified).<br />
A single default file can be declared in each <strong>UniBasic</strong> program or<br />
subroutine, and the default file is specific to the program or subroutine<br />
in which it is defined. If a main program opens a default file, and then<br />
calls an display subroutine that also opens a default file, UniData<br />
restores the original default file when returning to the main program.<br />
ON ERROR<br />
statements<br />
THEN statements<br />
END<br />
ELSE statements<br />
END<br />
The ON ERROR clause enables the program to continue to perform<br />
when a fatal error occurs such as when the file is not open, an I/O error<br />
occurs, or UniData cannot find the file.<br />
If a VOC entry exists for a file that does not exist, the ON ERROR<br />
clause executes. However, if no VOC entry exists, the ELSE statement<br />
executes.<br />
If you do not specify the ON ERROR clause and a fatal error occurs,<br />
the program terminates.<br />
THEN executes if the open is successful. END is required to terminate<br />
multiline THEN statements.<br />
ELSE executes if the OPEN is not successful or the record does not<br />
exist.<br />
If the file exists, but some other error occurs, the ELSE statement<br />
executes. However, if a file does not exist and no VOC entry exists, the<br />
ELSE statement executes.<br />
END is required to terminate multiline ELSE statements.<br />
OPEN Parameters (continued)
INMAT Function Return Values<br />
After you execute OPEN, the INMAT function returns one of the values described in<br />
the following table.<br />
Examples<br />
In the following example, the program statement opens the data file ACCREC in<br />
read-only mode. Because no file variable is specified, ACCREC becomes the default<br />
file.<br />
OPEN 'ACCREC' READONLY ELSE STOP 'Cannot open ACCREC'<br />
In the next example, the program statement opens the dictionary file ACCPAY,<br />
assigning it to the file variable AP. If UniData does not find the file, “File not found”<br />
displays.<br />
OPEN 'DICT', 'ACCPAY' TO AP ELSE PRINT 'File not found'<br />
In the next example, the program segment opens the CLIENTS file to the file variable<br />
CLIENT. If it is not found, UniData executes the ELSE statements, printing an error<br />
and setting a flag to 1.<br />
OPEN 'CLIENTS' TO CLIENT ELSE<br />
PRINT 'NO CLIENT'<br />
OPEN.ABORT = 1<br />
END<br />
IF OPEN.ABORT THEN PRINT 'Aborting on open error';STOP<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
Value Description<br />
n The number of modulos for the file.<br />
0 The file opened is a directory.<br />
INMAT Function Return Values<br />
CLOSE, DELETE, OPENSEQ, OSOPEN, READ, WRITE<br />
OPEN 1-536
openSecureSocket function<br />
Syntax<br />
openSecureSocket(name_or_IP, port, mode, timeout, socket_handle, context)<br />
Description<br />
Use the openSecureSocket() function to open a secure socket connection in a<br />
specified mode and return the status.<br />
This function behaves exactly the same as the openSocket() function, except that it<br />
returns the handle to a socket that transfers data in a secured mode (SSL/TLS).<br />
All parameters (with the exception of context) have the exact meaning as the<br />
openSocket() parameters. Context must be a valid security context handle.<br />
Once the socket is opened, any change in the associated security context will not<br />
affect the established connection.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-537 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
name_or_IP DNS name (x.com) or IP address of a server.<br />
port Port number. If the port number is specified as a value
Parameter Description<br />
timeout The timeout value, expressed in milliseconds. If you specify<br />
mode as 0, timeout will be ignored.<br />
socket_handle A handle to the open socket.<br />
context A handle to the security context<br />
openSecureSocket Parameters (continued)<br />
The following table describes the return status of each mode.<br />
Return<br />
Code Description<br />
0 Success.<br />
1-41 See Socket Function Error Return Codes.<br />
101 Invalid security context handle.<br />
102 SSL/TLS handshake failure (unspecified, peer is<br />
not SSL aware).<br />
103 Requires client authentication but does not have<br />
a certificate in the security context.<br />
104 Unable to authenticate server.<br />
Return Code Status<br />
openSecureSocket function 1-538
OPENSEQ<br />
Syntax<br />
OPENSEQ [absolutepath | seq.filename,record.id] [READONLY] TO seq.file.var<br />
[ON ERROR statements] [LOCKED statements] {THEN statements [END] | ELSE<br />
statements [END]}<br />
OPENSEQ [absolutepath | seq.filename,record.id] [READONLY] TO seq.file.var<br />
[LOCKED statements] [ON ERROR statements] {THEN statements [END] | ELSE<br />
statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> OPENSEQ command opens a sequential file for access, starting at the<br />
specified record. UniData limits to 150 the number of sequential files you can open<br />
in a <strong>UniBasic</strong> program.<br />
Tip: Use OPENSEQ to open files that use CHAR(10) as a delimiter. You can then use<br />
READSEQ to read the next line delimited by CHAR(10), or WRITESEQ to write a<br />
line delimited by CHAR(10). You also can use OSBREAD to read a block of data from<br />
the file, or OSBWRITE to write a block of data to the file.<br />
Note: For UniData for Windows Platforms only: When you use OPENSEQ, UniData<br />
uses the fopen function to open files in Text mode and converts NEWLINE [CHAR<br />
(10)] line delimiters to CARRIAGE RETURN–NEWLINE pairs [CHAR(13) and<br />
CHAR(10)].<br />
1-539 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
absolutepath The operating system path and sequential file name.<br />
seq.filename Specifies a UniData directory type file name.<br />
record.id Specifies a record in the sequential file at which to start<br />
accessing.<br />
READONLY Opens the file for reading only. If the program attempts to write<br />
to a file opened in READONLY mode, UniData displays a<br />
runtime error message and does not update the file. For<br />
information about security procedures, see Administering<br />
UniData on UNIX or Administering UniData on Windows<br />
Platforms.<br />
TO seq.file.var Specifies a file variable to contain a pointer to the opened file.<br />
ON ERROR statements Specifies statements to execute if the OPENSEQ statement fails<br />
with a fatal error because the file is not open, an I/O error occurs,<br />
or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
LOCKED statements Specifies statements to execute if the record is locked by another<br />
user. If you do not specify a LOCKED clause, the program waits<br />
until the lock on the record is released. You can place the<br />
LOCKED clause after the FROM clause.<br />
Use the ECL command DEFAULT.LOCKED.ACTION BELL<br />
to make the terminal beep while you wait for UniData to unlock<br />
the record.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record (or ID)<br />
does not exist. END is required to terminate multiline ELSE<br />
statements.<br />
OPENSEQ Parameters<br />
OPENSEQ 1-540
STATUS Function Return Values<br />
After you execute OPENSEQ, the STATUS function returns one of the values<br />
described in the following table.<br />
Example<br />
In the following example, the program statement opens the sequential file<br />
INV.SOURCES in the directory PRINTERS, and assigns the file variable PRNT:<br />
1-541 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
OPENSEQ 'PRINTERS','INV.SOURCES' TO PRNT ELSE GOSUB CLOSED:<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLOSESEQ, OPEN, OSBREAD, OSBWRITE, OSCLOSE, OSDELETE,<br />
OSOPEN, OSREAD, OSWRITE, READSEQ, WEOFSEQ, WRITESEQ,<br />
WRITESEQF<br />
UniData<br />
Value Description<br />
0 The record does not exist.<br />
1 The file you specify is not a sequential-access file.<br />
2 The file does not exist.<br />
3 The READONLY clause was included in the command<br />
statement and the record does not exist.<br />
4 An unknown error occurred (such as having too many files open<br />
or permission problems).<br />
STATUS Function Return Values<br />
DEFAULT.LOCKED.ACTION – For information, see UniData <strong>Commands</strong><br />
<strong>Reference</strong>.
openSocket<br />
Syntax<br />
openSocket(name_or_IP, port, mode, timeout, socket_handle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Use the openSocket function to open a socket connection in a specified mode and<br />
return the status.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
name_or_IP DNS name (x.com) or IP address of a server.<br />
port Port number. If the port number is specified as a value
The following table describes the return status of each mode.<br />
Mode Return Status<br />
The following table describes the status of each return code.<br />
1-543 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
0 - Non-blocking The function will return immediately regardless of whether or not the<br />
socket is successfully opened. The return code inidcates if the<br />
operation is successful. The timeout value is ignored.<br />
1 - Blocking If a positive timeout is specified, the function will either return with<br />
a valid socket handle or will time out after the specified timeout<br />
period. If the timeout value is 0, the function will block until either<br />
the socket is successfully opened, the underlying TCP/IP connection<br />
times out or some other error prevents the socket from opening.<br />
Mode Return Status<br />
Return Code Status<br />
0 Success.<br />
Non-zero See Socket Function Error Return Codes.<br />
openSocket Return Codes
OpenXMLData<br />
Syntax<br />
OpenXMLData(xml_handle,xml_data_extraction_rule, xml_data_handle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Use the OpenXMLData function to open an XML document after preparing it using<br />
the PrepareXML function.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
xml_handle The XML handle generated by the PrepareXML() function.<br />
xml_data_extraction_<br />
rule<br />
The path to the XML extraction rule file.<br />
xml_data_handle The XML data file handle. The following are the possible return<br />
values:<br />
XML.SUCCESS Success.<br />
XML.ERROR Failed<br />
XML.INVALID.HANDLE Invalid XML handle<br />
OpenXMLData Parameters<br />
OpenXMLData 1-544
Example<br />
The following example illustrates use of the OpenXMLData function:<br />
1-545 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
status = OpenXMLData(“STUDENT_XML”,<br />
“_XML_/MYSTUDENT.ext”,STUDENT_XML_DATA)<br />
If status = XML.ERROR THEN<br />
STOP “Error when opening the XML document. “<br />
END<br />
IF status = XML.INVALID.HANDLE THEN<br />
STOP “Error: Invalid parameter passed.”<br />
END
OR<br />
Syntax<br />
expr1 OR expr2<br />
Synonym<br />
!<br />
Description<br />
The OR Boolean operator combines a set of expressions. If expr1 or expr2 is true, the<br />
combined expression is true. Either expression must be true for a true condition.<br />
Example<br />
In the following example, the program segment combines expressions (X < Y) and<br />
(Y < Z). If either expression is true, the program calls subroutine RETRY.<br />
X = 1 ; Y = 2 ; z = 3<br />
IF (X < Y) OR (Y < Z) THEN GOSUB RETRY:<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
AND, NOTS, OR<br />
OR 1-546
OSBREAD<br />
Syntax<br />
OSBREAD var FROM file.var [AT byte.expr] LENGTH length.expr [NODELAY]<br />
[ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> OSBREAD command reads data from a file starting at a specified byte<br />
location for a certain length of bytes, and assigns the data to a variable. OSBREAD<br />
performs an operating system block read on a UNIX, or Windows platform file.<br />
Note: Before you use OSBREAD, you must open the file by using the OSOPEN or<br />
OPENSEQ command.<br />
UniData uses the ASCII 0 character [CHAR(0)] as a string-end delimiter. Therefore,<br />
ASCII 0 cannot be used in any string variable within <strong>UniBasic</strong>. OSBREAD converts<br />
CHAR(0) to CHAR(128) when reading a block of data.<br />
Reading from a Named Pipe<br />
Keep these points in mind when you write programs that read from named pipes:<br />
1-547 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Unlike a typical read, reading a named pipe removes the data.<br />
Your application should check the length of var after reading a pipe. The<br />
value returned could be shorter than length.expr.<br />
UniData truncates the data if it is longer than length.expr.<br />
Reading Other Types of Files<br />
Processing of files that are not named pipes is determined by the presence or absence<br />
of the AT clause:<br />
If the AT clause is included, <strong>UniBasic</strong> begins reading from the file at the<br />
offset specified by byte.expr.
If the AT clause is not included, <strong>UniBasic</strong> begins reading from the current<br />
location of the file pointer.<br />
Because named pipes must be read from the beginning, the AT clause is not<br />
appropriate for accessing them. If the AT clause is specified, the ON<br />
ERROR executes, and the <strong>UniBasic</strong> STATUS function is set to 2. If the ON<br />
ERROR clause is not included, the program aborts.<br />
After successful execution of OSBREAD against a file that is not a named<br />
pipe, the file pointer remains at the next byte after the data read.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
var Specifies a variable to which to assign the data read.<br />
FROM file.var Specifies a file from which to read the data.<br />
AT byte.expr Specifies a location in the file from which to begin reading data.<br />
If byte.expr is 0, the read begins at the beginning of the file.<br />
When reading a named pipe, do not specify an AT clause. Pipes<br />
are always read with no offset.<br />
LENGTH length.expr Specifies a length of data to read from the file, starting at<br />
byte.expr.<br />
length.expr cannot be longer than the maximum string length<br />
determined by your system configuration.<br />
NODELAY Forces an immediate read of a named pipe regardless of whether<br />
the pipe contains data. If you do not specify NODELAY, the<br />
process attempting to read waits until the pipe is opened for<br />
writing and data is written to it.<br />
If filename is not a named pipe, NODELAY has no effect.<br />
ON ERROR statements Specifies statements to execute if a fatal error occurs (if the file<br />
is not open, or if the file is a read-only file). If you do not specify<br />
the ON ERROR clause, the program terminates under such fatal<br />
error conditions.<br />
OSBREAD Parameters<br />
OSBREAD 1-548
STATUS Function Return Values<br />
After you execute OSBREAD, the STATUS function returns one of the values<br />
described in the following table.<br />
Examples<br />
In the following example, the program statement reads 10,000 bytes of the file RFILE<br />
starting from the beginning of the file. The program assigns the data it reads to the<br />
variable TEST.<br />
1-549 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
OSBREAD TEST FROM 'RFILE' AT 0 LENGTH 10000<br />
In the next example, the program segment reads 15,000 bytes from an NTFS or<br />
UNIX file, starting at the first byte. It then converts ASCII value 10 (a line feed) to a<br />
value mark and processes each line sequentially.<br />
OSBREAD BLOCK FROM INPUT.DIR AT 0 LENGTH 15000<br />
CONVERT CHAR(10) TO @FM IN BLOCK<br />
LOOP<br />
REMOVE REC FROM BLOCK SETTING MORE.RECS<br />
GOSUB PROCESS.REC:<br />
WHILE MORE.RECS REPEAT<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
Value Description<br />
0 The read was successful.<br />
1 The file name is invalid.<br />
2 Access is denied by the operating system.<br />
3 The file does not exist.<br />
4 An unknown error occurred.<br />
STATUS Function Return Values<br />
CLOSESEQ, OPENSEQ, OSBWRITE, OSCLOSE, OSDELETE, OSOPEN,<br />
READSEQ, WRITESEQ, WRITESEQF
OSBWRITE<br />
Syntax<br />
OSBWRITE expr {ON | TO} file.var [AT byte.expr] [NODELAY] [ON ERROR<br />
statements]<br />
Description<br />
The <strong>UniBasic</strong> OSBWRITE command writes an expression to a sequential file<br />
starting at a specified byte location. OSBWRITE immediately writes a file segment<br />
out to the UNIX, or Windows platform file.<br />
You do not have to specify a length expression because the number of bytes in expr<br />
is written to the file.<br />
Note: Before you use OSBWRITE, you must open the file by using the OSOPEN or<br />
OPENSEQ command.<br />
UniData uses the ASCII 0 character [CHAR(0)] as a string-end delimiter. Therefore,<br />
ASCII 0 cannot be used in any string variable within <strong>UniBasic</strong>. If <strong>UniBasic</strong> reads a<br />
string that contains CHAR(0) characters by using OSBREAD, those characters are<br />
converted to CHAR(128). OSBWRITE converts CHAR(128) back to CHAR(0) when<br />
writing a block of characters.<br />
Writing to Named Pipes<br />
The combination of the following conditions and command options determine the<br />
action taken by <strong>UniBasic</strong> when OSBWRITE is executed against a named pipe:<br />
Presence and length of data in the pipe<br />
Open/closed status of the pipe<br />
Presence or absence of the AT and NODELAY command options<br />
For information about writing applications that access named pipes, see the Developing<br />
<strong>UniBasic</strong> Applications manual.<br />
OSBWRITE 1-550
Writing to Other Types of Files<br />
For files that are not named pipes, processing is determined by the presence or<br />
absence of the AT clause:<br />
1-551 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
AT clause specified – <strong>UniBasic</strong> begins writing to the file at the offset<br />
specified by byte.expr.<br />
AT clause not specified – <strong>UniBasic</strong> begins writing to the current location of<br />
the file pointer.<br />
After successful execution of OSBWRITE against a file that is not a named<br />
pipe, the file pointer remains at the next byte after the data is written.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
expr Specifies the expression to write to the file.<br />
ON | TO file.var Specifies the file on which to write the expression.<br />
AT byte.expr If byte.expr is 0, the write begins at the beginning of the file.<br />
NODELAY Forces an immediate write.<br />
Include NODELAY to write to a named pipe immediately<br />
regardless of whether the pipe contains data. If you do not<br />
specify NODELAY, the process attempting to write waits until<br />
the pipe is opened for reading.<br />
ON ERROR statements Specifies statements to execute if the OSBWRITE statement<br />
fails with a fatal error because the file is not open, an I/O error<br />
occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
OSBWRITE Parameters
STATUS Function Return Values<br />
After you execute OSBWRITE, the STATUS function returns one of the values<br />
described in the following table.<br />
Examples<br />
Value Description<br />
0 The write was successful.<br />
1 The file name is invalid.<br />
2 You do not have permission to access the file.<br />
4 The file does not exist.<br />
STATUS Function Return Values<br />
In the following example, the program statement writes the data in TEST to the<br />
RFILE starting from the beginning of the file:<br />
OSBWRITE TEST ON RFILE AT 0<br />
In the next example, the program segment reads REC.ID from a select list, reads the<br />
associated record from the CLIENT file, and appends the record onto a variable<br />
(BLOCK), terminating each record with an ASCII 10 (line feed). When it is<br />
complete, the code writes the block to the NTFS or UNIX file name opened to the<br />
variable CLIENT.SEQ.<br />
DONE = 0<br />
LOOP<br />
READNEXT REC.ID ELSE DONE = 1<br />
UNTIL DONE DO<br />
READ REC FROM CLIENT,REC.ID ELSE REC = ' '<br />
IF REC THEN<br />
REC = REC.ID:@FM:REC<br />
BLOCK := REC:CHAR(10)<br />
END<br />
REPEAT<br />
OSBWRITE BLOCK ON CLIENT.SEQ AT 0<br />
OSBWRITE 1-552
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLOSESEQ, OPENSEQ, OSBREAD, OSCLOSE, OSDELETE, OSOPEN,<br />
READSEQ, WRITESEQ, WRITESEQF<br />
1-553 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
OSCLOSE<br />
Syntax<br />
OSCLOSE file.var [ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> OSCLOSE command closes a sequential file that you opened with the<br />
OSOPEN or OPENSEQ command.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
file.var Specifies the file to close.<br />
ON ERROR<br />
statements<br />
Specifies statements to execute if the OSCLOSE statement fails with a<br />
fatal error because the file is not open, an I/O error occurs, or UniData<br />
cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error occurs, the<br />
program terminates.<br />
OSCLOSE Parameters<br />
STATUS Function Return Values<br />
After you execute OSCLOSE, the STATUS function returns one of the values<br />
described in the following table.<br />
Value Description<br />
0 The file is closed successfully.<br />
5 The file did not close.<br />
STATUS Function Return Values<br />
OSCLOSE 1-554
Example<br />
In the following example, the program statement closes the file UNDEF:<br />
OSCLOSE UNDEF<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLOSE, CLOSESEQ, OPENSEQ, OSOPEN<br />
1-555 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
OSDELETE<br />
Syntax<br />
OSDELETE filename [ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> OSDELETE command deletes an NTFS or UNIX sequential file.<br />
Warning: The <strong>UniBasic</strong> OSDELETE command is intended for use on OS-type files<br />
(not UniData hashed files). If you execute the command against a recoverable<br />
hashed file, UniData could crash immediately or at the next Recoverable File System<br />
(RFS) checkpoint. If you execute the command against a nonrecoverable hashed file,<br />
UniData will not crash, but other unpredictable problems could occur.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
filename Specifies the file to delete. filename must include the file path. If you do<br />
not specify a path, UniData searches the current directory.<br />
ON ERROR<br />
statements<br />
Specifies statements to execute if the OSDELETE statement fails with a<br />
fatal error because the file is not open, an I/O error occurs, or UniData<br />
cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error occurs, the<br />
program terminates.<br />
OSDELETE Parameters<br />
OSDELETE 1-556
STATUS Function Return Values<br />
After you execute OSDELETE, the STATUS function returns one of the values<br />
described in the following table.<br />
Examples<br />
In the following example, the program statement deletes the file NAMES in the<br />
current directory:<br />
OSDELETE "NAMES"<br />
In the next example, the program statement deletes the file client.rec in the UNIX<br />
subdirectory /u/trans:<br />
1-557 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
OSDELETE '/u/trans/client.rec'<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
Value Description<br />
0 The file was deleted.<br />
1 The directory name is invalid.<br />
2 UniData cannot access the file (such as user<br />
does not have permission).<br />
4 The file does not exist.<br />
STATUS Function Return Values<br />
CLOSESEQ, DELETE, OPENSEQ, OSOPEN, OSCLOSE
OSOPEN<br />
Syntax<br />
OSOPEN filename [READONLY | WRITEONLY] TO file.var [NODELAY]<br />
[ON ERROR statements] {THEN | ELSE} statements [END]<br />
Description<br />
The <strong>UniBasic</strong> OSOPEN command opens a sequential file that does not use<br />
CHAR(10) as the line delimiter.<br />
Read/write access mode is the default. Specify this access mode by omitting<br />
READONLY and WRITEONLY.<br />
Tip: After opening a sequential file with OSOPEN, use OSBREAD to read a block of<br />
data from the file, or OSBWRITE to write a block of data to the file. You also can use<br />
READSEQ to read a record from the file, or WRITESEQ or WRITESEQF to write a<br />
record to the file, if the file is not a named pipe. (READSEQ, WRITESEQ, and<br />
WRITESEQF are line-oriented commands that use CHAR(10) as the line delimiter.)<br />
Note: On UniData for Windows Platforms only: When you use OSOPEN, UniData<br />
uses the open function to open files in binary mode, but does not convert NEWLINE<br />
[CHAR(10)] delimiters to CARRIAGE RETURN–NEWLINE pairs [CHAR(13) and<br />
CHAR(10)] as the OPENSEQ command does.<br />
OSOPEN 1-558
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-559 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
filename Specifies the file to open. filename must include the entire path<br />
name unless the file resides in the current directory.<br />
READONLY Directs UniData to open the file for reading only. If the program<br />
attempts to write to a file opened in READONLY mode,<br />
UniData displays a runtime error message and does not update<br />
the file. For information about security procedures, see<br />
Administering UniData on UNIX or Administering UniData on<br />
Windows Platforms.<br />
WRITEONLY Specifies that the pipe or file is open for write access only.<br />
TO file.var Specifies a variable to contain a pointer to the file.<br />
NODELAY Forces a pipe to be opened immediately. This enables a process<br />
to continue even when the pipe is not open in the opposite access<br />
mode. The application must then manage access to the pipe to<br />
ensure that it is opened for the opposite process before reading<br />
from or writing to it.<br />
If filename is not a named pipe, NODELAY has no effect.<br />
ON ERROR statements Specifies statements to execute if the OSOPEN statement fails<br />
with a fatal error because the file is not open, an I/O error occurs,<br />
or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record (or ID)<br />
does not exist. END is required to terminate multiline ELSE<br />
statements.<br />
OSOPEN Parameters
Example<br />
In the following example, the program statement opens the file INVENTORY as<br />
INVENT unless UniData cannot access the file.<br />
OSOPEN 'INVENTORY' TO INVENT ELSE STOP "Can't open INVENTORY"<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLOSESEQ, OPEN, OPENSEQ, OSBREAD, OSBWRITE, OSCLOSE,<br />
OSDELETE, READSEQ, WRITESEQ, WRITESEQF<br />
OSOPEN 1-560
OSREAD<br />
Syntax<br />
OSREAD var FROM filename [ON ERROR statements] {THEN statements [END]<br />
| ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> OSREAD command reads an entire sequential file and assigns the<br />
contents of the file to a variable.<br />
Warning: Do not use OSREAD on large files. If the file is too large for the program<br />
memory, the program aborts and a runtime error message is generated. On large<br />
files, use OSBREAD or READSEQ.<br />
Note: UniData uses the ASCII 0 character [CHAR(0)] as a string-end delimiter.<br />
ASCII 0 cannot be used in any string variable within <strong>UniBasic</strong>. OSREAD converts<br />
CHAR(0) to CHAR(128) when reading a block of data.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-561 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
var Specifies the variable to which to assign the data from the file.<br />
FROM filename The filename must include the entire path to the file unless<br />
filename exists in the current directory.<br />
OSREAD Parameters
Parameter Description<br />
ON ERROR statements Specifies statements to execute if the OSREAD statement fails<br />
with a fatal error because the file is not open, an I/O error<br />
occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record (or ID)<br />
does not exist. END is required to terminate multiline ELSE<br />
statements.<br />
Example<br />
In the following example, the program segment reads the data stored in the UNIX file<br />
‘BILLING’ in the subdirectory ‘disk1’ and assigns it to the variable BILL.REC:<br />
OSREAD BILL.REC FROM "disk1/BILLING" ELSE<br />
PRINT "NO BILLING RECORD FOUND"<br />
END<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
OSWRITE<br />
OSREAD Parameters (continued)<br />
OSREAD 1-562
OSWRITE<br />
Syntax<br />
OSWRITE expr {ON | TO} filename [ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> OSWRITE command writes the contents of an expression to a<br />
sequential file.<br />
Note: UniData uses the ASCII 0 character [CHAR(0)] as a string-end delimiter. For<br />
this reason, you cannot use ASCII 0 in any string variable in <strong>UniBasic</strong>. If <strong>UniBasic</strong><br />
reads a string with a CHAR(0) character, and then the character is converted to<br />
CHAR(128), OSWRITE converts CHAR(128) to CHAR(0) when writing a block of<br />
characters.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-563 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
expr Specifies the expression to write to filename.<br />
ON | TO filename Specifies the name of a sequential file to which to write.<br />
ON ERROR statements Specifies statements to execute if the OSWRITE statement fails<br />
with a fatal error because the file is not open, an I/O error occurs,<br />
or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
OSWRITE Parameters
Example<br />
In the following example, the program segment writes the contents of MAIL.LIST to<br />
the file called “mergefile” in the UNIX subdirectory ‘/u/maildir’:<br />
OSWRITE MAIL.LIST ON "/u/maildir/mergefile"<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
OSREAD<br />
OSWRITE 1-564
PAGE<br />
Syntax<br />
PAGE [ON num.expr] [expr]<br />
Description<br />
The <strong>UniBasic</strong> PAGE command prints the current output page. UniData prints the<br />
page with any specified header or footer.<br />
If you do not specify any parameters, the result depends on the last PRINTER<br />
command executed:<br />
1-563 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
PRINTER OFF – The new page is generated on the user’s terminal.<br />
PRINTER ON – The new page is generated on the system printer.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
ON num.expr Specifies the page number of the next output page. Each subsequent<br />
page is incremented by one.<br />
expr Specifies a target print file for the completed page where num.expr is<br />
the number assigned to the file. When you specify a num.expr, the<br />
PRINTER command setting is disregarded.<br />
For assistance assigning print files, see your system administrator.<br />
PAGE Parameters
Examples<br />
In the following example, the program statement completes the current page with<br />
footings, then advances to a new page. The PRINTER command setting determines<br />
where the page is printed.<br />
PAGE<br />
In the next example, the program statement sends the completed page to the file<br />
assigned to print unit 5. If UniData cannot find the print unit specified, the program<br />
prints nothing.<br />
PAGE ON 5<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
PRINTER<br />
UniData<br />
SETPTR – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
PAGE 1-564
PAUSE<br />
Syntax<br />
PAUSE [wait_time]<br />
Description<br />
The <strong>UniBasic</strong> PAUSE command suspends the UniData process that issues the<br />
command for the amount of time you specify with wait_time, or until a <strong>UniBasic</strong><br />
WAKE command is executed for this process. Keep in mind the following points<br />
when executing PAUSE:<br />
1-565 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
PAUSE has no effect if wait_time is a negative number, or if another<br />
UniData process has previously issued a WAKE command for this process.<br />
To pause a process indefinitely, omit wait_time, or specify a wait_time of 2.<br />
PAUSE must be executed by the process to be paused.<br />
Examples<br />
The following sample program executes the <strong>UniBasic</strong> PAUSE command to pause the<br />
current session:<br />
PAUSE_WAKE<br />
PRINT "How long do you want to pause this session":<br />
INPUT pause_time<br />
PAUSE pause_time<br />
END<br />
The following example executes the preceding program. In this execution, the user<br />
does not enter an amount of time to pause the session, so it is paused indefinitely.<br />
(The cursor rests on the line following the prompt.)<br />
:RUN BP PAUSE_WAKE<br />
How long do you want to pause this session?
From another UniData session, the user executes the LIST.PAUSED command to<br />
obtain the process ID for the paused process, and then wakes it up by specifying<br />
WAKE 1052:<br />
:LIST.PAUSED<br />
Number of Paused Users<br />
~~~~~~~~~~~~~~~~~~~~~~<br />
1<br />
UDTNO USRNBR UID USRNAME USRTYPE TTY<br />
LEFTTIME TOT_TIME<br />
1 1052 1283 carolw udt pts/0 -<br />
-<br />
:WAKE 1052<br />
:<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
WAKE<br />
UniData<br />
LIST.PAUSED, PAUSE, SLEEP, WAKE – For information, see the UniData<br />
<strong>Commands</strong> <strong>Reference</strong>.<br />
PAUSE 1-566
PCPERFORM<br />
Syntax<br />
PCPERFORM str.expr [CAPTURING, dyn.array.var]<br />
Description<br />
The <strong>UniBasic</strong> PCPERFORM command executes an operating system command<br />
from within a <strong>UniBasic</strong> program.<br />
PCPERFORM is similar to the EXECUTE and PERFORM commands except that<br />
PCPERFORM executes an operating system command.<br />
If PCPERFORM is successful, UniData sets @SYSTEM.RETURN.CODE to 0. If<br />
unsuccessful, UniData sets @SYSTEM.RETURN.CODE to -1.<br />
Note: The settings of UDT.OPTIONS affect the way ECL commands execute. For<br />
information about these options, see the UDT.OPTIONS <strong>Commands</strong> <strong>Reference</strong>. For<br />
information about UDT.OPTIONS that could affect that command, see the<br />
appropriate ECL command in UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-567 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
str.expr Specifies a string to execute as a host operating system command.<br />
CAPTURING,<br />
dyn.array.var<br />
Specifies a target dynamic array to capture the output of the host<br />
operating system command.<br />
PCPERFORM Parameters
Example<br />
In the following example, the program statement executes the operating system date<br />
command:<br />
PCPERFORM "date" CAPTURING DATE.TIME<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
EXECUTE, EXECUTESQL, MDPERFORM, UDTEXECUTE<br />
PCPERFORM 1-568
PERFORM<br />
PERFORM is a synonym for the EXECUTE command. For more information, see<br />
EXECUTE.<br />
Synonym<br />
EXECUTE<br />
1-569 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
PRECISION<br />
Syntax<br />
PRECISION num.expr<br />
Description<br />
The <strong>UniBasic</strong> PRECISION command rounds numbers to the number of decimal<br />
places indicated in num.expr. num.expr can be a number from 0 to 14. If the number<br />
is not within this range, UniData does not change the setting. The default is four<br />
decimal places.<br />
Tip: UniData converts the operands in numeric operations from string to numeric<br />
data type, performs the operations, and then converts the results back to string data<br />
type. When making calculations for which you require a high degree of precision, use<br />
the PRECISION command to force UniData to represent a particular level of decimal<br />
representation.<br />
Set the UniData FLOAT.PRECISION to 4 to truncate rather than round at the<br />
PRECISION setting.<br />
Examples<br />
In the following example, the program statement results in all numeric variables<br />
being truncated to eight decimal places:<br />
PRECISION 8<br />
In the next example, the program statement truncates all digits to the right of the<br />
decimal point:<br />
PRECISION 0<br />
In the next example, the program statement sets precision based on the variable DEC:<br />
PRECISION DEC<br />
PRECISION 1-570
Related Command<br />
UniData<br />
FLOAT.PRECISION – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
1-571 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
PrepareXML<br />
Syntax<br />
PrepareXML(xml_file,xml_handle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Use the PrepareXML function to prepare the XML document in the UniBASIC<br />
program. This step allocates memory for the XML document, opens the document,<br />
determines the file structure of the document, and returns the file structure.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
xml_file The path to the file where the XML document resides.<br />
xml_handle The return value. The return value is the UniBASIC variable for<br />
xml_handle. Status is one of the following return values:<br />
XML.SUCCESS Success<br />
XML.ERROR Error<br />
PrepareXML Parameters<br />
PrepareXML 1-572
Example<br />
The following example illustrates use of the PrepareXML function:<br />
1-573 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
STATUS = PrepareXML(“_XML_/MYSTUDENT.XML”,STUDENT_XML)<br />
IF STATUS=XML.ERROR THEN<br />
STATUS = XMLError(errmsg)<br />
PRINT “error message “:errmsg<br />
STOP “Error when preparing XML document “<br />
END
PRINT<br />
Syntax<br />
PRINT [ON num.expr] [print.expr]<br />
Description<br />
The <strong>UniBasic</strong> PRINT command prints data on the display terminal or the system<br />
printer, or sends data to a print file.<br />
Separate multiple items in a single PRINT statement with commas or colons. A<br />
comma directs the printer to execute a tab. Tab stops are set to 10 spaces. If you use<br />
a colon to separate statements, UniData concatenates the items.<br />
Unless a PRINT expression ends with a colon, UniData executes a carriage return<br />
after printing the line. If the output from the PRINT statement exceeds the current<br />
page width, it wraps to the next line.<br />
Tip: You can use the <strong>UniBasic</strong> @ function with the PRINT command to place the<br />
cursor and/or direct the terminal to take some action. Execute the ECL REUSE.ROW<br />
command to determines whether a line feed is executed when the <strong>UniBasic</strong> PRINT @<br />
function references column only. For example, PRINT @(10) rather than PRINT<br />
@(3,10).<br />
Note: The PRINT statement interprets two consecutive nonprinting ASCII characters<br />
(such as CHAR(192):CHAR(192)) as one character when displaying data.<br />
To suppress the line feed at the end of displayed text, place a colon at the end of the<br />
PRINT or DISPLAY statement.<br />
PRINT 1-574
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Examples<br />
In the following example, the program segment prints HI THERE on the system<br />
printer:<br />
PRINTER ON<br />
PRINT "HI THERE"<br />
In the next example, the program statement sends the value of variable X concatenated<br />
to "X = " to the file specified by unit 10:<br />
PRINT ON 10 "X = ":X<br />
In the next example, the @ function is included with a terminal option. -1 clears the<br />
screen before printing.<br />
1-575 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ON num.expr Specifies a target print file. If you do not use the ON clause, the data is<br />
printed based on the last PRINTER command executed:<br />
PRINTER OFF – The data prints on the display terminal.<br />
PRINTER ON – The data prints on the system printer.<br />
print.expr Specifies an expression to print. It can be any valid <strong>UniBasic</strong><br />
expression. If you do not specify a print.expr, a PRINT statement sends<br />
a line feed character to the printer or file.<br />
PRINT Parameters<br />
PRINT @(-1):"Enter true or false: "<br />
INPUT answer,5_<br />
In the next example, the comma separation character prints X, Y, a string separated<br />
by tabs, X+Y, tabs twice, then prints another string, and finally print the average of<br />
X and Y using the INT function:<br />
X = 5 ; Y = 7<br />
PRINT X,Y,"Total = ":X+Y,,"Average = ":INT((X+Y)/2)<br />
The result is:<br />
5 7 Total = 12 Average = 6
Each item is separated by tabs as the result of the comma separation character. A<br />
colon causes all data items to be concatenated.<br />
The following program demonstrates the use of the colon at the end of the PRINT<br />
statement to suppress the line feed issued by <strong>UniBasic</strong> at the end of displayed text.<br />
The first PRINT statement does not end in a colon. Therefore, <strong>UniBasic</strong> issues a<br />
carriage return and prints a question mark (the default prompt character). The second<br />
PRINT statement ends in a colon. In this case, <strong>UniBasic</strong> displays the default prompt<br />
character and waits on the same line with the PRINT statement.<br />
PRINT "Enter character to display"<br />
INPUT X<br />
PRINT "The character you entered was(1): ":X<br />
PRINT "Enter character to display":<br />
INPUT X<br />
PRINT "The character you entered was(2): ":X<br />
This program produces the following output (with input from the<br />
user):<br />
Enter character to display<br />
?*<br />
The character you entered was(1): *<br />
Enter character to display?#<br />
The character you entered was(2): #<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
@, CRT, GETPTR, INPUTERR, PRINTER, PRINTER CLOSE<br />
UniData<br />
SETPTR – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
PRINT 1-576
PRINTER<br />
Syntax<br />
PRINTER {ON | OFF}<br />
Description<br />
The <strong>UniBasic</strong> PRINTER command directs output of PRINT, FOOTING,<br />
HEADING, and PAGE statements not sent to a file (those executed without the ON<br />
clause). If you specify ON, UniData directs all output to the system printer. If you<br />
specify OFF, UniData directs all output to the terminal screen.<br />
PRINTER ON causes runtime error messages to print on the system printer.<br />
Note: If the printer and your computer are not communicating properly when you<br />
execute a print command (for example, a PRINT statement after a PRINTER ON<br />
command), UniData generates an error.<br />
Example<br />
In the following example, the program statement sends all future report output (data<br />
from PRINT, FOOTER, HEADER, and PAGE commands) to the printer:<br />
PRINTER ON<br />
1-577 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
PRINTER CLOSE<br />
Syntax<br />
PRINTER CLOSE [ON num]<br />
Description<br />
The <strong>UniBasic</strong> PRINTER CLOSE command sends data stored in either a print file<br />
or a print buffer to the print queue. The ON clause does not physically close the print<br />
file. Instead, it sends its contents to a print buffer, leaving the file empty. Then you<br />
can send additional data to the same print file to begin a new set of data to be printed.<br />
As many as 31 print files can be open at the same time. The PRINTER CLOSE<br />
statement does not generate a new line at the end of a page. <strong>UniBasic</strong> is in control of<br />
page feeds or generating new line equivalents.<br />
Note: Data in a print file is automatically sent to the print queue if the program ends<br />
or issues a PRINTER CLOSE statement.<br />
Example<br />
In the following example, the program statement sends the current contents of print<br />
file 5 to the print queue:<br />
PRINTER CLOSE ON 5<br />
Related Command<br />
UniData<br />
SETPTR – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
PRINTER CLOSE 1-578
PRINTERR<br />
Syntax<br />
PRINTERR expr [FROM file.var]<br />
Description<br />
The <strong>UniBasic</strong> PRINTERR command prints error messages stored in the UniData<br />
system message file or in a user-defined file.<br />
To obtain a message from a user-defined error message file, you must open the file<br />
first.<br />
The <strong>UniBasic</strong> commands ABORT and PRINTERR return the system message you<br />
specify by ID in the command. You can also retrieve system messages using a<br />
<strong>UniBasic</strong> program by opening the system message file and reading a message record<br />
by ID.<br />
Note: ENGLISH.MSG is the default system message file that is activated when you<br />
install UniData. If you execute udtlang.config to select a language group, a different<br />
system message file could be activated. To find out which language is installed on<br />
your system, execute the ECL command SET.LANG CURRENT. For more<br />
information, see UniData International.<br />
1-579 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
expr Specifies a dynamic array that consists of two elements. The first<br />
element is the key for a record in the error message file. The second<br />
element is a parameter that some of the format codes use. For format<br />
codes, see the following table. Attribute marks (@AM or @FM) delimit<br />
elements.<br />
FROM file.var Specifies a file from which to extract a user-defined error message. The<br />
default is the UniData error message file.<br />
PRINTERR Parameters<br />
Creating a User-Defined Error Message<br />
Error messages in the UniData error message file consist of format codes and literal<br />
strings. The following table describes the codes you can include in error messages.<br />
Code Description<br />
A Extracts the next element in expr.<br />
A(n) Extracts the next element in expr, left-justified in a string of length n.<br />
C Clears the screen.<br />
D Enters the date in internal format.<br />
E literal Enters the message ID at the beginning of the message enclosed in brackets,<br />
followed by an optional literal string.<br />
H literal Prints literal.<br />
L Prints a carriage return/line feed. You must specify L (carriage return/line<br />
feed) explicitly.<br />
L(n) Prints n carriage returns/line feeds.<br />
R(n) Extracts the next element in expr, right-justified in an attribute of n blanks.<br />
S(n) Prints n spaces.<br />
PRINTERR Error Message Codes<br />
PRINTERR 1-580
Code Description<br />
Examples<br />
In the following example, the UniData udtlang.MSG file contains error message<br />
4432 and a user-defined file (S_ERR) contains error message E009. These messages<br />
contain the following:<br />
1-581 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
T Enters the time in internal format.<br />
W(n) Pauses for n seconds before continuing to display the message.<br />
X Skips the next parameter passed to the UniData message printing routine.<br />
PRINTERR Error Message Codes (continued)<br />
Message 4432 Message E009<br />
in udtlang.MSG in S_ERR<br />
L L(2)<br />
E FILE H => ERR<br />
A(10) S(6)<br />
H DOES NOT EXIST E<br />
L L<br />
H CAN’T PROCEED! A<br />
L H IS NOT PROPERLY SPECIFIED<br />
D L<br />
L<br />
T<br />
L<br />
The following code segment produces an error message if the file you enter for<br />
FNAME cannot be found or you enter 12 for VAR1:<br />
OPEN "S_ERR" TO E_FILE ELSE STOP "S_ERR NOT FOUND"<br />
INPUT FNAME<br />
INPUT VAR1<br />
ER1 = "4432":@FM:FNAME<br />
ER2 = "E009":@FM:"VAR1"<br />
OPEN FNAME TO TFILE ELSE<br />
PRINTERR ER1<br />
STOP<br />
END<br />
IF VAR1 > 10 THEN PRINTERR ER2 FROM E_FILE
If you enter file_test for FNAME and file_test cannot be found, the program segment<br />
produces the following error message:<br />
[4432] FILE test_file DOES NOT EXIST<br />
CAN'T PROCEED!<br />
19 Jan 1996<br />
10:34:19<br />
If you enter 12 for VAR1, the program segment produces the following error<br />
message:<br />
=>ERR [E009]<br />
VAR1 IS NOT PROPERLY SPECIFIED<br />
PRINTERR 1-582
PROCREAD<br />
Syntax<br />
PROCREAD var {THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> PROCREAD command assigns the string value of the primary input<br />
buffer of the calling Proc to a variable. PROCREAD can be used to access the<br />
primary input buffer of a calling proc.<br />
Note: A proc is a PQ-type VOC record.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-583 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
var Specifies variable to which to assign the string value of the<br />
primary input buffer of the calling proc.<br />
THEN statements END THEN executes if this program was called by a proc. END is<br />
required to terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if this program was not called by a proc. END is<br />
required to terminate multiline ELSE statements.<br />
PROCREAD Parameters
Examples<br />
In the following example, the program segment assigns the string value in the<br />
primary input buffer to ARGUMENTS. If the program had been called by something<br />
other than a proc, the program prints a two-line error message.<br />
PROCREAD ARGUMENTS ELSE<br />
PRINT "ERROR!"<br />
PRINT "DIALOUT MUST BE CALLED FROM A PROC"<br />
ABORT<br />
END<br />
The following sample Proc loads the <strong>UniBasic</strong> program name proc.test into the data<br />
stack (Hproc.test), turns on that stack (STON), and loads “ONE” into the primary<br />
output buffer (HONE). The next command (P) executes the data stack entry, which<br />
runs proc.basic. Finally, D0 displays the contents of the active input buffer.<br />
The program proc.test prints after the proc, and a sample execution of the proc<br />
follows the program:<br />
PQ<br />
C<br />
C name: proc.one<br />
C test the interface of basic and PROC.<br />
C<br />
Hproc.test<br />
STON<br />
HONE<br />
P<br />
D0<br />
PROCREAD 1-584
The following globally cataloged program, proc.test, is executed by the preceding<br />
proc. The INPUT statement reads from the currently active output buffer, which the<br />
proc loaded with “ONE”.<br />
1-585 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
*-----------------------------------------------------------------<br />
---------<br />
* subdirectory: interface<br />
* program name: proc.test<br />
* version : 1.6 or later<br />
* compile mode: any<br />
* catalog : y<br />
* catalog flag: local<br />
* test for : accepting passed arguments from a proc and<br />
writing<br />
* data to PROC data buffer (PROCWRITE).<br />
* called by : any proc or executed at the ECL prompt<br />
*-----------------------------------------------------------------<br />
---------*<br />
*<br />
PROGRAM proc.basic<br />
$BASICTYPE 'R'<br />
PRINT '*******************'<br />
PRINT 'TEST --> PROCREAD '<br />
PRINT '*******************'<br />
PROCREAD pname<br />
THEN<br />
len = LEN(pname)<br />
PRINT "The last command executed is stored in the primary input<br />
buffer."<br />
PRINT "The last 10 characters of the 1st buffer are<br />
:":pname[0,len]<br />
PRINT "The length of the primary input buffer is :":LEN(pname)<br />
END ELSE<br />
PRINT "Not run from PROC."<br />
END<br />
PRINT '*******************'<br />
PRINT 'TEST --> PROCWRITE'<br />
PRINT '*******************'<br />
INPUT procname<br />
IF procname = 'ONE' THEN<br />
letters = "abcdefg,1234567,ABCDEFG,tuvwxyz,"<br />
string = ''<br />
limit = 512<br />
FOR I = 1 TO limit STEP 32<br />
string := letters<br />
NEXT I<br />
PRINT "String length = ":LEN(string)
END ELSE<br />
string = "ONE TWO THREE FOUR FIVE"<br />
END<br />
PROCWRITE string<br />
END<br />
The preceding proc and program produce the following output:<br />
:wproctest<br />
*******************<br />
TEST --> PROCREAD<br />
*******************<br />
The last command executed is stored in the primary input buffer.<br />
The last 10 characters of the 1st buffer are :wproctest<br />
The length of the primary input buffer is :9<br />
*******************<br />
TEST --> PROCWRITE<br />
*******************<br />
?ONE<br />
String length = 512<br />
abcdefg,1234567,ABCDEFG,tuvwxyz,abcdefg,1234567,ABCDEFG,tuvwxyz,ab<br />
cdefg,1234567,ABCDEFG,tuvwxyz,abcdefg,1234567,ABCDEFG,tuvwxyz,abcd<br />
efg,1234567,ABCDEFG,tuvwxyz,abcdefg,1234567,ABCDEFG,tuvwxyz,abcdef<br />
g,1234567,ABCDEFG,tuvwxyz,abcdefg,1234567,ABCDEFG,tuvwxyz,abcdefg,<br />
1234567,ABCDEFG,tuvwxyz,abcdefg,1234567,ABCDEFG,tuvwxyz,abcdefg,12<br />
34567,ABCDEFG,tuvwxyz,abcdefg,1234567,ABCDEFG,tuvwxyz,abcdefg,1234<br />
567,ABCDEFG,tuvwxyz,abcdefg,1234567,ABCDEFG,tuvwxyz,abcdefg,123456<br />
7,ABCDEFG,tuvwxyz,abcdefg,1234567,ABCDEFG,tuvwxyz,<br />
Related Command<br />
<strong>UniBasic</strong><br />
PROCWRITE<br />
PROCREAD 1-586
PROCWRITE<br />
Syntax<br />
PROCWRITE expr<br />
Description<br />
The <strong>UniBasic</strong> PROCWRITE command writes data to the primary input buffer of the<br />
calling Proc. PROCWRITE overlays any data in the primary input buffer with the<br />
new data in PROCWRITE.<br />
Example<br />
In the following example, the program segment writes the contents of ANSWER to<br />
the primary input buffer:<br />
1-587 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
PRINT "SEND RESULTS TO THE PRINTER? (Y OR N)"<br />
INPUT ANSWER, Y<br />
IF ANSWER = "Y" THEN<br />
PRINTER ON<br />
...<br />
END<br />
PROCWRITE ANSWER<br />
Note: Another example is provided with PROCREAD.<br />
Related Command<br />
<strong>UniBasic</strong><br />
PROCREAD
PROGRAM<br />
Syntax<br />
PROGRAM prog.name<br />
Description<br />
The <strong>UniBasic</strong> PROGRAM command defines the name of the current main program.<br />
This statement is optional. It is used for documentation purposes only. The<br />
PROGRAM statement must be the first noncomment statement in the program.<br />
Example<br />
In the following example, the program segment declares the program name as<br />
BOOKS:<br />
REM This is a program to bill customers<br />
PROGRAM BILLS<br />
Related Command<br />
<strong>UniBasic</strong><br />
SUBROUTINE<br />
UniData<br />
BASIC, CATALOG – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
PROGRAM 1-588
PROMPT<br />
Syntax<br />
PROMPT str.expr<br />
Description<br />
The <strong>UniBasic</strong> PROMPT command sets the prompt displayed by the INPUT<br />
command to a specified single-byte character. If str.expr is longer than one character,<br />
UniData uses the first character as the prompt. You cannot set the prompt to a<br />
multibyte character.<br />
Data received from a DATA statement displays after the prompt.<br />
If you want to suppress the default prompt character, set the prompt to an empty<br />
string. The default prompt character is the question mark.<br />
Tip: Setting the prompt to an empty string also suppresses display of input from a<br />
DATA statement on the terminal screen. For example:<br />
PROMPT ""<br />
DATA "mypassword"<br />
INPUT PASSWD<br />
will not echo “mypassword” to the terminal screen. The PROMPT statement must<br />
precede the DATA statement.<br />
Data input from the keyboard will still echo on the display terminal.<br />
When you want to display text on the screen and have the cursor remain at the end of<br />
the displayed text awaiting user input, place a colon at the end of the PRINT or<br />
DISPLAY statement.<br />
1-589 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Example<br />
In the following example, the contents of variable PSTRING (in this case, an<br />
asterisk) become the new prompt. When an INPUT command is used in the program,<br />
an asterisk appears at the current cursor position on the display terminal.<br />
PSTRING = "*"<br />
PROMPT PSTRING<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
IN, INPUT, INPUT @, INPUTIF, INPUTTRAP<br />
PROMPT 1-590
protocolLogging<br />
Syntax<br />
protocolLogging(log_file, log_action, log_level)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
This function will start or stop logging.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
The following table describes each log level and detail.<br />
1-591 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
log_file The name of the file to which the logs will be recorded. The default log file<br />
name is httplog which is created under the current directory.<br />
log_action Either “ON” or “OFF”. The default is “OFF”.<br />
log_level The detail level of logging from 0 - 10. See table below.<br />
protocolLogging Parameters<br />
Parameter Description<br />
0 No logging.<br />
1 Socket open/read/write/close action (no real data) HTTP request: host<br />
info(URL)<br />
log_level Details
Parameter Description<br />
2 Level 1 logging plus socket data statistics (size, and so forth).<br />
3 Level 2 logging plus all data actually transferred.<br />
4-10 More detailed status data to assist debugging.<br />
log_level Details (continued)<br />
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success.<br />
1 Failed to start logging.<br />
Return Code Status<br />
protocolLogging 1-592
PWR<br />
Syntax<br />
PWR(num.expr1, num.expr2)<br />
Description<br />
The <strong>UniBasic</strong> PWR function raises expr1 to the power of expr2.<br />
Note: PWR is synonymous with two asterisks (**) or ^.<br />
Example<br />
In the following example, the program segment raises variable X to the power of 3,<br />
first using exponentiation operator **, then using the PWR function, and finally<br />
using the exponentiation operator ^. The results are identical.<br />
X = 2<br />
PRINT X**3<br />
PRINT PWR(X,3)<br />
PRINT X^3<br />
Related Command<br />
^<br />
1-593 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
QUOTE<br />
Syntax<br />
QUOTE(str.expr)<br />
Synonym<br />
DQUOTE<br />
Description<br />
The <strong>UniBasic</strong> QUOTE function encloses a string expression in double quotation<br />
marks.<br />
Examples<br />
In the following example, the program segment encloses the string stored in VAR2<br />
with double quotation marks, and then stores that string (“STRING2”) in VAR3:<br />
VAR2 = "STRING2"<br />
VAR3 = QUOTE(VAR2)<br />
In the following example, the program statement uses DQUOTE to print “This is a<br />
test”:<br />
PRINT DQUOTE ('This is a test')<br />
In the next example, the program segment prints “‘This is another test’”:<br />
X = "This is another test"<br />
PRINT DQUOTE(X)<br />
QUOTE 1-593
Related Command<br />
<strong>UniBasic</strong><br />
SQUOTE<br />
1-594 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
RAISE<br />
Syntax<br />
RAISE(str.expr)<br />
Description<br />
The <strong>UniBasic</strong> RAISE function raises all UniData delimiters to the next level.<br />
UniData raises attribute marks to record marks, value marks to attribute marks, and<br />
subvalue marks to value marks.<br />
Example<br />
In the following example, the program segment raises all delimiters to the next level:<br />
ARRAY = 'Harry Sims':@VM:'114 W. Smith':@SVM:'Suite 220'<br />
ARRAY = RAISE(ARRAY)<br />
This results in the following array:<br />
ARRAY = 'Harry Sims':@FM:'114 W. Smith':@VM:'Suite 220'<br />
Related Command<br />
<strong>UniBasic</strong><br />
LOWER<br />
RAISE 1-595
READ<br />
Syntax<br />
READ dyn.array.var FROM [file.var,] record.ID.expr [ON ERROR statements]<br />
{THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> READ command reads a record from a file and assigns its contents to<br />
a dynamic array. UniData assigns the first attribute of the record to the first position<br />
of the array, the second attribute to the second position, and so on. If UniData cannot<br />
find the record you specify, it executes the ELSE clause and returns dyn.array.var<br />
empty.<br />
Note: This command does not check for locks. If you are operating in a multiuser<br />
environment, you must use record locks to prevent more than one user from accessing<br />
the same record at the same time. For more information about <strong>UniBasic</strong> record<br />
locking, see Developing <strong>UniBasic</strong> Applications.<br />
Warning: Do not use <strong>UniBasic</strong> READ commands to open or modify binary data in<br />
DIR-type files (for example, BP). Doing so could corrupt data in the file. Instead, use<br />
OSREAD or OSBREAD after executing the <strong>UniBasic</strong> NOCONVERT command.<br />
1-596 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dyn.array.var Specifies a target dynamic array for the data being read.<br />
FROM file.var, Specifies a file variable from which to read the record.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal READ error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
record.ID.expr Specifies a record to read.<br />
ON ERROR statements Specifies statements to execute if the READ statement fails with<br />
a fatal error because the file is not open, an I/O error occurs, or<br />
UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record (or ID)<br />
does not exist. END is required to terminate multiline ELSE<br />
statements.<br />
READ Parameters<br />
STATUS Function Return Values<br />
After you execute READ, the STATUS function returns one of the values described<br />
in the following table.<br />
Value Description<br />
0 Successful read.<br />
2 A read error occurred.<br />
5 An encryption error occurred during the READ operation.<br />
STATUS Function Values<br />
READ 1-597
Example<br />
In the following example, the program segment reads a record from the CLIENTS<br />
file with ID CLIENT.ID. If the record ID is found, UniData executes the subroutine<br />
PROCESS.CLIENT. Otherwise, UniData prints a message and the program performs<br />
the subroutine REPROMPT.<br />
1-598 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
READ CLIENT.REC FROM CLIENT, CLIENT.ID THEN<br />
GOSUB PROCESS.CLIENT<br />
END ELSE<br />
PRINT 'NO CLIENT REC FOR 'CLIENT.ID<br />
END<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLOSE, DELETE, OPEN, READL, READU, READV, READVL, READVU,<br />
WRITE
READBCK<br />
Syntax<br />
READBCK dyn.array.var [FROM file.var] [ON ERROR statements] {THEN<br />
statements [END] | ELSE statements [END]}<br />
Description<br />
The first READBCK command retrieves the alternate key set by SETINDEX, then<br />
each subsequent READBCK retrieves the previous alternate key value in the index.<br />
The corresponding record is read into a dynamic array, and the record ID is assigned<br />
to the @ID variable.<br />
Note: This command does not check for locks. If you are operating in a multiuser<br />
environment, you must use record locks to prevent more than one user from accessing<br />
the same record at the same time. For more information about <strong>UniBasic</strong> record<br />
locking, see Developing <strong>UniBasic</strong> Applications.<br />
Using this command in a loop, a <strong>UniBasic</strong> program retrieves records in descending<br />
order based on an indexed attribute.<br />
Before executing READBCK, you must set the alternate key value with the<br />
SETINDEX command. The SETINDEX parameters BUFFER.KEYS and<br />
VALIDATE.KEY determine, respectively, whether the buffering mechanism is used<br />
and whether keys are validated when READBCK executes. For details, see<br />
SETINDEX.<br />
READBCK sets the STATUS function return value to 10 if <strong>UniBasic</strong> detects a<br />
duplicate alternate index key value and you have executed the ECL command<br />
DUP.STATUS ON during the current session.<br />
READBCK 1-599
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
STATUS Function Return Values<br />
After you execute READBCK, the STATUS function returns one of the values<br />
described in the following table.<br />
1-600 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
dyn.array.var Specifies a dynamic array to which to assign the values read.<br />
FROM file.var Specifies a file variable from which to read the record.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
ON ERROR statements Specifies statements to execute if the READBCK statement fails<br />
with a fatal error because the file is not open, an I/O error occurs,<br />
or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record does not<br />
exist. END is required to terminate multiline ELSE statements.<br />
READBCK Parameters<br />
Paramete<br />
r Description<br />
0 Successful read.<br />
10 <strong>UniBasic</strong> found and read a duplicate alternate index key value, and ECL<br />
DUP.STATUS is on.<br />
STATUS Function Return Values
Example<br />
In the following example, the program segment sets the index to the first record that<br />
contains Smith, and then reads that record and the previous four:<br />
OPEN 'CLIENTS' TO tmp ELSE STOP<br />
SETINDEX 'LNAME', 'Smith' ON tmp<br />
FOR X = 1 TO 5<br />
READBCK rec FROM tmp THEN PRINT rec:", ":rec:" ":rec<br />
ELSE STOP<br />
NEXT X<br />
END<br />
The preceding program produces the following results:<br />
Marge, Smith Smith Widgets<br />
Pearl, Sloane Harvard Assoc.<br />
Reginald, Sklar Culver Excavating<br />
Alexandria, Singleton Vintech Inc.<br />
Larry, Singh Smith Widgets<br />
Note: This program reads the records even if the records are locked by another user.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
READBCKL, READBCKU, READFWD, READFWDL, READFWDU,<br />
READXBCK, READXFWD, SELECTINDEX, SETINDEX<br />
UniData<br />
BUILD.INDEX, CREATE.INDEX, DUP.STATUS – For information, see the<br />
UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
READBCK 1-601
READBCKL<br />
Syntax<br />
READBCKL dyn.array.var [FROM file.var] [ON ERROR statements]<br />
[LOCKED statements] {THEN statements [END] | ELSE statements [END]}<br />
READBCKL dyn.array.var [FROM file.var] [LOCKED statements]<br />
[ON ERROR statements] {THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The first READBCKL command retrieves the alternate key set by SETINDEX, and<br />
then each subsequent READBCKL retrieves the previous alternate key in the index.<br />
The corresponding record is read into a dynamic array, and the record ID is assigned<br />
to the @ID variable. READBCKL checks for locks. If the record is available, it sets<br />
a shared (L) lock before reading the record.<br />
Note: <strong>UniBasic</strong> locks are advisory only. For more information, see Developing<br />
<strong>UniBasic</strong> Applications.<br />
Using this command in a loop, a <strong>UniBasic</strong> program retrieves records in descending<br />
order based on an indexed attribute.<br />
Before executing READBCKL, you must set the pointer in the alternate key file with<br />
the SETINDEX command. The SETINDEX parameters BUFFER.KEYS and<br />
VALIDATE.KEY determine, respectively, whether the buffering mechanism is used<br />
and whether keys are validated when READBCKL executes. For details, see<br />
SETINDEX.<br />
READBCKL sets the STATUS function return value to 10 if <strong>UniBasic</strong> detects a<br />
duplicate alternate index key value and you have executed the ECL command<br />
DUP.STATUS ON during the current session.<br />
1-602 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dyn.array.var Specifies a target dynamic array to receive the data read.<br />
FROM file.var Specifies a file variable from which to read the record.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
ON ERROR statements Specifies statements to execute if the READBCKL statement<br />
fails with a fatal error because the file is not open, an I/O error<br />
occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
LOCKED statements Specifies statements to execute if the record is already locked.<br />
If you do not specify the LOCKED clause, and if the record is<br />
locked, UniData waits until the record is available.<br />
Use the ECL command DEFAULT.LOCKED.ACTION BELL<br />
to make the terminal beep while you wait for UniData to<br />
unlock the record.<br />
THEN statements END THEN executes if the read is not successful. END is required<br />
to terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful, the current<br />
alternate key value is not set by the SETINDEX command, or<br />
UniData cannot locate the current alternate key value (for<br />
example, when UniData reaches the end of the alternate<br />
index). END is required to terminate multiline ELSE<br />
statements.<br />
READBCKL Parameters<br />
READBCKL 1-603
STATUS Function Return Values<br />
After you execute READBCKL, the STATUS function returns one of the values<br />
described in the following table.<br />
Value Description<br />
0 Successful read.<br />
Example<br />
This example uses the following program to lock the CLIENT file for two minutes:<br />
1-604 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
10 <strong>UniBasic</strong> found and read a duplicate alternate index key value, and ECL<br />
DUP.STATUS is on.<br />
STATUS Function Return Values<br />
OPEN "CLIENTS" TO CLIENT.FILE ELSE STOP<br />
FILELOCK CLIENT.FILE LOCKED PRINT "CLIENTS FILE already locked."<br />
SLEEP 120<br />
FILEUNLOCK CLIENT.FILE<br />
If you execute the following program:<br />
OPEN 'CLIENTS' TO tmp ELSE STOP<br />
SETINDEX 'LNAME', 'Smith' ON tmp<br />
FOR X = 1 TO 5<br />
READBCKL rec FROM tmp THEN PRINT rec:", ":rec:" ":rec<br />
ELSE STOP<br />
NEXT X<br />
END<br />
Notice that execution halts on the second program until the first program unlocks the<br />
CLIENTS file. This is because commands that set shared locks cannot access files<br />
locked with exclusive locks (FILELOCK sets an exclusive lock).<br />
Note: If the first program had set a shared lock, the second program would have been<br />
able to read the records.
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
READBCK, READBCKU, READFWD, READFWDL, READFWDU,<br />
READXBCK, READXFWD, SELECTINDEX, SETINDEX<br />
UniData<br />
BUILD.INDEX, CREATE.INDEX, DEFAULT.LOCKED.ACTION, DUP.STATUS<br />
– For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
READBCKL 1-605
READBCKU<br />
Syntax<br />
READBCKU dyn.array.var [FROM file.var] [ON ERROR statements]<br />
[LOCKED statements] {THEN statements [END] | ELSE statements [END]}<br />
READBCKU dyn.array.var [FROM file.var] [LOCKED statements]<br />
[ON ERROR statements] {THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The first READBCKU command retrieves the alternate key set by SETINDEX, and<br />
then each subsequent READBCKU retrieves the previous alternate key value in the<br />
index. The corresponding record is read into a dynamic array, and the record ID is<br />
assigned to the @ID variable. READBCKU checks for locks. If the record is<br />
available, it sets an exclusive (U) lock before reading the record.<br />
Note: <strong>UniBasic</strong> locks are advisory only. For more information, see Developing<br />
<strong>UniBasic</strong> Applications.<br />
Using this command in a loop, a <strong>UniBasic</strong> program retrieves records in descending<br />
order based on an indexed attribute.<br />
Before executing READBCKU, you must set the alternate key value with the<br />
SETINDEX command. The SETINDEX parameters BUFFER.KEYS and<br />
VALIDATE.KEY determine, respectively, whether the buffering mechanism is used<br />
and whether keys are validated when READBCKU executes. For details, see<br />
SETINDEX.<br />
READBCKU sets the STATUS function return value to 10 if <strong>UniBasic</strong> detects a<br />
duplicate alternate index key value and you have executed the ECL command<br />
DUP.STATUS ON during the current session.<br />
1-606 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dyn.array.var Specifies a target dynamic array to receive the data read.<br />
FROM file.var Specifies a file variable from which to read the record.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
ON ERROR<br />
statements<br />
Specifies statements to execute if the READBCKU statement<br />
fails with a fatal error because the file is not open, an I/O error<br />
occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
LOCKED statements Specifies statements to execute if the record is already locked. If<br />
you do not specify the LOCKED clause, and if the record is<br />
locked, UniData waits until the record is available.<br />
Use the ECL command DEFAULT.LOCKED.ACTION BELL<br />
to make the terminal beep while you wait for UniData to unlock<br />
the record.<br />
THEN statements END THEN executes if the read is not successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful, the current alternate<br />
key value is not set by the SETINDEX command, or UniData<br />
cannot locate the current alternate key value (for example, when<br />
UniData reaches the end of the alternate index). END is required<br />
to terminate multiline ELSE statements.<br />
READBCKU Parameters<br />
READBCKU 1-607
STATUS Function Return Values<br />
After you execute READBCKU, the STATUS function returns one of the values<br />
described in the following table.<br />
Value Description<br />
0 Successful read.<br />
Example<br />
This example uses the following program to lock the CLIENT file for two minutes:<br />
1-608 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
10 <strong>UniBasic</strong> found and read a duplicate alternate index key value, and ECL<br />
DUP.STATUS is on.<br />
STATUS Function Return Values<br />
OPEN 'CLIENTS' TO tmp ELSE STOP<br />
SETINDEX 'LNAME', 'Smith' ON tmp<br />
READBCKU rec FROM tmp THEN PRINT rec:", ":rec:" ":rec<br />
ELSE STOP<br />
SLEEP 60<br />
END<br />
If you execute the following program:<br />
OPEN 'CLIENTS' TO tmp ELSE STOP<br />
SETINDEX 'LNAME', 'Smith' ON tmp<br />
FOR X = 1 TO 5<br />
READBCKU rec FROM tmp THEN PRINT rec:", ":rec:" ":rec<br />
ELSE STOP<br />
NEXT X<br />
END<br />
Notice that execution halts on the second program until the first program unlocks the<br />
record associated with “Smith.” This is because commands that set exclusive locks<br />
cannot access records lock with any kind of lock.
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
READBCK, READBCKL, READFWD, READFWDL, READFWDU,<br />
READXBCK, READXFWD, SELECTINDEX, SETINDEX<br />
UniData<br />
BUILD.INDEX, CREATE.INDEX, DEFAULT.LOCKED.ACTION, DUP.STATUS<br />
– For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
READBCKU 1-609
READFWD<br />
Syntax<br />
READFWD dyn.array.var [FROM file.var] [ON ERROR statements] {THEN<br />
statements [END] | ELSE statements [END]}<br />
Description<br />
The first READFWD command retrieves the alternate key set by SETINDEX, and<br />
then each subsequent READFWD retrieves the next alternate key value in the index.<br />
UniData reads the corresponding record into a dynamic array, and then assigns the<br />
record ID to the @ID variable.<br />
Note: This command does not check for locks. If you are operating in a multiuser<br />
environment, you must use record locks to prevent more than one user from accessing<br />
the same record at the same time. For more information about the <strong>UniBasic</strong> record<br />
locking, see Developing <strong>UniBasic</strong> Applications.<br />
Using this command in a loop, a <strong>UniBasic</strong> program retrieves records in ascending<br />
order based on an indexed attribute.<br />
Before executing READFWD, you must set a pointer to an alternate key value with<br />
the SETINDEX command. The SETINDEX parameters BUFFER.KEYS and<br />
VALIDATE.KEY determine, respectively, whether the buffering mechanism is used<br />
and whether keys are validated when READFWD executes. For details, see<br />
SETINDEX.<br />
READFWD sets the STATUS function return value to 10 if <strong>UniBasic</strong> detects a<br />
duplicate alternate index key value and you have executed the ECL command<br />
DUP.STATUS ON during the current session.<br />
1-610 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dyn.array.var Specifies a dynamic array to contain the record.<br />
FROM file.var Specifies a file from which to read the record.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
ON ERROR statements Specifies statements to execute if the READFWD statement<br />
fails with a fatal error because the file is not open, an I/O error<br />
occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record does not<br />
exist. END is required to terminate multiline ELSE statements.<br />
READFWD Parameters<br />
STATUS Function Return Values<br />
After you execute READFWD, the STATUS function returns one of the values<br />
described in the following table.<br />
Value Description<br />
0 Successful read.<br />
10 <strong>UniBasic</strong> found and read a duplicate alternate index key value, and ECL<br />
DUP.STATUS is on.<br />
STATUS Function Return Values<br />
READFWD 1-611
Example<br />
In the following example, the program segment sets the index to the first record that<br />
contains Smith, and then reads that record and the next four:<br />
1-612 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
OPEN 'CLIENTS' TO tmp ELSE STOP<br />
SETINDEX 'LNAME', 'Singh' ON tmp<br />
FOR X = 1 TO 5<br />
READFWD rec FROM tmp THEN PRINT rec:", ":rec:" ":rec<br />
ELSE STOP<br />
NEXT X<br />
This program produces the following results:<br />
Charles, Singh Goddard Fabrics<br />
Larry, Singh Smith Widgets<br />
Alexandria, Singleton Vintech Inc.<br />
Reginald, Sklar Culver Excavating<br />
Pearl, Sloane Harvard Assoc.<br />
Note: This program reads the records even if the records are locked by other users.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
READBCK, READBCKL, READBCKU, READFWDL, READFWDU,<br />
READXFWD, READXBCK, SELECTINDEX, SETINDEX<br />
UniData<br />
BUILD.INDEX, CREATE.INDEX, DUP.STATUS – For information, see the<br />
UniData <strong>Commands</strong> <strong>Reference</strong>.
READFWDL<br />
Syntax<br />
READFWDL dyn.array.var [FROM file.var] [ON ERROR statements]<br />
[LOCKED statements] {THEN statements [END] | ELSE statements [END]}<br />
READFWDL dyn.array.var [FROM file.var] [LOCKED statements]<br />
[ON ERROR statements] {THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The first READFWDL command retrieves the alternate key set by SETINDEX, and<br />
then each subsequent READFWDL retrieves the next alternate key value in the<br />
index. UniData reads the corresponding record into a dynamic array, and then assigns<br />
the record ID to the @ID variable. READFWDL checks for locks. If the record is<br />
available, it sets a shared (L) lock.<br />
Note: <strong>UniBasic</strong> locks are advisory only. For more information, see Developing<br />
<strong>UniBasic</strong> Applications.<br />
Using this command in a loop, a <strong>UniBasic</strong> program retrieves records in ascending<br />
order based on an indexed attribute.<br />
Before executing READFWDL, you must set a pointer to an alternate key value with<br />
the SETINDEX command. The SETINDEX parameters BUFFER.KEYS and<br />
VALIDATE.KEY determine, respectively, whether the buffering mechanism is used<br />
and whether keys are validated when READFWDL executes. For details, see<br />
SETINDEX.<br />
READFWDL sets the STATUS function return value to 10 if <strong>UniBasic</strong> detects a<br />
duplicate alternate index key value and you have executed the ECL command<br />
DUP.STATUS ON during the current work session.<br />
READFWDL 1-613
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-614 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
dyn.array.var Specifies a dynamic array to contain the record.<br />
FROM file.var Specifies a file variable from which to read the record.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal READ error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
ON ERROR statements Specifies statements to execute if the READFWDL statement<br />
fails with a fatal error because the file is not open, an I/O error<br />
occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
LOCKED statements Specifies statements to execute if the record is locked by<br />
another user. If you do not specify a LOCKED clause, the<br />
program waits until the lock on the record is released.<br />
Use the ECL command DEFAULT.LOCKED.ACTION BELL<br />
to make the terminal beep while you wait for UniData to unlock<br />
the record.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record does<br />
not exist. END is required to terminate multiline ELSE<br />
statements.<br />
READFWDL Parameters
STATUS Function Return Values<br />
After you execute READFWDL, the STATUS function returns one of the values<br />
described in the following table.<br />
Value Description<br />
0 Successful read.<br />
10 <strong>UniBasic</strong> found and read a duplicate alternate index key value, and ECL<br />
DUP.STATUS is on.<br />
STATUS Function Return Values<br />
Example<br />
This example uses the following program to lock the CLIENT file for two minutes:<br />
OPEN "CLIENTS" TO CLIENT.FILE ELSE STOP<br />
FILELOCK CLIENT.FILE LOCKED PRINT "CLIENTS FILE already locked."<br />
SLEEP 120<br />
FILEUNLOCK CLIENT.FILE<br />
If you execute the following program:<br />
OPEN 'CLIENTS' TO tmp ELSE STOP<br />
SETINDEX 'LNAME', 'Smith' ON tmp<br />
FOR X = 1 TO 5<br />
READFWDL rec FROM tmp THEN PRINT rec:", ":rec:" ":rec<br />
ELSE STOP<br />
NEXT X<br />
END<br />
Notice that execution halts on the second program until the first program unlocks the<br />
CLIENTS file. This is because commands that set shared locks cannot access files<br />
locked with exclusive locks (FILELOCK sets an exclusive lock).<br />
Note: If the first program had set a shared lock, the second program would have been<br />
able to read the records.<br />
READFWDL 1-615
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
READBCK, READBCKL, READBCKU, READFWD, READFWDU,<br />
READXBCK, READXFWD, SELECTINDEX, SETINDEX<br />
UniData<br />
BUILD.INDEX, CREATE.INDEX, DEFAULT.LOCKED.ACTION, DUP.STATUS<br />
– For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
1-616 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
READFWDU<br />
Syntax<br />
READFWDU dyn.array.var [FROM file.var] [ON ERROR statements]<br />
[LOCKED statements] {THEN statements [END] | ELSE statements [END]}<br />
READFWDU dyn.array.var [FROM file.var] [LOCKED statements]<br />
[ON ERROR statements] {THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The first READFWDU command retrieves the alternate key set by SETINDEX, and<br />
then each subsequent READFWDU retrieves the next alternate key value in the<br />
index. UniData reads the corresponding record into a dynamic array, and then assigns<br />
the record ID to the @ID variable. READFWDU checks for locks. If the record is<br />
available, READFWDU sets an exclusive (U) lock before reading the record.<br />
Note: <strong>UniBasic</strong> locks are advisory only. For more information, see Developing<br />
<strong>UniBasic</strong> Applications.<br />
Using this command in a loop, a <strong>UniBasic</strong> program retrieves records in ascending<br />
order based on an indexed attribute.<br />
Before executing READFWDU, you must set a pointer to the alternate key value<br />
with the SETINDEX command.<br />
READFWDU sets the STATUS function return value to 10 if <strong>UniBasic</strong> detects a<br />
duplicate alternate index key value and you have executed the ECL command<br />
DUP.STATUS ON during the current work session.<br />
READFWDU 1-617
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-618 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
dyn.array.var Specifies a dynamic array to contain the record.<br />
FROM file.var Specifies a file from which to read the record.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
ON ERROR statements Specifies statements to execute if the READFWDU statement<br />
fails with a fatal error because the file is not open, an I/O error<br />
occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
LOCKED statements Specifies statements to execute if the record is locked by<br />
another user. If you do not specify a LOCKED clause, the<br />
program waits until the lock on the record is released.<br />
Use the ECL command DEFAULT.LOCKED.ACTION BELL<br />
to make the terminal beep while you wait for UniData to unlock<br />
the record.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record does<br />
not exist. END is required to terminate multiline ELSE<br />
statements.<br />
READFWDU Parameters
STATUS Function Return Values<br />
After you execute READFWDU, the STATUS function returns one of the values<br />
described in the following table.<br />
Value Description<br />
0 Successful read.<br />
10 <strong>UniBasic</strong> found and read a duplicate alternate index key value, and ECL<br />
DUP.STATUS is on.<br />
STATUS Function Return Values<br />
Example<br />
This example uses the following program to lock the CLIENT file for two minutes:<br />
OPEN 'CLIENTS' TO tmp ELSE STOP<br />
SETINDEX 'LNAME', 'Smith' ON tmp<br />
READFWDU rec FROM tmp THEN PRINT rec:", ":rec:" ":rec<br />
ELSE STOP<br />
SLEEP 120<br />
END<br />
If you execute the following program:<br />
OPEN 'CLIENTS' TO tmp ELSE STOP<br />
SETINDEX 'LNAME', 'Smith' ON tmp<br />
FOR X = 1 TO 5<br />
READFWDU rec FROM tmp THEN PRINT rec:", ":rec:" ":rec<br />
ELSE STOP<br />
NEXT X<br />
END<br />
Notice that execution halts on the second program until the first program unlocks the<br />
record associated with “Smith.” This is because commands that set exclusive locks<br />
cannot access records lock with any kind of lock.<br />
READFWDU 1-619
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
READBCK, READBCKL, READBCKU, READFWD, READFWDL,<br />
READXBCK, READXFWD, SELECTINDEX, SETINDEX<br />
UniData<br />
BUILD.INDEX, CREATE.INDEX, DEFAULT.LOCKED.ACTION, DUP.STATUS<br />
– For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
1-620 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
READL<br />
Syntax<br />
READL dyn.array.var FROM [file.var,] record.ID.expr [ON ERROR statements]<br />
[LOCKED statements] {THEN statements [END] | ELSE statements [END]}<br />
READL dyn.array.var FROM [file.var,] record.ID.expr [LOCKED statements]<br />
[ON ERROR statements] {THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> READL command reads the specified record from a file and assigns<br />
its contents to a dynamic array. UniData assigns the first attribute of the record to the<br />
first position of the array, the second attribute to the second position, and so on.<br />
READL checks for locks. If the record is available, it sets a read-only lock on the<br />
record, preventing other lock-checking commands from updating it.<br />
Note: <strong>UniBasic</strong> locks are advisory only. For more information, see Developing<br />
<strong>UniBasic</strong> Applications.<br />
Warning: Do not use <strong>UniBasic</strong> READ and WRITE commands to open or modify<br />
binary data in DIR-type files (for example, BP). Doing so could corrupt data in the<br />
file. Instead, use OSREAD or OSBREAD after executing the <strong>UniBasic</strong> NOCONVERT<br />
command.<br />
READL 1-621
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-622 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
dyn.array.var Specifies a dynamic array to receive the record.<br />
FROM file.var Specifies a file from which to read the record.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
ON ERROR statements Specifies statements to execute if the READL statement fails<br />
with a fatal error because the file is not open, an I/O error occurs,<br />
or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
LOCKED statements Specifies statements to execute if the record is locked by another<br />
user (with an exclusive lock). If you do not specify a LOCKED<br />
clause, the program waits until the lock on the record is released.<br />
Use the ECL command DEFAULT.LOCKED.ACTION BELL<br />
to make the terminal beep while you wait for UniData to unlock<br />
the record.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record does not<br />
exist. END is required to terminate multiline ELSE statements.<br />
READL Parameters
STATUS Function Return Values<br />
After you execute READL, the STATUS function returns one of the values described<br />
in the following table.<br />
Examples<br />
This example uses the following program to lock the ORDERS file for two minutes:<br />
OPEN "ORDERS" TO ORDER.FILE ELSE STOP<br />
FILELOCK ORDER.FILE LOCKED PRINT "ORDERS FILE already locked."<br />
SLEEP 120<br />
FILEUNLOCK ORDER.FILE<br />
If you immediately execute the following program:<br />
OPEN "ORDERS" TO tmp ELSE STOP<br />
READL rec FROM tmp,'941' THEN PRINT rec LOCKED PRINT "Record<br />
locked, try again later"<br />
END<br />
the second program prints “Record locked, try again later”.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
Value Description<br />
0 Successful read.<br />
1 UniData was unable to read the record.<br />
n The record is locked. The user number of the user who locked<br />
the record.<br />
STATUS Function Return Values<br />
CLOSE, DELETE, OPEN, READ, READU, READV, READVL, READVU,<br />
WRITE<br />
READL 1-623
UniData<br />
DEFAULT.LOCKED.ACTION – For information, see the UniData <strong>Commands</strong><br />
<strong>Reference</strong>.<br />
1-624 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
READLIST<br />
Syntax<br />
READLIST dyn.array.var [FROM list.num] {THEN statements [END] | ELSE<br />
statements [END]}<br />
Synonym<br />
READSELECT (BASICTYPE P only)<br />
Description<br />
The <strong>UniBasic</strong> READLIST command assigns the values in an active select list to a<br />
dynamic array. Each select list element becomes an attribute in the dynamic array.<br />
Note: Use the following syntax in BASICTYPE M:<br />
READLIST dyn.array.var FROM list.num [, acct.name] [SETTING count.var]<br />
{THEN statements [END] | ELSE statements [END]}<br />
If you create a list under an account other than the current one, you can specify the<br />
account with acct.name. The SETTING clause sets the number of elements in the list<br />
to count.var.<br />
In BASICTYPE P, use the READSELECT command with the following syntax:<br />
READSELECT dyn.array.var [FROM list.name] {THEN statements [END] | ELSE<br />
statements [END]}<br />
READLIST 1-625
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Example<br />
In the following example, the program segment selects the IDs in the INVENTORY<br />
file to select list 0, and then builds a dynamic array of the items for which quantity in<br />
stock is greater than 10. The last program statement prints the select list to show its<br />
contents.<br />
1-626 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
dyn.array.var Specifies a dynamic array to contain the values removed from<br />
the select list.<br />
FROM list.num Specifies which select list (0-9) you want to use. If you do not<br />
specify a list.num, UniData reads the default list (0). If no items<br />
are available in the list, UniData executes the ELSE clause.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the list does not<br />
exist. END is required to terminate multiline ELSE statements.<br />
READLIST Parameters<br />
OPEN 'INVENTORY' TO INV.FILE ELSE STOP<br />
SELECT INV.FILE<br />
DONE = 0<br />
LOOP<br />
READNEXT INV.ID ELSE DONE = 1<br />
WHILE NOT(DONE) DO<br />
READ INV.REC FROM INV.FILE,INV.ID ELSE<br />
PRINT "No INVENTORY RECORD: ":INV.ID<br />
END<br />
IF INV.REC > 9 THEN<br />
READLIST LIST.ITEM ELSE LIST.ITEM = " "<br />
END<br />
REPEAT<br />
PRINT LIST.ITEM
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DELETELIST, FORMLIST, GETLIST, READNEXT, SELECT,<br />
SELECTINDEX, SELECTINFO, WRITELIST<br />
UniQuery<br />
DELETE.LIST, GET.LIST, SELECT, SAVE.LIST, SSELECT – For information, see<br />
the UniQuery <strong>Commands</strong> <strong>Reference</strong>.<br />
UniData SQL<br />
SELECT – For information, see the UniData SQL <strong>Commands</strong> <strong>Reference</strong>.<br />
READLIST 1-627
READNEXT<br />
Syntax<br />
READNEXT id.var [, val.var[, subval.var]] [FROM list.num.expr]<br />
[ON ERROR statements] {THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> READNEXT command assigns the next record ID from an active<br />
select list to a variable.<br />
Note: READNEXT does not actually read the record, but assigns it to a variable.<br />
After the variable is assigned, you can use it within a READ statement to access it.<br />
As an example, a customer transaction might require that data be read in a particular<br />
sequence. The sequence is determined by using a sorted SELECT statement to select<br />
IDs in the appropriate order and then using the READNEXT statement to assign an<br />
ID to a variable.<br />
Note: READNEXT performs differently with BASICTYPEs M and P as shown in the<br />
following syntax:<br />
READNEXT var FROM list.name {, acct.name}<br />
[SETTING count.var] {THEN statements [END] | ELSE statements [END]}<br />
The SETTING clause assigns the number of elements in the list to the variable<br />
count.var.<br />
READNEXT and Multivalued Attributes<br />
Select lists used by READNEXT can contain an optional value and subvalue<br />
positions (if you create the list using the BY.EXP keyword). The select list created by<br />
using this keyword is sorted based on a multivalued or subvalued attribute. The select<br />
list contains, in each of two attributes, the record ID and position of the sorted value<br />
or subvalue. The READNEXT command passes the value or subvalue positions to<br />
val.var and subval.var. A subsequent READ statement might access the appropriate<br />
value using val.var (and subval.var).<br />
1-628 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Note: When you create a select list using the BY.EXP keyword against a multivalued<br />
or multi-subvalued attribute, the resulting select list contains the multivalue position<br />
in the second value of the attribute and the multi-subvalue position in the third value<br />
of the attribute. If a BY.EXP select statement is executed against an attribute with a<br />
value code specifier of MV, the third value in each attribute in the resulting select list<br />
is -5 as the following shows:<br />
001: 785}1}-5<br />
002: 796}1}-5<br />
003: 812}1}-5<br />
...<br />
READNEXT assigns the values and subvalues of each record ID to val.var and<br />
subval.var. The val.var and subval.var each can contain more than one data value<br />
(separated by value or subvalue marks) if you use more than one BY.EXP keyword<br />
when you create the select list. In this case, the first subvalue in val.var and in<br />
subval.var corresponds to the value and subvalue position of the attribute in the first<br />
BY.EXP expression. The second subvalue in val.var and in subval.var corresponds<br />
to the value and subvalue position of the attribute in the second BY.EXP clause, and<br />
so forth for each successive BY.EXP clause.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
id.var Specifies a variable to contain the value of the next record ID.<br />
,val.var,subval.var Specifies a value and subvalue to read.<br />
FROM list.num.expr Specifies which select list (0-9) you want to use. If you do not<br />
specify list.num, the default (0) list is used. If no items are<br />
available in the list, UniData executes the ELSE clause.<br />
READNEXT Parameters<br />
READNEXT 1-629
Parameter Description<br />
Examples<br />
In the following example, the program segment reads 10 IDs from select list 1, and<br />
then reads the records associated with those IDs. If a record ID is not found in the<br />
default system file, the program displays the message NOT FOUND.<br />
1-630 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ON ERROR statements Specifies statements to execute if the READNEXT statement<br />
fails with a fatal error because the file is not open, an I/O error<br />
occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the user enters the debugger.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record does<br />
not exist. END is required to terminate multiline ELSE<br />
statements.<br />
READNEXT Parameters (continued)<br />
FOR I = 1 TO 10<br />
READNEXT ID FROM 1 ELSE SHORT.LIST = 1 THEN<br />
READU REC FROM CUST,ID ELSE PRINT "NOT FOUND"<br />
END<br />
NEXT I
In the next example, the program selects all Canadian clients, and then executes<br />
READNEXT to read and display the records for the first 22:<br />
EXECUTE 'SELECT CLIENTS WITH COUNTRY = "Canada"'<br />
EXECUTE "SAVE.LIST 'canadians'"<br />
OPEN 'CLIENTS' TO CLIENT.FILE ELSE ABORT<br />
GETLIST 'canadians' SETTING LIST.CNT<br />
ELSE PRINT CLIENT:" SAVELISTS ID ‘canadians’ CANNOT BE<br />
FOUND";STOP<br />
PRINT @(-1)<br />
FOR I = 1 TO 22<br />
READNEXT ID ELSE EXIT<br />
READ REC FROM CLIENT.FILE, ID THEN<br />
PRINT @(5,I):REC:@(20,I):REC<br />
END ELSE<br />
PRINT "CANNOT FIND RECORD":ID<br />
END<br />
NEXT I<br />
CLEARSELECT<br />
END<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DELETELIST, FORMLIST, GETLIST, READLIST, SELECT, SELECTINDEX,<br />
SELECTINFO, WRITELIST<br />
UniQuery<br />
DELETE.LIST, GET.LIST, SAVE.LIST, SELECT, SSELECT – For information, see<br />
the UniQuery <strong>Commands</strong> <strong>Reference</strong>.<br />
UniData SQL<br />
SELECT – For information, see the UniData SQL <strong>Commands</strong> <strong>Reference</strong>.<br />
READNEXT 1-631
READNEXTTUPLE<br />
Syntax<br />
READNEXTTUPLE dyn.array.var FROM file.name.expr {THEN<br />
statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> READNEXTTUPLE command assigns the next entire record to a<br />
variable. The record ID is obtained from an active select list that was created by a<br />
UniData SQL SELECT statement during the current work session.<br />
READNEXTTUPLE creates a dynamic array delimited by attribute marks (@AM).<br />
The attribute marks are entered by the UniData SQL SELECT statement.<br />
Tip: Do not use the UniData SQL UNNEST command in the SQL statement that<br />
creates the ID list. UniData might not return the entire record with attribute marks,<br />
value marks, and/or subvalue marks if you use UNNEST.<br />
1-632 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dyn.array.var Specifies the dynamic array to contain the record.<br />
FROM file.name.expr Specifies the file from which to read the next record ID.<br />
file.name.expr must have been created during the current session<br />
by:<br />
An EXECUTESQL statement with a TO clause in the <strong>UniBasic</strong><br />
program.<br />
A UniData SQL statement executed at the ECL prompt before<br />
the program was run.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful, the record does not<br />
exist, or the last record has been read. END is required to<br />
terminate multiline ELSE statements.<br />
READNEXTTUPLE Parameters<br />
READNEXTTUPLE 1-633
Example<br />
In the following example, the program segment executes a UniData SQL statement<br />
and stores the output in an internal result file called SQL_INPUT. The<br />
READNEXTTUPLE statement then reads the records stored in SQL_INPUT until<br />
the last record item is read. The process converts the attribute marks to spaces and<br />
prints each record read.<br />
1-634 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
OUT.COMMAND = "SELECT NAME, ADDRESS, CITY"<br />
OUT.COMMAND := " FROM CLIENTS TO SQL_INPUT; "<br />
EXECUTESQL OUT.COMMAND<br />
DONE = 0<br />
BPIOCP<br />
LOOP<br />
READNEXTTUPLE CLIENT.REC FROM "SQL_INPUT" ELSE<br />
DONE = 1<br />
END<br />
UNTIL DONE DO<br />
CONVERT @AM TO " " IN CLIENT.REC<br />
CONVERT @VM TO","IN CLIENT.REC<br />
PRINT CLIENT.REC<br />
REPEAT<br />
END<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
EXECUTE, EXECUTESQL<br />
UniData SQL<br />
SELECT – For information, see Using UniData SQL.
READSELECT<br />
READSELECT is a synonym for the READLIST command. For more information,<br />
see READLIST.<br />
Synonym<br />
READLIST<br />
READSELECT 1-635
READSEQ<br />
Syntax<br />
READSEQ var FROM seq.file.var {THEN statements [END] | ELSE statements<br />
[END]}<br />
Description<br />
The <strong>UniBasic</strong> READSEQ command reads the next record from a sequential file and<br />
assigns the data read to a variable.<br />
Note: Before you use READSEQ, you must open the file by using the OSOPEN or<br />
OPENSEQ command.<br />
If the file is a named pipe, you cannot use READSEQ to read it. You must use the<br />
OSBREAD command.<br />
Each read from the sequential file searches for a line feed character [CHAR(10)] to<br />
determine the end of the record. READSEQ maintains a pointer to the current<br />
position in the file (where the last record terminated).<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-636 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
var Specifies a variable to which to assign the record.<br />
READSEQ Parameters
Parameter Description<br />
FROM seq.file.var Specifies a sequential file from which to read the record.<br />
seq.file.var must be a sequential file opened by using an<br />
OPENSEQ or OSOPEN statement.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record does not<br />
exist. END is required to terminate multiline ELSE statements.<br />
Example<br />
In the following example, the program statement reads the next record in the file<br />
PORT.FILE and assigns it to the variable TAX.REC:<br />
READSEQ TAX.REC FROM PORT.FILE ELSE STOP "Can’t READSEQ TAX.REC"<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
READSEQ Parameters (continued)<br />
CLOSESEQ, OPENSEQ, OSBREAD, OSBWRITE, OSCLOSE, OSDELETE,<br />
OSOPEN, WRITESEQ, WRITESEQF<br />
READSEQ 1-637
eadSocket<br />
Syntax<br />
readSocket(socket_handle, socket_data, max_read_size, time_out, blocking_mode,<br />
actual_read_size)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Use the readSocket function to read data in the socket buffer up to max_read_size<br />
characters.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-638 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
socket_handle The handle to the open socket.<br />
socket_data The data to be read from the socket.<br />
max_read_size The maximum mumber of characters to return. If this is 0, then<br />
the entire buffer should be returned.<br />
time_out The time (in milliseconds) before a return in blocking mode.<br />
This is ignored for non-blocking read.<br />
blocking_mode 0:using current mode<br />
1:blocking<br />
2:non-blocking<br />
actual_read_size The number of characters actually read. -1 if error.<br />
readSocket Parameters
The following table describes the return status of each mode.<br />
Mode Return Status<br />
0 - Non-Blocking The function will return immediately if there is no data in the<br />
socket. If the max_read_size parameter is greater than the socket<br />
buffer then just the socket buffer will be returned.<br />
1 - Blocking If there is no data in the socket, the function will block until data<br />
is put into the socket on the other end. It will return up to the<br />
max_read_size character setting.<br />
Mode Return Status<br />
The following table describes the status of each return code.<br />
Return Code Status<br />
0 Success.<br />
Non-zero See Socket Function Error Return Codes.<br />
readSocket Return Codes<br />
readSocket 1-639
READT<br />
Syntax<br />
READT [UNIT (mu.expr)] var {THEN statements [END] | ELSE statements<br />
[END]}<br />
Description<br />
The <strong>UniBasic</strong> READT command reads the next record from a tape and assigns it to<br />
a variable.<br />
Note: Before you use the READT command, you must attach a tape drive with the<br />
T.ATT command. For information about tape commands, see the UniData<br />
<strong>Commands</strong> <strong>Reference</strong>. You must use the TAPELEN option for the T.ATT command<br />
and specify the length of the tape in megabytes. This command is intended for use<br />
with UniData tapes only.<br />
UniData uses the ASCII 0 character (CHAR(0)) as an end-of-record mark. Therefore,<br />
you cannot use ASCII 0 in any string variable in <strong>UniBasic</strong>. READT converts<br />
(CHAR(0)) to CHAR(128).<br />
1-640 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
UNIT (mu.expr) Specifies the conversion code (first digit), and the unit number<br />
(second digit). UniData allows unit numbers from 0 through 9.<br />
mu.expr is optional. The default value is 00, indicating tape unit<br />
0 and no conversion:<br />
0 – No conversion (ASCII assumed)<br />
1 – EBCDIC conversion<br />
2 – Invert high bit<br />
3 – Swap bytes<br />
var Specifies a variable to contain the record.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record does not<br />
exist. END is required to terminate multiline ELSE statements.<br />
READT Parameters<br />
STATUS Function Return Values<br />
After you execute READT, the STATUS function returns one of the values described<br />
in the following table.<br />
Value Description<br />
0 Successful read.<br />
1 End of file encountered.<br />
2 End of tape encountered.<br />
3 Tape not assigned.<br />
STATUS Function Return Values<br />
READT 1-641
Example<br />
In the following example, the program segment first uses the ECL T.ATT command<br />
to reserve tape unit 0 and perform no conversion. Then the program segment reads<br />
all the records on the tape (until the end of the file or tape) and calls an internal<br />
subroutine that processes the record.<br />
1-642 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
PERFORM "T.ATT"<br />
DONE = 0<br />
LOOP<br />
READT UNIT (00) TAX.RECORD ELSE DONE = 1<br />
UNTIL DONE DO<br />
GOSUB PROCESS.RECORD<br />
REPEAT<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
RESIZET, REWIND, WEOF, WRITET<br />
UniData<br />
Value Description<br />
4 Parity error.<br />
5 Unknown hardware error.<br />
6 Other unspecified error.<br />
STATUS Function Return Values (continued)<br />
SETTAPE, T.ATT, T.DET – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.
READU<br />
Syntax<br />
READU dyn.array.var FROM [file.var,] record.ID.expr [ON ERROR statements]<br />
[LOCKED statements] {THEN statements [END] | ELSE statements [END]}<br />
READU dyn.array.var FROM [file.var,] record.ID.expr [LOCKED statements]<br />
[ON ERROR statements] {THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> READU command reads a record from a file and assigns its contents<br />
to a dynamic array. READU checks for locks. If the record is available, it sets an<br />
exclusive lock and reads the record.<br />
Note: <strong>UniBasic</strong> locks are advisory only. For more information, see Developing<br />
<strong>UniBasic</strong> Applications.<br />
Warning: Do not use <strong>UniBasic</strong> READ and WRITE commands to open or modify<br />
binary data in DIR-type files (for example, BP). Doing so could corrupt data in the<br />
file. Instead, use OSREAD or OSBREAD after executing the <strong>UniBasic</strong> NOCONVERT<br />
command.<br />
READU 1-643
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-644 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
dyn.array.var Specifies a dynamic array to contain the record.<br />
FROM file.var, Specifies the file variable from which to read the record.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
record.ID.expr Specifies the record ID to use to retrieve the record.<br />
ON ERROR statements Specifies statements to execute if the READU statement fails<br />
with a fatal error because the file is not open, an I/O error occurs,<br />
or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
LOCKED statements Specifies statements to execute if the record is locked by another<br />
user. If you do not specify a LOCKED clause, the program waits<br />
until the lock on the record is released.<br />
Use the ECL command DEFAULT.LOCKED.ACTION BELL<br />
to make the terminal beep while you wait for UniData to unlock<br />
the record.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record (or ID)<br />
does not exist. END is required to terminate multiline ELSE<br />
statements.<br />
READU Parameters
STATUS Function Return Values<br />
After you execute READU, the STATUS function returns one of the values described<br />
in the following table.<br />
Examples<br />
Value Description<br />
0 Successful read.<br />
1 UniData was unable to read the record.<br />
n The record is locked. The user number of the user who locked<br />
the file is returned in n.<br />
STATUS Function Return Values<br />
The following program segment is taken from the sample program in Appendix A,<br />
“Sample Programs,” in Developing <strong>UniBasic</strong> Applications. READU checks for<br />
locks. If the record is available, it sets an exclusive lock and reads the record into<br />
ORDER.REC.<br />
DISPLAY_DATA:<br />
* Display the current information in the desired record. This is<br />
* determined by the number the user entered (ORDER_NUMBER).<br />
READU ORDER.REC FROM ORDERS_FILE,ORDER_NUMBER THEN<br />
* Read with a lock so that no one else can modify it at the same<br />
time.<br />
RECORD_FOUND = 1<br />
The record remains locked until the following program executes, which releases<br />
locks:<br />
WRITE ORDER.REC ON ORDERS_FILE,ORDER_NUMBER<br />
In the following example, the program segment assigns the record, read from the<br />
default file, to the variable INFO, and sets an exclusive lock on that record. UniData<br />
prints “Record locked” if the record is locked by another program, or prints “File not<br />
found” if the record does not exist. If the default file is not found, the program ends.<br />
READU INFO FROM "IDENT" LOCKED PRINT "Record locked"<br />
ELSE PRINT "Record not found"<br />
READU 1-645
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLOSE, DELETE, OPEN, READ, READL, READV, READVL, READVU,<br />
WRITE<br />
UniData<br />
DEFAULT.LOCKED.ACTION – For information, see the UniData <strong>Commands</strong><br />
<strong>Reference</strong>.<br />
1-646 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
READV<br />
Syntax<br />
READV var FROM [file.var,] record.ID.expr, attribute.expr<br />
[ON ERROR statements] {THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> READV command assigns the data from an attribute of a record to a<br />
variable.<br />
Note: READV ignores locks. To update a record, you should use the READVU<br />
command, which checks for locks. For an explanation of UniData locks, see<br />
Developing <strong>UniBasic</strong> Applications..<br />
Tip: To improve efficiency, use READV when only one or two attributes are needed<br />
from a record. If access to more attributes is needed, READ or MATREAD is more<br />
efficient.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
var Specifies a dynamic array to contain the attribute.<br />
FROM file.var, Specifies the file from which to read the record.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
record.ID.expr Specifies the record to read.<br />
attribute.expr Specifies the attribute to read.<br />
READV Parameters<br />
READV 1-647
Parameter Description<br />
Examples<br />
In the following example, the program segment reads CLIENT.NAME from the<br />
CLIENTS file, record ID 10034, attribute 2. If the record exists, UniData appends the<br />
attribute to string NAME.ARRAY1 using the short form of the replace command.<br />
Otherwise, UniData executes the ELSE clause.<br />
1-648 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ON ERROR statements Specifies statements to execute if the READV statement fails<br />
with a fatal error because the file is not open, an I/O error occurs,<br />
or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record does not<br />
exist. END is required to terminate multiline ELSE statements.<br />
READV Parameters (continued)<br />
NAME.ARRAY1 = "Smith Jones Brown"<br />
OPEN "CLIENTS" TO CLIENT.FILE ELSE STOP<br />
READV CLIENT.NAME FROM CLIENT.FILE,"10034",2 THEN<br />
NAME.ARRAY1 = CLIENT.NAME<br />
PRINT NAME.ARRAY1<br />
END ELSE<br />
PRINT 'NO FILE FOR CLIENT ':CLIENT.ID<br />
END<br />
In the next example, you can use the READV command with an attribute.expr of 0<br />
to verify that a record exists (for example, if you are assigning IDs sequentially in the<br />
CLIENTS file). Each time you need to create a new ID, you need to verify that the<br />
ID you selected is not in use. The following code accomplishes this task, incrementing<br />
the ID until an ID is available.<br />
LOOP<br />
READV CHECK FROM CLIENT,NEXT.ID,0 ELSE CHECK = 0<br />
UNTIL CHECK NE 0 DO<br />
NEXT.ID += 1<br />
REPEAT CLIENT.ID = NEXT.ID
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLOSE, DELETE, OPEN, READ, READL, READU, READVL, READVU,<br />
WRITE<br />
READV 1-649
READVL<br />
Syntax<br />
READVL var FROM [file.var,] record.ID.expr, attribute.expr<br />
[ON ERROR statements] [LOCKED statements] {THEN statements [END] | ELSE<br />
statements [END]}<br />
READVL var FROM [file.var,] record.ID.expr, attribute.expr<br />
[LOCKED statements] [ON ERROR statements] {THEN statements [END] | ELSE<br />
statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> READVL command assigns the data from an attribute of a record to<br />
a variable. READVL checks for locks. If the record is available, it sets a shared lock<br />
before it reads the record.<br />
Note: <strong>UniBasic</strong> locks are advisory only. For more information, see Developing<br />
<strong>UniBasic</strong> Applications.<br />
You generally use the READVL command when only one or two attributes are needed<br />
from a record. If access to more attributes is needed, READ or MATREAD is more<br />
efficient.<br />
1-650 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
var Specifies the variable to contain the attribute.<br />
FROM file.var, Specifies the file from which to read the attribute.<br />
If you do not specify a file with file.var, the data is read from the<br />
most recently opened default file.<br />
record.ID.expr Specifies a record from which to read an attribute.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
attribute.expr Specifies an attribute from which to read.<br />
ON ERROR statements Specifies statements to execute if the READVL statement fails<br />
with a fatal error because the file is not open, an I/O error occurs,<br />
or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
LOCKED statements Specifies statements to execute if the record is locked by another<br />
user. If you do not specify a LOCKED clause, the program waits<br />
until the lock on the record is released.<br />
Use the ECL command DEFAULT.LOCKED.ACTION BELL<br />
to make the terminal beep while you wait for UniData to unlock<br />
the record.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record (or ID)<br />
does not exist. END is required to terminate multiline ELSE<br />
statements.<br />
READVL Parameters<br />
READVL 1-651
Example<br />
In the following example, READVL checks for locks on the record CARS in the<br />
default file. If the record is available, it sets a shared lock and reads the third attribute<br />
of the record. If the data is not found, UniData displays the message “NOT FOUND”.<br />
1-652 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
READVL MODEL FROM "CARS",3 ELSE PRINT "NOT FOUND"<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLOSE, DELETE, OPEN, READ, READL, READU, READV, READVU, WRITE<br />
UniData<br />
DEFAULT.LOCKED.ACTION – For information, see the UniData <strong>Commands</strong><br />
<strong>Reference</strong>.
READVU<br />
Syntax<br />
READVU var FROM [file.var,] record.ID.expr, attribute.expr<br />
[ON ERROR statements] [LOCKED statements] {THEN statements [END] | ELSE<br />
statements [END]}<br />
READVU var FROM [file.var,] record.ID.expr, attribute.expr<br />
[LOCKED statements] [ON ERROR statements] {THEN statements [END] | ELSE<br />
statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> READVU command assigns the data from an attribute of a record to<br />
a variable. READVU checks for locks. If the record is available, it sets an exclusive<br />
lock before it reads the record.<br />
Tip: You can improve efficiency by using the READVU command when you need only<br />
one or two attributes from a record. If more attributes are necessary, or if you need<br />
to update more attributes, use the READU or MATREADU commands.<br />
<strong>UniBasic</strong> locks are advisory only. For more information, see Developing <strong>UniBasic</strong><br />
Applications.<br />
READVU 1-653
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-654 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
var Specifies a variable to contain the data read from the attribute.<br />
FROM file.var, Specifies the file from which to read the attribute.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
record.ID.expr Specifies a record in the file from which to read the data.<br />
attribute.expr Specifies an attribute within the file from which to read the data.<br />
ON ERROR statements Specifies statements to execute if the READVU statement fails<br />
with a fatal error because the file is not open, an I/O error occurs,<br />
or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
LOCKED statements Specifies statements to execute if the record is locked by another<br />
user. If you do not specify a LOCKED clause, the program waits<br />
until the lock on the record is released.<br />
Use the ECL command DEFAULT.LOCKED.ACTION BELL<br />
to make the terminal beep while you wait for UniData to unlock<br />
the record.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record (or ID)<br />
does not exist. END is required to terminate multiline ELSE<br />
statements.<br />
READVU Parameters
Examples<br />
The following program segment is taken from Appendix A, “Sample Programs,” in<br />
Developing <strong>UniBasic</strong> Applications. READVU checks for locks. If the record is<br />
available, it sets an exclusive lock and reads the multivalued attribute containing the<br />
order number the user wants to delete.<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 />
In the next example, the program segment reads the seventh attribute of the record<br />
named in the variable ID from the INV file and stores the attribute in the variable<br />
SUPPL. If the record is locked, or if the default file cannot be found, UniData<br />
displays a read-error message.<br />
READVU SUPPL FROM INV,ID,7 LOCKED PRINT "Locked"<br />
ELSE GOTO 2010:<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLOSE, DELETE, OPEN, READ, READL, READU, READV, READVL, WRITE<br />
UniData<br />
DEFAULT.LOCKED.ACTION – For information, see the UniData <strong>Commands</strong><br />
<strong>Reference</strong>.<br />
READVU 1-655
READXBCK<br />
Syntax<br />
READXBCK dyn.array.var [FROM file.var] [ON ERROR statements] {THEN<br />
statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> READXBCK command reads the previous key in an alternate key<br />
index in much the same manner as the READBCK command, but does not read the<br />
associated record. READXBCK enables a program to read alternate keys without<br />
incurring the overhead of retrieving a record every time.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-656 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
dyn.array.var Specifies a dynamic array to which to assign the values read.<br />
FROM file.var Specifies the file from which to read the record.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
READXBCK Parameters
Parameter Description<br />
ON ERROR statements Specifies statements to execute if the READXBCK statement<br />
fails with a fatal error because the file is not open, an I/O error<br />
occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record does not<br />
exist. END is required to terminate multiline ELSE statements.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
READBCK, READBCKL, READBCKU, READFWD, READFWDL,<br />
READFWDU, READXFWD, SELECTINDEX, SETINDEX<br />
UniData<br />
READXBCK Parameters (continued)<br />
BUILD.INDEX, CREATE.INDEX – For information, see the UniData <strong>Commands</strong><br />
<strong>Reference</strong>.<br />
READXBCK 1-657
READXFWD<br />
Syntax<br />
READXFWD dyn.array.var [FROM file.var] [ON ERROR statements]<br />
{THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> READXFWD command reads the next value in an alternate key index<br />
in much the same manner as the READFWD command, but does not read the<br />
associated record. READXFWD enables a program to read alternate keys without<br />
incurring the overhead of retrieving a record every time.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-658 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
dyn.array.var Specifies a dynamic array to which to assign the values read.<br />
FROM file.var Specifies the file from which to read the record.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
READXFWD Parameters
Parameter Description<br />
ON ERROR statements Specifies statements to execute if the READXFWD statement<br />
fails with a fatal error because the file is not open, an I/O error<br />
occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
THEN statements END THEN executes if the read is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the read is not successful or the record does not<br />
exist. END is required to terminate multiline ELSE statements.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
READBCK, READBCKL, READBCKU, READFWD, READFWDL,<br />
READFWDU, READXBCK, SELECTINDEX, SETINDEX<br />
UniData<br />
READXFWD Parameters (continued)<br />
BUILD.INDEX, CREATE.INDEX – For information, see the UniData <strong>Commands</strong><br />
<strong>Reference</strong>.<br />
READXFWD 1-659
ReadXMLData<br />
Syntax<br />
ReadXMLData(xml_data_handle, rec)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
After opening the XML document with the OpenXMLData function, read the<br />
document using the ReadXMLData function. UniBASIC returns the XML data as a<br />
dynamic array.<br />
Syntax<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
After you read the XML document, you can execute any UniBASIC statement or<br />
function against the data.<br />
1-660 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
xml_data_handle A variable that holds the XML data handle created by the<br />
OpenXMLData function.<br />
rec A mark-delimited dynamic array containing the extracted data.<br />
ReadXMLData Parameters
Status Codes<br />
The status code can be one of the following:<br />
Status Code Description<br />
XML.SUCCESS Success<br />
XML.ERROR Failure<br />
XML.INVALID.HANDLE Invalid xml_data_handle<br />
XML.EOF End of data<br />
ReadXMLData Status Codes<br />
Example<br />
The following example illustrates use of the ReadXMLData function:<br />
MOREDATA=1<br />
LOOP WHILE (MOREDATA=1)<br />
status = ReadXMLData(STUDENT_XML,rec)<br />
IF status = XML.ERROR THEN<br />
STOP “Error when preparing the XML document. “<br />
END ELSE IF status = XML.EOF THEN<br />
PRINT “No more data”<br />
MOREDATA = 0<br />
END ELSE<br />
PRINT “rec = “:rec<br />
END<br />
REPEAT<br />
ReadXMLData 1-661
RECORDLOCKED<br />
Syntax<br />
RECORDLOCKED (file.var, rec.id.expr)<br />
Description<br />
The <strong>UniBasic</strong> RECORDLOCKED function returns the lock status of the specified<br />
record or file. For an explanation of UniData locks, and for a sample program you<br />
can use to test this command, see Developing <strong>UniBasic</strong> Applications.<br />
Null Value Handling<br />
With null value handling on, the null value in file.var results in a RECORDLOCKED<br />
return value of -2 and a STATUS function return value of -12. The null value is a valid<br />
record ID and can be passed to the function in rec.id.expr.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-662 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
file.var Specifies the file on which to check lock status. The null value in file.var<br />
results in a RECORDLOCKED return value of -2.<br />
rec.id.expr Specifies the record on which to check lock status.<br />
RECORDLOCKED Parameters
RECORDLOCKED Function Return Values<br />
The RECORDLOCKED function returns one of the values described in the following<br />
table.<br />
Value Lock Type Lock Owner Locking Command<br />
4 exclusive you FILELOCK, SQL LOCK TABLE,<br />
implicit SQL TP lock escalation.<br />
3 shared you FILELOCK, SQL LOCK TABLE,<br />
implicit SQL TP lock escalation.<br />
2 exclusive you READU, RECORDLOCKU, SQL<br />
TP implicit record locking.<br />
1 shared you READL, RECORDLOCKL, SQL<br />
TP implicit record locking.<br />
0 The record is not locked.<br />
-1 shared another user READL, RECORDLOCKL, SQL<br />
TP implicit record locking.<br />
-2 exclusive another user READU, RECORDLOCKU, SQL<br />
TP implicit record locking.<br />
-3 shared another user FILELOCK, SQL LOCK TABLE,<br />
implicit SQL TP lock escalation.<br />
-4 exclusive another user FILELOCK, SQL LOCK TABLE,<br />
implicit SQL TP lock escalation.<br />
RECORDLOCKED Return Values<br />
Note: When UDT.OPTIONS 35 is on, this function returns a value of -2 when another<br />
user has a READU lock on the record or file.<br />
RECORDLOCKED 1-663
STATUS Function Return Values<br />
After you execute RECORDLOCKED, the STATUS function returns one of the<br />
values described in the following table.<br />
Value<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
FILELOCK, FILEUNLOCK, RECORDLOCKL, RECORDLOCKU, RELEASE<br />
1-664 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
RECORDLOCKED<br />
Return Value Meaning<br />
n A number between -1<br />
and -4.<br />
The record is locked. The user number of the user<br />
who owns the lock is returned in n.<br />
0 0 The record is not locked.<br />
-1 -11 The file is NFA. Currently, RECORDLOCKED<br />
does not support NFA files.<br />
-2 -12 Invalid file type. file.var can contain the null value.<br />
-3 -13 System error: unknown user.<br />
STATUS Function Return Values
RECORDLOCKL<br />
Syntax<br />
RECORDLOCKL [file.var,] record.ID.expr [ON ERROR statements]<br />
[LOCKED statements]<br />
Description<br />
The <strong>UniBasic</strong> RECORDLOCKL command checks for record locks. If the record is<br />
available, it sets a shared lock on the record. For an explanation of UniData locks,<br />
and for a sample program that you can use to test this command, see Developing<br />
<strong>UniBasic</strong> Applications.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
file.var, Specifies the file from which to read the record.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
RECORDLOCKL Parameters<br />
RECORDLOCKL 1-665
Parameter Description<br />
Examples<br />
In the following example, the program statement sets a shared lock on the record<br />
HOLLY in the default file. If the record is already locked by another user, the<br />
program waits until the record is released.<br />
RECORDLOCKL "HOLLY"<br />
In the next example, the program segment sets a lock on the record with the ID Smith<br />
from file CLIENT.FILE. If the record is locked, UniData displays the message “THE<br />
RECORD IS ALREADY LOCKED”.<br />
1-666 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
record.ID.expr Specifies a record to lock.<br />
ON ERROR<br />
statements<br />
RECORDLOCKL CLIENT.FILE,"Smith"<br />
LOCKED PRINT "THE RECORD IS ALREADY LOCKED"<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
Specifies statements to execute if the RECORDLOCKL<br />
statement fails with a fatal error because the file is not open, an<br />
I/O error occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
LOCKED statements Specifies statements to execute if another user has an exclusive<br />
lock on the record. If you do not specify a LOCKED clause, the<br />
program waits until the lock on the record is released.<br />
Use the ECL command DEFAULT.LOCKED.ACTION BELL<br />
to make the terminal beep while you wait for UniData to unlock<br />
the record.<br />
RECORDLOCKL Parameters (continued)<br />
FILELOCK, FILEUNLOCK, RECORDLOCKED, RECORDLOCKU, RELEASE
UniData<br />
DEFAULT.LOCKED.ACTION – For information, see the UniData <strong>Commands</strong><br />
<strong>Reference</strong>.<br />
RECORDLOCKL 1-667
RECORDLOCKU<br />
Syntax<br />
RECORDLOCKU [file.var,] record.ID.expr [ON ERROR statements]<br />
[LOCKED statements]<br />
Description<br />
The <strong>UniBasic</strong> RECORDLOCKU command checks for record locks. If the record is<br />
available, it sets an exclusive lock on the record. For an explanation of UniData locks,<br />
and for a sample program that you can use to test this command, see Developing<br />
<strong>UniBasic</strong> Applications.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-668 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
file.var, Specifies the file from which to read the record.<br />
If you do not specify a file.var, UniData reads from the default<br />
file. If no default file is open, a fatal error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
RECORDLOCKU Parameters
Parameter Description<br />
record.ID.expr Specifies a record to lock.<br />
ON ERROR<br />
statements<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
FILELOCK, FILEUNLOCK, RECORDLOCKED, RECORDLOCKL, RELEASE<br />
UniData<br />
Specifies statements to execute if the RECORDLOCKU<br />
statement fails with a fatal error because the file is not open, an<br />
I/O error occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
LOCKED statements Specifies statements to execute if the record is locked by<br />
another user. If you do not specify a LOCKED clause, the<br />
program waits until the lock on the record is released.<br />
Use the ECL command DEFAULT.LOCKED.ACTION BELL<br />
to make the terminal beep while you wait for UniData to unlock<br />
the record.<br />
RECORDLOCKU Parameters (continued)<br />
DEFAULT.LOCKED.ACTION – For information, see UniData <strong>Commands</strong><br />
<strong>Reference</strong>.<br />
RECORDLOCKU 1-669
RELEASE<br />
Syntax<br />
RELEASE [file.var [, record.ID.expr]] [ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> RELEASE command unlocks records and files locked by the same<br />
user process. If no files or records are locked, RELEASE has no effect.<br />
Tip: <strong>UniBasic</strong> locks are advisory only. For more information, see Developing<br />
<strong>UniBasic</strong> Applications.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-670 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
file.var Specifies a file to unlock. If you do not specify a file or a record,<br />
UniData releases all locks set by the same user process.<br />
,record.ID.expr Specifies a record ID to unlock. If you do not specify a record<br />
with record.ID.expr, UniData releases all locked records within<br />
the file.<br />
ON ERROR statements Specifies statements to execute if the RELEASE statement fails<br />
with a fatal error because the file is not open, an I/O error<br />
occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
RELEASE Parameters
Examples<br />
The following program segment is taken from the sample program in Appendix A,<br />
“Sample Program,” of Developing <strong>UniBasic</strong> Applications. In this program, the<br />
WRITE statement unlocks records so that locks are retained only as long as required.<br />
However, some error conditions could result in processing returning to the main<br />
routine with a record still locked. For this reason, the program segment includes a<br />
RELEASE statement.<br />
*-------------- Main Logic -----------------------------<br />
GOSUB INITIALIZE<br />
LOOP<br />
GOSUB DISPLAY_SCREEN<br />
GOSUB GET_ORDER_NUMBER<br />
UNTIL ORDER_NUMBER[1,1] = 'Q'<br />
GOSUB DISPLAY_DATA<br />
IF RECORD_FOUND THEN GOSUB GET_RECORD_COMMAND<br />
RELEASE<br />
REPEAT<br />
GOSUB EXIT<br />
In the next example, the program statement releases the record “COLO” in the file<br />
CONTACTS. Other locked records in this file remain locked.<br />
RELEASE CONTACTS,"COLO"<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
FILELOCK, FILEUNLOCK, RECORDLOCKED, RECORDLOCKL,<br />
RECORDLOCKU<br />
RELEASE 1-671
ReleaseXML<br />
Syntax<br />
ReleaseXML(XMLhandle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Release the dynamic array variable using the ReleaseXML function.<br />
ReleaseXML destroys the internal DOM tree and releases the associated memory.<br />
Parameter<br />
The following table describes the parameter of the syntax.<br />
Parameter Description<br />
1-672 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
XMLhandle The XML handle created by the PrepareXML function.<br />
ReleaseXML Parameter
REM<br />
Syntax<br />
REM [comment text]<br />
Synonyms<br />
!, *<br />
Note: REM is also a synonym for the MOD function. For more information, see<br />
MOD.<br />
Description<br />
The <strong>UniBasic</strong> REM command enables you to enter remarks in a program. You can<br />
enter the comment on a line by itself by entering the comment command followed by<br />
text. You also can enter a comment on a line that contains another <strong>UniBasic</strong> command<br />
by preceding the comment command with a semicolon.<br />
Tip: In structured programming, a single command is entered on each line. This<br />
makes programs easier to read and maintain.<br />
REM 1-673
Example<br />
In the following example, comments describe the subroutine’s functionality. The<br />
program uses !, *, and REM.<br />
1-674 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
! Subroutine to test user input validity.<br />
SUBROUTINE TEST<br />
COMMON N,DATA.IN,VAL,SCORE(10)<br />
BEGIN CASE<br />
CASE DATA.IN=VAL<br />
** answer correct, then<br />
SCORE(N)=1 REM add one to SCORE(N)<br />
PRINT "Got it right!"<br />
! print message.<br />
CASE IN VAL<br />
SCORE(N)=0<br />
PRINT "Incorrect, try again."<br />
END CASE<br />
RETURN<br />
REM end of error check subroutine.
REMOVE<br />
Syntax<br />
REMOVE var FROM dyn.var [AT col.pos] SETTING delim.var<br />
Description<br />
The <strong>UniBasic</strong> REMOVE command extracts an element from a dynamic array and<br />
assigns the removed element to a variable. REMOVE does not change the value of<br />
the dynamic array. REMOVE supports multibyte languages.<br />
REMOVE searches a dynamic array for system delimiters. When UniData finds a<br />
delimiter, it assigns the contents of the array element and the delimiter to the variable.<br />
UniData maintains a pointer to the last substring you remove so that successive<br />
REMOVE statements move progressively through a dynamic array.<br />
Tip: Use REMOVE to sequentially process the elements of a dynamic array.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
var Specifies the element to contain the extracted array element.<br />
REMOVE Parameters<br />
REMOVE 1-675
Parameter Description<br />
The SETTING clause assigns the variable delim.var a value based on the type of<br />
delimiter encountered. The following table describes the values of the delimiter<br />
codes.<br />
*ASCII value is language-dependent and can be reassigned.<br />
1-676 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
FROM dyn.var Specifies a dynamic array from which to remove elements.<br />
AT col.pos Specifies the position in the array at which to start removing<br />
elements.<br />
This position is the number of characters, including system<br />
delimiters, from the beginning of the array. To process the entire<br />
array, set col.pos to 1 (0 defaults to 1). The value of col.pos<br />
changes as the array is processed, indicating the current position<br />
of the pointer.<br />
SETTING delim.var Specifies the delimiter code. When the end of the array is<br />
encountered, delim.var is set to 0.<br />
REMOVE Parameters (continued)<br />
Delimiete<br />
r Code Description ASCII Value*<br />
0 array end<br />
1 record mark 255<br />
2 attribute mark 254<br />
3 value mark 253<br />
4 subvalue mark 252<br />
5 text mark 251<br />
6 not used; nonprinting 250<br />
7 not used; nonprinting 249<br />
REMOVE Delimiter Codes
Examples<br />
In the following example, the program segment processes the dynamic array<br />
CLIENT:<br />
DIM VAR(5,2)<br />
CLIENT = "G.Flaubert":@VM:"Guy":@SM:"12":@VM:"Yvette":@SM:"7"<br />
FOR I = 1 TO 5<br />
REMOVE VAR(I,1) FROM CLIENT SETTING VAR(I,2)<br />
NEXT I<br />
CLIENT = CLIENT;*reset REMOVE pointer<br />
After the loop terminates, VAR contains the following:<br />
VAR(1,1) = "G.Flaubert" VAR(1,2) = 3<br />
VAR(2,1) = "Guy" VAR(2,2) = 4<br />
VAR(3,1) = "12" VAR(3,2) = 3<br />
VAR(4,1) = "Yvette" VAR(4,2) = 4<br />
VAR(5,1) = "7" VAR(5,2) = 0<br />
Notice that each element in the array VAR contains the extracted array element and<br />
the associated delimiter.<br />
In the next example, the program segment starts at the beginning of the array<br />
AMOUNTS, successively removes each element from the array, calculates a 3.5<br />
percent tax amount, and adds it into the variable TAX.AMT. When MARK = 0<br />
(delim.var is 0), processing terminates.<br />
COL = 1<br />
LOOP<br />
REMOVE INV.AMT FROM AMOUNTS AT COL SETTING MARK<br />
TAX.AMT += INV.AMT*.035<br />
WHILE MARK DO REPEAT<br />
In the next example, the program segment demonstrates the difference between<br />
<strong>UniBasic</strong> and other implementations of BASIC:<br />
ARRAY = "AB":@AM:"CD":@AM:"EF"<br />
COL = 1<br />
LOOP<br />
REMOVE LINE FROM ARRAY AT COL SETTING MARK<br />
PRINT LINE, COL, MARK<br />
WHILE MARK REPEAT<br />
In <strong>UniBasic</strong>, the result is the following:<br />
AB 4 2<br />
CD 7 2<br />
EF 9 0<br />
REMOVE 1-677
In some implementations, the values are different:<br />
AB 3 2<br />
CD 6 2<br />
EF 8 2<br />
In the next example, the program segment compares processing time for the<br />
REMOVE statement versus the EXTRACT statement:<br />
1-678 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
MAINLINE<br />
OPEN ' ', 'VOC' TO VOC ELSE STOP 'CANNOT OPEN VOC FILE!'<br />
READ ITEM FROM VOC, 'BIGTEST' THEN<br />
LINE.CNT = DCOUNT (ITEM, @AM)<br />
PRINT "Bigtest in file VOC: "; LINE.CNT: " lines, ":<br />
PRINT LEN(ITEM): "bytes."<br />
GOSUB TIME.EXTRACT<br />
GOSUM TIME.REMOVE<br />
END ELSE<br />
PRINT 'COULD NOT READ ITEM BIGTEST'<br />
END<br />
STOP<br />
TIME.EXTRACT:<br />
LINE.IDX = 1<br />
START.TIME = TIME()<br />
LOOP<br />
UNTIL LINE.IDX LINE.CNT DO<br />
LINE = ITEM<br />
LINE.IDX += 1<br />
REPEAT<br />
END.TIME = TIME()<br />
PRINT "EXTRACT: ": OCONV(END.TIME-START.TIME, 'MTS'):<br />
RETURN<br />
TIME.REMOVE<br />
START.TIME = TIME()<br />
LOOP<br />
REMOVE LINE FROM ITEM SETTING MORE.LINES<br />
WHILE MORE.LINES DO<br />
REPEAT END.TIME = TIME()<br />
PRINT "REMOVE: ": OCONV(END.TIME-START.TIME, 'MTS'):<br />
RETURN<br />
This results in the following:<br />
Bigtest in file VOC: 6000 lines, 59999 bytes.<br />
Processing time:<br />
EXTRACT: 00:07:26<br />
REMOVE: 00:00:03
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DEL, EXTRACT, INSERT, REMOVE, REPLACE, SUBSTRINGS<br />
REMOVE 1-679
REMOVE<br />
Syntax<br />
REMOVE(dyn.array.var, delim.var)<br />
Description<br />
The <strong>UniBasic</strong> REMOVE function extracts an element from a dynamic array and<br />
assigns the removed element to a variable. REMOVE does not change the value of<br />
the dynamic array.<br />
REMOVE searches a dynamic array for system delimiters. When UniData finds a<br />
delimiter, it assigns the contents of the array element and the delimiter to the variable.<br />
UniData maintains a pointer to the last substring you remove so that successive<br />
REMOVE statements move progressively through a dynamic array.<br />
The REMOVE function performs the same action as the REMOVE command, but<br />
you cannot use it to specify a starting position.<br />
Tip: Use REMOVE to sequentially process the elements of a dynamic array.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-680 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
dyn.array.var Specifies a dynamic array from which to remove elements.<br />
delim.var Specifies the delimiter code. When the end of the array is encountered,<br />
delim.var is set to 0.<br />
REMOVE Parameters
The variable delim.var is assigned a value based on the type of delimiter encountered.<br />
The following table describes the values of the delimiter codes.<br />
*ASCII value is language-dependent and can be reassigned.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
Delimiter<br />
Code Description ASCII Value*<br />
0 array end<br />
1 record mark 255<br />
2 attribute mark 254<br />
3 value mark 253<br />
4 subvalue mark 252<br />
5 text mark 251<br />
6 nonprinting; not used 250<br />
7 nonprinting; not used 249<br />
REMOVE Delimiter Codes<br />
DEL, EXTRACT, INSERT, REMOVE, REPLACE, SUBSTRINGS<br />
REMOVE 1-681
REPLACE<br />
Syntax<br />
REPLACE(dyn.array.expr, attrib.expr, val.expr, subval.expr, replace.expr)<br />
dyn.array.expr = replace.expr<br />
Description<br />
The <strong>UniBasic</strong> REPLACE function replaces data in a dynamic array with an<br />
expression.<br />
If an attribute, value, or subvalue is less than 0, the replacement string is placed after<br />
the last attribute, value, or subvalue as appropriate. If the position given does not exist<br />
(for example, attribute 6 specified in an array with two attributes), the necessary<br />
number of attribute, value, and subvalue marks are added to create the specified<br />
position.<br />
Null Value Handling<br />
With null value handling on, when <strong>UniBasic</strong> encounters the null value in a command<br />
parameter when a number is expected (attrib.expr, val.expr, subval.expr,), it displays<br />
a warning message and uses 0.<br />
1-682 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dyn.array.expr Specifies the dynamic array to modify.<br />
attrib.expr Specifies the attribute to replace. The following rules also apply:<br />
If attrib.expr is a negative number, replace.expr is appended to the<br />
existing value instead of replacing it.<br />
If attrib.expr is 0, the preceding level (attribute, value, subvalue) is<br />
replaced by replace.expr.<br />
val.expr Specifies the value of the attribute to replace. The following rules also<br />
apply:<br />
If attrib.expr is a negative number, replace.expr is appended to the<br />
existing value instead of replacing it.<br />
If attrib.expr is 0, the preceding level (attribute, value, subvalue) is<br />
replaced by replace.expr.<br />
subval.expr Specifies the subvalue of the value of the attribute to replace. The<br />
following rules also apply:<br />
If attrib.expr is a negative number, replace.expr is appended to the<br />
existing value instead of replacing it.<br />
If attrib.expr is 0, the preceding level (attribute, value, subvalue) is<br />
replaced by replace.expr.<br />
replace.expr Specifies the replacement value.<br />
REPLACE Parameters<br />
Examples<br />
In this example, the program statement replaces the first value of attribute 2 with the<br />
value ‘220 W. 44TH’:<br />
CLIENT.REC = REPLACE(CLIENT.REC,4,1,0,'220 W. 44TH')<br />
REPLACE 1-683
In the next example, the program segment replaces “Blue” with the null value in STG,<br />
prints STG, then replaces the null value with “Blue” in STG, and prints STG again.<br />
The subroutine PRINT.SETUP converts attribute marks, value marks, and the null<br />
value to characters that can be displayed and printed.<br />
1-684 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
STG = "Movies":@AM:"The Sacrifice":@VM:"Blue":@AM:"Rocky IV"<br />
STG = REPLACE(STG,2,2,0,@NULL)<br />
GOSUB PRINT.SETUP<br />
PRINT "STG = ":PRT.STG<br />
STG = REPLACE(STG,2,2,0,"Blue")<br />
GOSUB PRINT.SETUP<br />
PRINT "STG = ":PRT.STG<br />
PRINT.SETUP:<br />
PRT.STG = CHANGE(STG, @NULL, "@NULL")<br />
PRT.STG = CHANGE(PRT.STG, @AM, "@AM")<br />
PRT.STG = CHANGE(PRT.STG, @VM, "@VM")<br />
RETURN<br />
This program prints the following:<br />
STG = Movies@AMThe Sacrifice@VM@NULL@AMRocky IV<br />
STG = Movies@AMThe Sacrifice@VMBlue@AMRocky IV<br />
In the next example, the first REPLACE places Harry Smith in the first attribute<br />
position. The second REPLACE places an array with two values in the fifth attribute.<br />
CUST.REC =''<br />
CUST.REC = REPLACE(CUST.REC,1,0,01'Harry Smith')<br />
CUST.REC = REPLACE(CUST.REC,5,0,0,"V220":@VM:"v230")<br />
This results in:<br />
CUST.REC = "Harry<br />
Smith":@AM::@AM::@AM::@AM:"V220":@VM:"V230"<br />
In the following example, the program uses the short form of the REPLACE<br />
command to append CLIENT.NAME to NAME.ARRAY1:<br />
NAME.ARRAY1 = "Smith Jones Brown"<br />
OPEN "CLIENTS" TO CLIENT.FILE ELSE STOP<br />
READV CLIENT.NAME FROM CLIENT.FILE,"10034",2 THEN<br />
NAME.ARRAY1 = CLIENT.NAME<br />
PRINT NAME.ARRAY1<br />
END ELSE<br />
PRINT 'NO RECORD FOR CLIENT ':CLIENT.ID<br />
END
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DEL, DELETE, EXTRACT, INSERT, REMOVE, REPLACE<br />
REPLACE 1-685
RESIZET<br />
Syntax<br />
RESIZET [UNIT(mu.expr)] expr {THEN statements [END] | ELSE statements<br />
[END]}<br />
Description<br />
The <strong>UniBasic</strong> RESIZET command changes the block size the WRITET command<br />
uses. When UniData processes a variable length record, the record length is less than<br />
the block length and UniData fills the remaining portion of the block with blanks.<br />
Tip: Use this command when the block size in a file is not the same as the block size<br />
in T.ATT.<br />
Parameters<br />
1-686 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
The following table describes each parameter of the syntax.<br />
Paragraph Description<br />
UNIT(mu.expr) Specifies the conversion code and unit number. The mu.expr is<br />
optional. The default value is UNIT (00) for tape unit 0 with no<br />
conversion (ASCII assumed).<br />
0 – No conversion (ASCII assumed).<br />
1 – EBCDIC conversion.<br />
2 – Invert high bit.<br />
3 – Swap bytes.<br />
expr Specifies the block size to which to resize.<br />
THEN statements END THEN executes if the resize is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the resize is not successful. END is required to<br />
terminate multiline ELSE statements.<br />
RESIZET Parameters
Example<br />
In the following example, the program segment changes the block size the WRITET<br />
statement uses for the length of REC:<br />
RESIZET LEN(REC) ELSE PRINT 'RESIZET ERROR'<br />
WRITET REC ELSE PRINT 'WRITET ERROR'<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
READT, REWIND, WRITET<br />
UniData<br />
SETTAPE, T.ATT, T.DET – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
RESIZET 1-687
RETURN<br />
Syntax<br />
RETURN [TO label[:]]<br />
Description<br />
The <strong>UniBasic</strong> RETURN command transfers program control from a subroutine back<br />
to the calling program or subroutine.<br />
The optional TO clause returns to a statement label. This clause is valid only for<br />
internal subroutine returns. If you do not specify a TO clause, control passes to the<br />
statement immediately following the GOSUB or CALL statement in the calling<br />
program or subroutine.<br />
Example<br />
The following externally cataloged subroutine is called by the sample program in<br />
Appendix A, “Sample Program,” of Developing <strong>UniBasic</strong> Applications. The<br />
RETURN statement returns control to UPDATE_ORDERS.<br />
1-688 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
SUBROUTINE DISPLAY_MESSAGE(MESSAGE)<br />
DISPLAY @(5,20):MESSAGE<br />
DISPLAY @(5,21):"Press the (Return) key.":<br />
INPUT PAUSE,1_<br />
RETURN<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CALL, GOSUB, ON/GOSUB
REUSE<br />
Syntax<br />
REUSE(dyn.array.expr)<br />
Description<br />
The <strong>UniBasic</strong> REUSE function affects the application of arithmetic operations on<br />
dynamic arrays.<br />
When REUSE Is Not Used<br />
When you execute an arithmetic operation on an array and you do not include the<br />
REUSE function, one of the following happens:<br />
Array and constant – When you apply an arithmetic operation to an array<br />
and a constant, the operation is executed against only the first element of the<br />
array. If you want the operation to execute on every element in the array,<br />
apply REUSE to the constant.<br />
Two arrays – When you execute an arithmetic operation on arrays of<br />
different lengths, the operation is performed on the number of elements in<br />
the shortest array only. The remaining elements are each filled with 1 or 0,<br />
depending on the operation performed:<br />
Division – 1.<br />
Addition, subtraction, and multiplication – 0.<br />
If you apply REUSE to the shorter array, the last element in this array is used<br />
to perform the operation on the remaining elements in the longer array.<br />
REUSE 1-689
Examples<br />
In the following example, the program segment multiplies the arrays without using<br />
the REUSE function:<br />
1-690 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
VIEWERS = 100:@VM:200:@VM:300<br />
COST = 40:@VM:1<br />
VCOST = VIEWERS*COST<br />
This results in:<br />
VCOST = 4000:@VM:200:@VM:0<br />
VCOST takes its length from VIEWERS, the longest of the two arrays, but multiplication<br />
is performed on only the first two elements of each array because the other<br />
array, COST, has only two elements. The final element in the result array (VCOST)<br />
is filled with 0. 0 is used to fill because the arithmetic operation is multiplication.<br />
However, if you apply the REUSE function to the shorter array:<br />
VCOST = VIEWERS*REUSE(COST)<br />
This results in:<br />
VCOST = 4000:@VM:200:@VM:300<br />
The final element in COST (1) is used to multiply with the final element of<br />
VIEWERS and fill the final element of the result array, VCOST.
REWIND<br />
Syntax<br />
REWIND [UNIT(mu.expr)] {THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> REWIND command rewinds a tape.<br />
Note: Before you can use the REWIND command, you must reserve a tape drive for<br />
use with the T.ATT command. For information about ECL T.ATT, see the UniData<br />
<strong>Commands</strong> <strong>Reference</strong>.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
UNIT(mu.expr) Specifies the conversion code (first digit), and the unit number<br />
(second digit). UniData allows unit numbers from 0 through 9.<br />
The mu.expr is optional and the default value is UNIT (00) for<br />
tape unit 0 with no conversion (ASCII assumed).<br />
0 – No conversion (ASCII assumed).<br />
1 – EBCDIC conversion.<br />
2 – Invert high bit.<br />
3 – Swap bytes.<br />
THEN statements END THEN executes if the rewind is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the rewind is not successful. END is required<br />
to terminate multiline ELSE statements.<br />
REWIND Parameters<br />
REWIND 1-691
Example<br />
In the following example, the program segment first uses the ECL T.ATT command<br />
to reserve tape unit 0 and specifies no conversion code. Then a routine reads all the<br />
records on the tape (until the end of the file or tape) and calls an internal subroutine<br />
that processes the record. After the process is finished, the REWIND command<br />
rewinds the tape.<br />
1-692 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
PERFORM "T.ATT DO"<br />
DONE = 0<br />
LOOP<br />
READT UNIT (00) TAX.RECORD ELSE DONE = 1<br />
UNTIL DONE DO<br />
GOSUB PROCESS.RECORD<br />
REPEAT REWIND UNIT (00) ELSE PRINT 'REWIND UNSUCCESSFUL'<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
READT, RESIZET, WRITET<br />
UniData<br />
SETTAPE, T.ATT, T.DET – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.
RND<br />
Syntax<br />
RND(num.expr)<br />
Description<br />
The <strong>UniBasic</strong> RND function returns a random integer from 0 through<br />
num.expr minus 1.<br />
Example<br />
In the following example, the program statement prints a random number from 0<br />
through 9:<br />
PRINT RND(10)<br />
Related Command<br />
<strong>UniBasic</strong><br />
RNDSEED<br />
RND 1-693
RNDSEED<br />
Syntax<br />
RNDSEED expr<br />
Description<br />
The <strong>UniBasic</strong> RNDSEED command enables you to “seed” the pseudo random<br />
number generator. The RND function gives you a different sequence of numbers each<br />
time. RNDSEED generates the same sequence of random numbers each time you run<br />
a program with the same seed.<br />
expr is a numeric seed point. Each time you use the same expr, RND generates the<br />
same sequence of random numbers.<br />
Example<br />
In the following program segment, RND produces an array of random numbers to<br />
replace the values in VCOST. Because RNDSEEN is a constant, this program always<br />
produces the same series of random numbers. Without this statement, the program<br />
produces a different set of random numbers each time it is run.<br />
1-694 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
RNDSEED 234<br />
VCOST = 100:@VM:200:@VM:0@VM:100:@VM:200:@VM:300<br />
VCOST = RND(VCOST)<br />
PRINT VCOST<br />
Related Command<br />
<strong>UniBasic</strong><br />
RND
RQM<br />
RQM is a synonym for the SLEEP function. For more information, see SLEEP.<br />
Synonym<br />
SLEEP<br />
RQM 1-695
SADD<br />
Syntax<br />
SADD(x, y)<br />
Description<br />
The <strong>UniBasic</strong> SADD function adds two string numbers and returns the result as a<br />
string number. SADD is the string addition function. Arguments can be any valid<br />
numbers or string numbers of any magnitude or precision.<br />
Tip: Processing string data type numbers rather than numeric data type numbers<br />
degrades processing speed. Numbers specified in quotation marks are string data<br />
type. Numbers specified without quotation marks are numeric data type. The data<br />
type in a variable is determined by the data first loaded into it.<br />
If x or y contains nonnumeric data, UniData displays an error message and returns a<br />
result of 0.<br />
The SADD function results in a string number, so you can use the function in any<br />
expression in which a string number is valid. Because string numbers can exceed the<br />
range of numbers that standard arithmetic operators can accommodate, you might not<br />
want to use the SADD function in any expression in which a standard number is<br />
valid.<br />
Note: The result of the SADD function cannot exceed the maximum allowable<br />
number determined by your hardware.<br />
Example<br />
In the following example, the program statement assigns to variable B the sum of the<br />
string constant (1.4149) and variable A:<br />
B = SADD("1.4149",A)<br />
1-696 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
saveSecurityContext<br />
Syntax<br />
saveSecurityContext(context, name, passPhrase)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The saveSecurityContext() function encrypts and saves a security context to a<br />
system security file. UniData maintains this file on a per account basis for. and uses<br />
the name as the record ID to access the saved security information. Since the information<br />
is encrypted, you should not attempt to directly manipulate the information.<br />
You may want your application to a security context to be used later. You can create<br />
multiple contexts to suit different needs. For example, you may want to use different<br />
protocols to talk to different servers. These contexts can be saved and reused.<br />
When creating a saved context, you must provide both a name and a passPhrase to<br />
use to encrypt the contents of the context. You must provide the name and passPhrase<br />
to load the saved context back. To ensure a high level of security, we recommend that<br />
the passPhrase be relatively long, yet easy to remember.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
context The Security context handle.<br />
name String containing the file name of the saved context.<br />
passPhrase String containing the password to encrypt the context contents.<br />
saveSecurityContext Parameters<br />
saveSecurityContext 1-697
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success.<br />
1-698 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
1 Invalid security context handle.<br />
2 Invalid parameters (empty name or passPhrase).<br />
3 Context could not be saved.<br />
Return Code Status
SCMP<br />
Syntax<br />
SCMP(x, y)<br />
Description<br />
The <strong>UniBasic</strong> SCMP function compares two string numbers and returns a value<br />
depending on the result of the comparison. Arguments can be any valid numbers or<br />
string numbers of any magnitude or precision. If x or y contains nonnumeric data,<br />
UniData displays an error message, and the comparison returns 0.<br />
SCMP Function Return Values<br />
The SCMP function returns one of the values described in the following table.<br />
Comparison<br />
x < y -1<br />
x = y 0<br />
x > y 1<br />
Returning<br />
Value<br />
SCMP Function Return Values<br />
Tip: Processing string data-type numbers rather than numeric data-type numbers<br />
degrades processing speed. Numbers specified in quotation marks are string data<br />
type. Numbers specified without quotation marks are numeric data type. The data<br />
type in a variable is determined by the data first loaded into it.<br />
SCMP 1-699
Example<br />
In the following example, the program segment compares FA to FB. If the result of<br />
the IF statement is true (the SCMP function returns 1), UniData executes the PRINT<br />
statement.<br />
1-700 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
IF SCMP(FA,FB) GT 0 THEN<br />
PRINT FA:" IS GREATER THAN ":FB
SDIV<br />
Syntax<br />
SDIV(x, y)<br />
Description<br />
The <strong>UniBasic</strong> SDIV function divides two string numbers and returns the result as a<br />
string number. SDIV divides x by y. Arguments can be any valid numbers or string<br />
numbers of any magnitude or precision. However, result precision is limited to 14<br />
significant digits.<br />
Tip: Processing string data type numbers rather than numeric data type numbers<br />
degrades processing speed. Numbers specified in quotation marks are string data<br />
type. Numbers specified without quotation marks are numeric data type. The data<br />
type of a variable is determined by the data first loaded into it.<br />
If x or y contains nonnumeric data, UniData displays an error message, and the<br />
operation results in 0. If y is 0, UniData displays an error message that indicates you<br />
cannot divide by 0 and returns a result of 0.<br />
The SDIV function results in a string number, so you can use the function in any<br />
expression in which a string is required. Because the resulting string numbers can be<br />
longer than the arithmetic operator can accommodate, you might not want to use the<br />
SDIV function in expressions requiring numeric data type.<br />
Example<br />
In the following example, the program statement divides the constant (1.4149) by<br />
variable A and assigns the result to variable B:<br />
B = SDIV("1.4149",A)<br />
SDIV 1-701
SELECT<br />
Syntax<br />
SELECT file.var [TO {list.num.expr | list.var.expr}] [ON ERROR statements]<br />
SELECT dyn.array [TO {list.num.expr | list.var.expr}] [ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> SELECT command creates an active select list of all record IDs in a<br />
file. Records appear in the list in the order in which they are stored in the file.<br />
You can access the select list with a READNEXT statement.<br />
The <strong>UniBasic</strong> SELECT command differs from EXECUTE "SELECT ...", which<br />
executes the UniQuery SELECT command. The <strong>UniBasic</strong> SELECT command<br />
immediately makes available to READNEXT one group of IDs at a time. The<br />
program does not have to wait for the entire ID list to be constructed.<br />
If changes occur in a group that has not been selected yet, those changes are reflected<br />
in the select list that is being read by the program. If an ID is deleted before the group<br />
is selected by the <strong>UniBasic</strong> program, that ID does not appear in the list.<br />
Record IDs are truncated at 96 characters when they are copied into the select list.<br />
When using the UniQuery SELECT command, SYSTEM(11) returns the number of<br />
items remaining in the list. With the <strong>UniBasic</strong> SELECT command, SYSTEM(11)<br />
returns the number of items remaining in the group.<br />
Note: You can specify named or numbered lists (using list.num.expr or list.var.expr)<br />
in BASICTYPEs R and U. Only named lists (list.var.expr) are supported in<br />
BASICTYPEs M and P.<br />
1-702 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
file.var Specifies a file variable from which to read record IDs.<br />
If you do not specify a file.var, UniData reads from the default file. If<br />
no default file is open, a fatal error occurs.<br />
The default file is one for which no file variable is assigned in the<br />
OPEN statement.<br />
dyn.array Specifies a dynamic array from which to select a list of attributes.<br />
TO list.num.expr Supported in BASICTYPEs R and U only. Specifies a numbered<br />
select list, 0–9, to contain record IDs. If you do not specify a list,<br />
SELECT creates list 0.<br />
TO list.var.expr Supported in all BASICTYPEs. Specifies a named select list to<br />
contain record IDs.<br />
Initialize list.var.expr with a statement like<br />
list.name = ''<br />
before using it in the SELECT statement to avoid a compiler warning<br />
for an uninitialized variable.<br />
ON ERROR<br />
statements<br />
Specifies statements to execute if the SELECT statement fails with a<br />
fatal error because the file is not open, an I/O error occurs, or UniData<br />
cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error occurs,<br />
the program terminates.<br />
SELECT Parameters<br />
SELECT 1-703
Examples<br />
The following program segment places in select list 1 all record IDs in the CLIENTS<br />
file, and then prints the ID of the first record:<br />
1-704 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
OPEN 'CLIENTS' TO CLIENT ON ERROR PRINT "File open error." THEN<br />
PRINT "OPEN"<br />
SELECT CLIENT TO 1<br />
READNEXT var FROM 1 ON ERROR PRINT "Error in READNEXT." THEN<br />
PRINT var<br />
END ELSE<br />
PRINT "Record not found."<br />
END<br />
The following sample program creates a select list that is named rather than<br />
numbered. This program is compiled in BASICTYPE P, but compiles and runs in all<br />
BASICTYPEs.<br />
$BASICTYPE "P"<br />
list = ''<br />
OPEN 'INVENTORY' TO INV_FILE ELSE PRINT "OPEN error"<br />
SELECT INV_FILE TO list<br />
FOR X = 1 TO 10<br />
READNEXT ID FROM list ELSE<br />
PRINT "No more IDs in list"<br />
END<br />
READU REC FROM INV_FILE,ID THEN<br />
PRINT "Record ":X:" is ":REC:" ":REC<br />
END ELSE<br />
PRINT "Record not found."<br />
END<br />
NEXT X<br />
END<br />
Here is the output for this program:<br />
Record 1 is 10105 Memory<br />
Record 2 is 10076 Telephone<br />
Record 3 is 10020 Adapter<br />
Record 4 is 10086 Modem<br />
Record 5 is 10092 Adapter<br />
Record 6 is 10073 Monitor<br />
Record 7 is 10041 Computer<br />
Record 8 is 10071 Computer<br />
Record 9 is 10103 Telephone<br />
Record 10 is 10101 Computer<br />
In the following example, the program statement creates a list of all record IDs in the<br />
INVENTORY file in active select list 0:<br />
SELECT INVENTORY
In the next example, the program segment first creates a list of all IDs in the<br />
ORDERS file and assigns the ID list to list 1. It then uses the READNEXT command<br />
to read the IDs from the list sequentially, executing a subroutine,<br />
PROCESS.ORDERS, each time.<br />
SELECT ORDERS TO 1<br />
LOOP<br />
READNEXT ORDER.ID FROM 1 ELSE TAPE.ID = " "<br />
WHILE ORDER.ID<br />
GOSUB PROCESS.ORDERS<br />
REPEAT<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DELETELIST, FORMLIST, READLIST, SELECTINDEX, SELECTINFO,<br />
WRITELIST<br />
UniQuery<br />
DELETE.LIST, GET.LIST, SAVE.LIST, SELECT, SSELECT – For information, see<br />
the UniQuery <strong>Commands</strong> <strong>Reference</strong>.<br />
UniData SQL<br />
SELECT – For information, see the UniData SQL <strong>Commands</strong> <strong>Reference</strong>.<br />
SELECT 1-705
SELECTINDEX<br />
Syntax<br />
SELECTINDEX index.name.expr[, key.val.expr] FROM file.var [TO list.num.expr]<br />
Description<br />
The <strong>UniBasic</strong> SELECTINDEX command creates a select list based on an alternate<br />
key index.<br />
Note: SELECTINDEX is not supported with EDA files.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-706 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
index.name.expr Specifies an alternate key index from which to select all key<br />
values if the key.val.expr is not specified.<br />
, key.val.expr Specifies a key value expression for SELECTINDEX to create a<br />
select list of record IDs (associated with the alternate key value)<br />
found in the alternate key index.<br />
FROM file.var Specifies a file variable from which to select the list.<br />
TO list.num.expr Specifies the list to which to select keys.<br />
SELECTINDEX Parameters
STATUS Function Return Values<br />
After you execute SELECTINDEX, the STATUS function returns one of the values<br />
described in the following table.<br />
Value Description<br />
0 The select list is loaded with alternate key values or record IDs for the specified<br />
file.<br />
1 No alternate index key exists for this attribute using the name specified. The select<br />
list is empty.<br />
STATUS Function Return Values<br />
Examples<br />
The following program creates a select list based on alternate index LNAME, and<br />
then reads the record using the first ID retrieved from that list:<br />
OPEN 'CLIENTS' TO CLIENT.FILE ELSE ABORT<br />
SELECTINDEX 'LNAME' FROM CLIENT.FILE TO 2<br />
PRINT @(-1)<br />
READNEXT ID FROM 2 THEN<br />
READ REC FROM CLIENT.FILE, ID THEN<br />
PRINT @(5,I):REC:@(20,I):REC<br />
END ELSE<br />
PRINT "CANNOT FIND RECORD":ID<br />
END<br />
CLEARSELECT<br />
END<br />
In the following example, SELECTINDEX uses the alternate key index LNAME and<br />
creates a list of all the last names contained in the CLIENTS file:<br />
SELECTINDEX "LNAME" FROM CLIENTS<br />
In the next example, SELECTINDEX uses the alternate key value “Smith” and<br />
creates a list of all occurrences of Smith contained in the CLIENTS file:<br />
SELECTINDEX "LNAME","Smith" FROM CLIENTS<br />
SELECTINDEX 1-707
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DELETELIST, FORMLIST, INDICES, READLIST, SELECT, SELECTINFO,<br />
SETINDEX, WRITELIST<br />
UniQuery<br />
DELETE.LIST, GET.LIST, SELECT, SSELECT, SAVE.LIST – For information, see<br />
the UniQuery <strong>Commands</strong> <strong>Reference</strong>.<br />
UniData SQL<br />
SELECT – For information, see the UniData SQL <strong>Commands</strong> <strong>Reference</strong>.<br />
1-708 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
SELECTINFO<br />
Syntax<br />
SELECTINFO([list.num.expr,] 1)<br />
Description<br />
The <strong>UniBasic</strong> SELECTINFO function returns the state of a select list. list.num.expr<br />
is an expression evaluating to the number of the select list (0-9).<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
list.num.expr The select list number (0-9).<br />
1 The only code.expr currently implemented is 1, which returns the values<br />
described in the following table.<br />
SELECTINFO Parameters<br />
SELECTINFO Function Return Values<br />
The SELECTINFO function returns one of the values described in the following<br />
table.<br />
Value Description<br />
1 The select list you specify is active.<br />
0 The select list you specify is not active.<br />
-1 The select list does not exist, or code.expr is not valid, or (in BASICTYPE P)<br />
list.num.expr is not a list variable.<br />
SELECTINFO Function Return Values<br />
SELECTINFO 1-709
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DELETELIST, FORMLIST, READLIST, SELECT, SELECTINDEX, WRITELIST<br />
UniQuery<br />
DELETE.LIST, GET.LIST, SAVE.LIST, SELECT, SSELECT – For information, see<br />
the UniQuery <strong>Commands</strong> <strong>Reference</strong>.<br />
UniData SQL<br />
SELECT – For information, see the UniData SQL <strong>Commands</strong> <strong>Reference</strong>.<br />
1-710 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
SEND<br />
Syntax<br />
SEND[X] expr[:expr2...] [:] TO line.expr {THEN | ELSE} statements [END]<br />
Description<br />
The <strong>UniBasic</strong> SEND command sends output data to a specified line. You usually use<br />
SEND after a line is attached.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
X Directs UniData to convert expr from an exploded ASCII hexadecimal<br />
representation string to its binary equivalent, and then transmit it on the<br />
specified line. The conversion process ends when UniData reads the first<br />
nonhexadecimal character.<br />
expr:expr2... A string that contains data formatting expressions. You can specify more<br />
than one string to send.<br />
: Suppresses the sending of a terminating carriage return and line feed.<br />
TO line.expr Specifies a line number. line.expr must be valid or an error message<br />
displays and the user enters the <strong>UniBasic</strong> debugger.<br />
If the line is attached, the process has exclusive use of it. If the line is not<br />
attached, UniData performs the ELSE clause.<br />
THEN<br />
statements<br />
END<br />
ELSE<br />
statements<br />
END<br />
THEN executes if the SEND is successful. END is required to terminate<br />
multiline statements.<br />
ELSE executes if the SEND is not successful. END is required to<br />
terminate multiline statements.<br />
SEND Parameters<br />
SEND 1-711
Note: SEND with the X option suppresses the output of return/line feed. However, you<br />
cannot include both quotation marks and the colon (‘:’) in the same statement.<br />
Examples<br />
In the following example, the program statement sends the string to line 0 unless line<br />
0 is not attached. If line 0 is not attached, UniData displays the message “Line not<br />
attached”.<br />
1-712 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
SEND BEGIN_TRANSMISSION TO 0<br />
ELSE PRINT "Line not attached"<br />
In the next example, the program statement converts the string to HELLO WORLD<br />
before sending it to line 0:<br />
TESTVAR = "48454C404F WORLD"<br />
SENDX TESTVAR TO 0 ELSE PRINT "Line not attached"<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
GET<br />
UniData<br />
PROTOCOL – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.
SEQ<br />
Syntax<br />
SEQ("char.expr")<br />
Description<br />
The <strong>UniBasic</strong> SEQ function converts a single character to its ASCII code value. The<br />
SEQ function is the complement of the CHAR function. SEQ supports multibyte<br />
languages.<br />
Tip: Use SEQ(@NULL) to determine the ASCII code that represents the null value<br />
on your system.<br />
Example<br />
In the following example, the program statement prints the ASCII code<br />
corresponding to the character “#” (in this case, 35):<br />
PRINT SEQ("#")<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
ASCII, CHAR, CHARS, EBCDIC<br />
SEQ 1-713
SEQS<br />
Syntax<br />
SEQS("char.expr")<br />
Description<br />
The <strong>UniBasic</strong> SEQS function converts the first character in each element of a<br />
dynamic array to its ASCII code value. SEQS supports multibyte languages.<br />
Example<br />
In the following example, the program statement prints the ASCII code<br />
corresponding to the value in each element of the dynamic array ARR1. The result is<br />
65}66}67}68.<br />
1-714 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ARR1 = "A":@AM:"B":@AM:"C":@AM:"D"<br />
PRINT SEQS(ARR1)<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
ASCII, CHAR, CHARS, EBCDIC, SEQ
setAuthenticationDepth<br />
Syntax<br />
setAuthenticationDepth(context, depth, serverOrClient)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The setAuthenticationDepth() function sets how deeply UniData should verify<br />
before deciding that a certificate is not valid.<br />
You can use this function to set both server authentication and client certification,<br />
determined by the value in serverOrClient parameter. The default depth for both is 1.<br />
The depth is the maximum number of intermediate issuer certificate, or CA certificates<br />
which must be examined while verifying an incoming certificate. Specifically,<br />
a depth of 0 means that the certificate must be self-signed. A default depth of 1 means<br />
that the incoming certificate can be either self-signed, or signed by a CA which is<br />
known to the context.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
context The Security Context handle.<br />
depth Numeric value for verification depth.<br />
serverOrClient 1 - Server<br />
2 - Client<br />
setAuthenticationDepth Parameters<br />
setAuthenticationDepth 1-715
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success.<br />
1-716 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
1 Invalid Security Context handle.<br />
2 Invalid depth (must be greater than or equal to 0).<br />
3 Invalid value for serverOrClient (must be 1 or 2)<br />
Return Code Status
setCipherSuite<br />
Syntax<br />
setCipherSuite(context,cipherSpecs)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The setCipherSuite() function enables you to identify which cipher suites to support<br />
for the specified context. It affects the cipher suites and public key algorithms<br />
supported during the SSL/TLS handshake and subsequent data exchanges.<br />
When a context is created, its cipher suites will all be set to SSLv3 suites by default.<br />
The CipherSpecs parameter is a string containing cipher-spec separated by colons.<br />
An SSL cipher specification in cipher-spec is composed of 4 major attributes as well<br />
as several, less significant attributes. These are defined below.<br />
Some of this information on ciphers is excerpted from the mod_ssl open source<br />
package of the Apache web server.<br />
Key Exchange Algorithm - RSA or Diffie-Hellman variants.<br />
Authentication Algorithm - RSA, Diffie-Hellman, DSS or none.<br />
Cipher/Encryption Algorithm - DES, Triple-DES, RC4, RC2, or none.<br />
MAC Digest Algorithm - MD5, SHA or SHA1.<br />
An SSL cipher can also be an export cipher and is either an SSLv2 or SSLv3/TLSv1<br />
cipher (here TLSv1 is equivalent to SSLv3). To specify which ciphers to use, one can<br />
either specify all the ciphers, one at a time, or use aliases to specify the preference<br />
and order for the ciphers.<br />
For detailed information about cipher algorithms, see <strong>UniBasic</strong> Extensions.<br />
setCipherSuite 1-717
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
The following table describes the status of each return code.<br />
1-718 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
context The Security Context handle.<br />
CipherSpecs String containing cipher suite specification described above.<br />
setCipherSuite Parameters<br />
Return<br />
Code Status<br />
0 Success.<br />
1 Invalid Security Context handle.<br />
2 Invalid cipher suite specification.<br />
setCipherSuite Return Codes
setClientAuthentication<br />
Syntax<br />
setClientAuthentication(context,option)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The setClientAuthentication() function turns client authentication for a server<br />
socket on or off.<br />
When option is set to on, during the initial SSL handshake, the server sends a client<br />
authentication request to the client. It will also receive the client certificate and<br />
perform authentication according to the issuer’s certificate (or certificate chain) set<br />
in the security context.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
context The Security Context handle.<br />
option 1 - ON<br />
2 - OFF<br />
setClientAuthentication Parameters<br />
setClientAuthentication 1-719
The following table describes the status of each return code.<br />
1-720 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return<br />
Code Status<br />
0 Success.<br />
1 Invalid Security Context handle.<br />
Return Code Status
SETENV<br />
Syntax<br />
SETENV(var_name, value)<br />
Description<br />
Use the SETENV function to set an environment variable from <strong>UniBasic</strong>.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
var_name The name of the environment variable.<br />
value The value of the environment variable.<br />
SETENV Parameters<br />
Return Codes<br />
The following table describes the SETENV return codes.<br />
Return Code Description<br />
0 Setting the environment variable was successful.<br />
-1 Setting the environment variable was not successful.<br />
SETENV Return Codes<br />
SETENV 1-721
setHTTPDefault<br />
Syntax<br />
setHTTPDefault(option, value)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The setHTTPDefault function configures the default HTTP settings, including<br />
proxy server and port, buffer size, authentication credential, HTTP version, and<br />
request header values. <strong>UniBasic</strong> uses these settings with every HTTP request that<br />
follows.<br />
If you require all outgoing network traffic to go through a proxy server, you should<br />
call setHTTPDefault() with value containing the proxy server name or IP address as<br />
well as the port (if other than the default of 80).<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-722 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
option A string containing an option name. See the table below for the options<br />
currently defined.<br />
value A string containing the appropriate option value.<br />
setHTTPDefault Parameters
The following table describes the available options for setHTTPDefault.<br />
Option Description<br />
PROXY_NAME Name or IP address of the proxy server.<br />
PROXY_PORT The port number to be used on the proxy server. This only needs<br />
to be specified if the port is other than the default of 80.<br />
VERSION The version of HTTP to be used. The default version is 1.0, but<br />
it can be set to 1.1 for web servers that understand the newer<br />
protocol. The string should be ”1.0” or “1.1”.<br />
BUFSIZE The size of the buffer for HTTP data transfer between UniData<br />
and the web server. The default is 4096 however, the buffer size<br />
can be increased to improve performance. It should be entered<br />
as an integer greater than or equal to 4096.<br />
AUTHENTICATE The user name and password to gain access. The string should<br />
be “user-name:password”. Default Basic authentication can<br />
also be set. If a request is denied (HTTP staus 401/407),<br />
<strong>UniBasic</strong> will search for the default credential to automatically<br />
re-submit the request.<br />
HEADERS The header to be sent with the HTTP request. If default_headers<br />
contains an empty string, then any current user-specified default<br />
header will be cleared. Currently, the only default header<br />
<strong>UniBasic</strong> sets automatically is “User-Agent” UniData 6.0.” If<br />
you do not want to send out this header you should overwrite it<br />
with setHTTPDefault(). Per RFC 2616, for “net politeness,”an<br />
HTTP client should always send out this header. <strong>UniBasic</strong> will<br />
also send a date/time stamp with every HTTP request.<br />
According to RFC 2616, the stamp will represent time in<br />
Universal Time (UT) format. A header should be entered as a<br />
dynamic array in the form of<br />
@VM@Fm@VM.<br />
setHTTPDefault Options<br />
setHTTPDefault 1-723
The following table describes the status of each return code.<br />
Note: All defaults set by setHTTPDefault() will be in effect until the end of the<br />
current UniData session. If you do not want the setting to affect subsequent<br />
programs, you will need to clear it before exiting the current program. If the user<br />
wishes to set the “Authorization” or “Proxy-Authorization” header as defualts, see<br />
the description under setRequestHeader(). To clear the default settings, pass an<br />
empty string with PROXY_NAME, AUTHENTICATE and HEADERS, and 0 for<br />
PROXY_PORT and BUFSIZE.<br />
1-724 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Code Status<br />
0 Success.<br />
1 Invalid option.<br />
2 Invalid Value.<br />
setHTTPDefault Return Codes
SETINDEX<br />
Syntax<br />
SETINDEX index.name.expr [, [rop] key.val.expr [, id.expr]] [ON file.var]<br />
[BUFFER.KEYS {ON | OFF}] [VALIDATE.KEY {ON | OFF}]<br />
Description<br />
The <strong>UniBasic</strong> SETINDEX command sets a pointer to a key in an alternate key index.<br />
Note: The FILEINFO function, specifically FILEINFO(file.var,21), returns the<br />
current alternate key value.<br />
<strong>UniBasic</strong> maintains index.name.expr for READBCK or READFWD, and related<br />
statements. Normally, you should use the following relational (rop) operators:<br />
Before READBCK statements: LT, LE, LAST_ALT_KEY<br />
Before READFWD statements: GT, GE, EQ, FIRST_ALT_KEY,<br />
NULLVAL_ALT_KEY<br />
Note: You can point to only one alternate index at a time. Each time you use<br />
SETINDEX, the current value is reset and the subsequent READFWD/READBCK<br />
statement reads the record associated with the newly selected index.<br />
SETINDEX 1-725
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-726 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
index.name.expr Specifies the alternate key index to use in subsequent<br />
READFWD/READBCK statements.<br />
rop One of several valid operators (see the following table). The default<br />
rop operator is EQ.<br />
, key.val.expr Specifies the key value to initialize. If you do not specify this value,<br />
UniData sets the internal pointer to the first key value in the index.<br />
If you specify FIRST_ALT_KEY, LAST_ALT_KEY, or<br />
NULLVAL_ALT_KEY as rop, you cannot specify key.val.expr.<br />
, id.expr Specifies the @ID associated with the key value to position the<br />
pointer in the index.<br />
When the id.expr entered does not exist, SETINDEX sets the<br />
position to the key value following the expected location of id.expr.<br />
ON file.var Specifies the file to act on.<br />
BUFFER.KEYS<br />
ON | OFF<br />
VALIDATE.KEY<br />
ON | OFF<br />
Directs READFWD/READBCK to use or not use a buffering<br />
mechanism.<br />
ON improves performance, but you could miss some newly added<br />
key values.<br />
OFF (the default) slows performance, but you will not miss any key<br />
values added after the one you just read.<br />
Directs READFWD/READBCK to validate or not validate the key<br />
value just read against what is in the tuple. Because reading a key<br />
value and its tuple is not an atomic action, a tuple could be deleted<br />
after it is read. ON prevents this, but could degrade performance.<br />
SETINDEX Parameters
op Operators<br />
The following table describes the valid rop operators.<br />
Operator Resulting Current Alternate Key Value<br />
EQ First value equal to the specified value (default).<br />
GT First value greater than that specified.<br />
GE First value greater than or equal to that specified.<br />
LT Last value less than that specified.<br />
LE Last value less than or equal to that specified.<br />
FIRST_ALT_KEY First non-null alternate key value. Keys that are an empty string<br />
are sorted before keys containing values. If you specify<br />
FIRST_ALT_KEY as rop, you cannot specify key.val.expr.<br />
LAST_ALT_KEY Last alternate key value. If you specify LAST_ALT_KEY as<br />
rop, you cannot specify key.val.expr.<br />
NULLVAL_ALT_KEY First null alternate key value. Keys that are empty strings are<br />
sorted after null value keys, followed by keys containing<br />
values. If you specify NULLVAL_ALT_KEY as rop, you<br />
cannot specify key.val.expr.<br />
rop Operators<br />
STATUS Function Return Values<br />
After you execute SETINDEX, the STATUS function returns one of the values<br />
described in the following table.<br />
Status<br />
Value Description<br />
0 The alternate key specified exists.<br />
1 Error.<br />
2 The alternate key specified does not exist.<br />
STATUS Function Return Values<br />
SETINDEX 1-727
Examples<br />
In the following example, the program segment sets the pointer at the first occurrence<br />
of the data element containing Miller in the alternate index LNAME:<br />
1-728 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
OPEN 'CLIENTS' TO tmp<br />
ELSE STOP<br />
SETINDEX 'LNAME', 'SMITH' ON tmp<br />
The following series of examples demonstrates the use of SETINDEX to set the<br />
record pointer to the first null key in the PROD_NAME alternate key index:<br />
OPEN 'INVENTORY' TO inventory ELSE PRINT "Open error"<br />
SETINDEX 'PROD_NAME', NULLVAL_ALT_KEY inventory<br />
FOR X = 1 TO 5<br />
READFWD rec FROM inventory THEN<br />
PRINT rec:", ":rec:", ":rec<br />
END ELSE NULL<br />
NEXT X<br />
STOP<br />
This program produces the following result when no null values exist in the<br />
PROD_NAME index:<br />
:RUN BP set.idx<br />
10020, Adapter, A/C Adapter for notebook computers<br />
10086, Adapter, Ethernet LC Card<br />
10092, Adapter, Workgroup Hub<br />
10082, CD Player, Portable Model<br />
10104, CD Player, Personal Model, Bass Boost<br />
After the null value is inserted into the PROD_NAME attribute for records 10008 and<br />
56060, this same program produces the following results:<br />
:RUN BP set.idx<br />
10015, , Portable, B/W, 6 ppm<br />
10238, , Super Deluxe Model<br />
10020, Adapter, A/C Adapter for notebook computers<br />
10086, Adapter, Ethernet LC Card<br />
10092, Adapter, Workgroup Hub
The following program demonstrates the use of SETINDEX to set the record pointer<br />
to the first non-null key in the PROD_NAME alternate key index by specifying rop<br />
operator FIRST_ALT_KEY:<br />
OPEN 'INVENTORY' TO inventory ELSE PRINT "Open error"<br />
SETINDEX 'PROD_NAME', FIRST_ALT_KEY inventory<br />
FOR X = 1 TO 5<br />
READFWD rec FROM inventory THEN<br />
PRINT rec:", ":rec:", ":rec<br />
END ELSE NULL<br />
NEXT X<br />
STOP<br />
Next, run this program using the INVENTORY file that you modified to contain null<br />
values in the PROD_NAME attribute for records 10015 and 10238. The following<br />
output results.<br />
:RUN BP set.idx<br />
10020, Adapter, A/C Adapter for notebook computers<br />
10086, Adapter, Ethernet LC Card<br />
10092, Adapter, Workgroup Hub<br />
10082, CD Player, Portable Model<br />
10104, CD Player, Personal Model, Bass Boost<br />
Tip: You would obtain this same output if the INVENTORY file contained no null<br />
values in PROD_NAME and you specified rop NULLVAL_ALT_KEY.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
READBCK, READBCKL, READBCKU, READFWD, READFWDL,<br />
READFWDU, READXBCK, READXFWD, SELECTINDEX<br />
UniData<br />
BUILD.INDEX, CREATE.INDEX – For information, see the UniData <strong>Commands</strong><br />
<strong>Reference</strong>.<br />
SETINDEX 1-729
setPrivateKey<br />
Syntax<br />
setPrivateKey(key, format, keyLoc, passPhrase, validate, context)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The setPrivateKey() function loads the private key into a security context so that it<br />
can be used by SSL functions. If the context already had a set private key, it will be<br />
replaced.<br />
SSL depends on public key crypto algorithms to perform its functions. A pair of keys<br />
is needed for each communicating party to transfer data over SSL The public key is<br />
usually contained in a certificate, signed by a CA, while the private key is kept<br />
secretly by the user.<br />
Private key is used to digitally sign a message or encrypt a symmetric secret key to<br />
be used for data encryption.<br />
For detailed information about the setPrivateKey function, see <strong>UniBasic</strong> Extensions.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-730 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Key A string containing either the key or path for a key file.<br />
Format 1 - PEM (Base64 encoded) format<br />
2 - DER (ASN.1 binary) format<br />
KeyLoc 1 - key contained in key string<br />
2 - key is in a file specified by key<br />
setPrivateKey Parameters
Parameter Description<br />
passPhrase String containing the path phrase required for gaining access to the key.<br />
It can be empty if the key is not pass phrase protected. THIS IS NOT<br />
RECOMMENDED!<br />
Validate 1 - Validate against matching public key<br />
0 - Will not bother to validate<br />
Context The security context handle.<br />
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success<br />
1 Invalid Security handle<br />
2 Invalid format<br />
setPrivateKey Parameters (continued)<br />
3 Invalid key type<br />
4 Key file cannot be accessed (non-existent or wrong pass phrase)<br />
5 Certificate cannot be accessed<br />
6 Private key does not match public key in certificate<br />
7 Private key cannot be interpreted<br />
99 Other errors that prevent private key from being accepted by<br />
UniData or UniVerse.<br />
setPrivateKey Return Codes<br />
setPrivateKey 1-731
setRandomSeed<br />
Syntax<br />
setRandomSeed(inFiles, outFile, length, context)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The setRandomSeed() function generates a random seed file from a series of source<br />
files and sets that file as the default seed file for the supplied security context.<br />
The strength of cryptographic functions depends on the true randomness of the keys.<br />
This function generates and sets the random seed file used by many of the UniData<br />
cryptographic functions. By default, UniData uses the .rnd file in your current<br />
account. You can override the default by calling this function.<br />
The random seed file is specified by outFile, which is generated based on source files<br />
specified in inFiles. For Windows platforms, multiple files must be separated by “;”<br />
(a semi-colon). For Unix platforms, multiple files must be separated by “:” (a colon).<br />
The length parameter specifies how many bytes of seed data UniData should<br />
generate.<br />
If you do not specify a source in the inFiles parameter, the outFile parameter must<br />
already exist.<br />
If you do not specify context, the seed file will be used as a global seed file that<br />
applies to all cryptographic functions. However, a seed file setting in a particular<br />
security context will always override the global setting.<br />
1-732 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
inFiles A string containing source file names.<br />
outFiles A string containing the generated seed file.<br />
length The number of bytes that should be generated (the default is 1024 if less<br />
that 1024 is specified).<br />
context The Security Context handle.<br />
setRandomSeed Parameters<br />
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success.<br />
1 Invalid parameter(s).<br />
2 Random file generation error.<br />
3 Random file set error.<br />
setRandomSeed Return Codes<br />
setRandomSeed 1-733
setRequestHeader<br />
Syntax<br />
setRequestHeader(request_handle, header_name, header_value)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The setRequestHeader function allows the user to set additional headers for a<br />
request.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
The following table describes the status of each return code.<br />
1-734 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
request_handle The handle to the request returned by createRequest().<br />
header_name The name of the header.<br />
header_value The value of the header.<br />
setRequestHeader Parameters<br />
Return Code Status<br />
0 Success.<br />
1 Invalid request handle.<br />
2 Invalid header (Incompatible with method).<br />
3 Invalid header value.<br />
setRequetHeader Return Codes
Note: Since a user-defined header or header value can be transferred, it is difficult<br />
to check the validity of parameters passed to the function. <strong>UniBasic</strong> currently will<br />
not perform syntax checking on the parameters, although it will reject setting a<br />
response header to a request. Refer to RFC 2616 for valid request headers.<br />
The header set by this function overwrites settings by setHTTPDefault().<br />
This function supports Base64 encoding for Basic authentication. If header_name<br />
contains either “Authorization” or “Proxy-Authorization”, the header_value should<br />
then contain ASCII text user credential information in the format of<br />
“userid:password”, as specified by RFC 2617. This function will then encode the<br />
text based on Base64 encoding.<br />
Only Basic authentication is supported. Digest authentication may be supported in<br />
the future. Basic authentication is not safe and is not recommended for use with<br />
transferring secured data.<br />
setRequestHeader 1-735
setSocketOptions<br />
Syntax<br />
setSocketOptions(socket_handle, options)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The setSocketOptions function sets the current value for a socket option associated<br />
with a socket of any type.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-736 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
socket_handle The socket handle from openSocket(), acceptSocket(), or<br />
initServerSocket().<br />
options Dynamic Array containing information about the socket options and<br />
their current settings. The dynamic array is configured as:<br />
optName1optValue1a[optValue1b]<br />
optName2optValue2a[optValue2b]<br />
optName3...<br />
Where optName is specified by the caller and must be an option name<br />
string listed below. The first optValue specifies if the option is ON or<br />
OFF and must be one of two possible values: “1” for ON or “2” for OFF.<br />
The second optValue is optional and may hold additional data for a<br />
specific option. Currently, for the “LINGER” option it contains the<br />
delayed time (in milliseconds)before closing the socket. For all other<br />
options, it should not be specified as it will be ignored.<br />
setSocketOptions Parameters
The following table describes the available options (case-sensitive) for<br />
setSocketOptions.<br />
Option Description<br />
DEBUG Enable/disable recording of debug information.<br />
REUSEADDR Enable/disable the reuse of a location address (default)<br />
KEEPALIVE Enable/disable keeping connections alive.<br />
DONTROUTE Enable/disable routing bypass for outgoing messages.<br />
LINGER Linger on close if data is present.<br />
BROADCAST Enable/disable permission to transmit broadcast messages.<br />
OOBINLINE Enable/disable reception of out-of-band data in band.<br />
SNDBUF Set buffer size for output (default 4KB).<br />
RCVBUF Set buffer size for input (default 4KB).<br />
setSocketOptions Options<br />
The following table describes the status of each return code.<br />
Return Code Status<br />
0 Success.<br />
Non-zero See Socket Function Error Return Codes.<br />
setSocketOptions Return Codes<br />
setSocketOptions 1-737
showSecurityContext<br />
Syntax<br />
showSecurityContext(context,config)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The showSecurityContext() function dumps the SSL configuration parameters of a<br />
security context into a readable format.<br />
The security context handle must have been returned by a successful execution of<br />
createSecurityContext() or loadSecurityContext().<br />
The configuration information includes: protocol, version, certificate, cipher suite<br />
used by this connection and start time, and so forth.<br />
Warning: For security reasons, UniData does not display the privateKey installed<br />
into the context. Once installed, there is no way for you to extract it.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-738 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
context The Security Context handle.<br />
config A dynamic array containing the configuration data.<br />
saveSecurityContext Parameters
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success.<br />
1 Invalid Security Context handle.<br />
2 Configuration data could not be obtained.<br />
Return Code Status<br />
showSecurityContext 1-739
SIGNATURE<br />
Syntax<br />
SIGNATURE(algorithm, action, data, dataLoc, key, keyLoc, keyFmt, pass, sigIn,<br />
result)<br />
Description<br />
The SIGNATURE() function generates a digital signature or verifies a signature<br />
using the supplied key.<br />
The algorithm parameter specifies the digest algorithm used to construct the<br />
signature. UniData supports the MD5 and SHA1 algorithms. There are four actions<br />
you can be specify: RSA-Sign, RSA-Verify, DSA-Sign, and DSA-Verify. If you<br />
choose DSA, you can only specify SHA1 in algorithm.<br />
The data to be signed or verified against a signature can be supplied either directly in<br />
data, or read from a file whose names is in data.<br />
For signing action, you should specify a private key. For verification, a public key is<br />
usually expected. However, UniData also accepts a private key for verification<br />
purposes. Key can be either in PEM or DER format. If a private key is password<br />
protected, the password must be supplied with pass.<br />
For verification, key can also contain a certificate or name of a certificate file. A<br />
signature is expected in sigIn.<br />
For signing action, the generated signature is put into result.<br />
1-740 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
algorithm The digest algorithm used for signing or verification (must be either<br />
“MD5” or “SHA1”).<br />
action 1 - RSA-Sign<br />
2 - RSA-Verify<br />
3 - DSA-Sign<br />
4 - DSA-Verify<br />
data Data or the name of the file containing the data to be signed or verified.<br />
dataLoc 1 - Data in a string<br />
2 - Data in a file<br />
key The key or the name of the file containing the key to be used to sign or<br />
verify. In the case of verification, key can be a certificate string or a file.<br />
keyLoc 1 - Key is in a string<br />
2 - Key is in a file<br />
3 - Key is in a certificate for verification<br />
keyFmt 1 - PEM<br />
2 - DER<br />
pass A string containing the pass phrase for the private key.<br />
sigIn A string containing a digital signature.<br />
result A generated signature or a file to store the signature.<br />
SIGNATURE Parameters<br />
The following table describes the status of each return code.<br />
Return<br />
Code Status<br />
0 Success.<br />
1 Unsupported digest algorithm.<br />
2 The data cannot be read.<br />
Return Code Status<br />
SIGNATURE 1-741
Return<br />
Code Status<br />
1-742 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
3 Message digest cannot be obtained.<br />
4 Invalid parameters.<br />
5 Key cannot be read or is in the wrong format / algorithm.<br />
6 Incorrect Password.<br />
7 Signature cannot be generated.<br />
8 Signature cannot be verified.<br />
Return Code Status (continued)
SIN<br />
Syntax<br />
SIN(num.expr)<br />
Description<br />
The <strong>UniBasic</strong> SIN function returns the trigonometric sine of the numeric expression<br />
num.expr.<br />
Examples<br />
In the following example, the program segment assigns the sine of the number 25 to<br />
the variable SIN.X. The result is 0.4226.<br />
X = 25<br />
SIN.X=SIN(X)<br />
In the next example, the program statement prints 1.0000, the sine of 90:<br />
PRINT SIN(90)<br />
Related <strong>Commands</strong><br />
ACOS, ASIN, ATAN, COS, TAN<br />
SIN 1-743
SLEEP<br />
Syntax<br />
SLEEP [hh:mm[:ss]] [seconds]<br />
Synonym<br />
RQM<br />
Description<br />
The <strong>UniBasic</strong> SLEEP and RQM commands halt program execution for the time<br />
specified in seconds, or until the time specified.<br />
Tip: You can use SLEEP or RQM if you want a processing or reporting program to<br />
wait until midnight before running to better use system resources. SLEEP is also<br />
useful when waiting for the release of locked system resources.<br />
Note: The original purpose of RQM was to release remaining execution time<br />
reserved for a program, allowing other programs to use the time. If a particular<br />
program is very computation-intensive, RQM could improve overall system<br />
performance.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-744 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
hh:mm:ss Specifies the time to end sleep in hours, minutes, and (optional) seconds.<br />
You must surround the time in quotation marks.<br />
seconds Specifies the number of seconds to sleep.<br />
SLEEP Parameters
Examples<br />
In the following example, the program statement halts program execution for 10<br />
seconds:<br />
SLEEP 10<br />
In the next example, the program statement suspends program execution until 11:45<br />
PM:<br />
SLEEP “23:45”<br />
In the next example, the program statement halts program execution for one second:<br />
SLEEP<br />
SLEEP 1-745
SMUL<br />
Syntax<br />
SMUL(x, y)<br />
Description<br />
The <strong>UniBasic</strong> SMUL function multiplies two string numbers and returns the result<br />
as a string number. Arguments can be any valid numbers or string numbers of any<br />
magnitude or precision. Using string numbers rather than standard numbers degrades<br />
processing speed.<br />
If x or y contains nonnumeric data, UniData displays an error message and returns a<br />
result of 0.<br />
Tip: Processing string data type numbers rather than numeric data type numbers<br />
degrades processing speed. Numbers specified in quotation marks are string data<br />
type. Numbers specified without quotation marks are numeric data type. The data<br />
type of a variable is determined by the data first loaded into it.<br />
The SMUL function results in a string number, so you can use the function in any<br />
expression in which a string number is valid. Because string numbers can exceed the<br />
range of numbers that standard arithmetic operators can accommodate, you might not<br />
want to use the SMUL function in any expression in which a standard number is<br />
valid.<br />
Example<br />
In the following example, the program statement multiplies the constant (1.4149) by<br />
variable A and assigns the result to variable B:<br />
B = SMUL("1.4149",A)<br />
1-746 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
SOAPCreateRequest<br />
Syntax<br />
SOAPCreateRequest(URL, soapAction, Request)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Creates a SOAP request and returns a handle to the request.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
URL A string containing the URL where the web service is located. UniData<br />
sends the SOAP request to this URL. [IN]<br />
soapAction A string UniData uses as the SOAPAction HTTP header for this SOAP<br />
request. [IN]<br />
Request The returned handle to the SOAP request. This handle can be used in<br />
subsequent calls to the SOAP API for <strong>UniBasic</strong>. [OUT]<br />
SOAPCreateRequest Parameters<br />
SOAPCreateRequest 1-747
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
Return Code Description<br />
You can also use the <strong>UniBasic</strong> STATUS() function to obtain the return status from the<br />
function.<br />
1-748 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
0 Function complete successfully.<br />
1 Invalid URL syntax.<br />
2 Invalid HTTP method (indicates the POST method is not<br />
supported by the HTTP server).<br />
SOAPCreateRequest Return Codes
SOAPCreateSecureRequest<br />
Syntax<br />
SOAPCreateSecureRequest(URL, soapAction, Request, security_context)<br />
Description<br />
The SOAPCreateSecureRequest function creates a secure SOAP request and<br />
returns a handle to the request.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
URL A string containing the URL where the web service is located.<br />
UniVerse sends the SOAP request to this URL. For information<br />
about the format of the URL, see URL Format. [IN]<br />
soapAction A string UniVerse uses as the SOAPAction HTTP header for this<br />
SOAP request. [IN]<br />
Request The returned handle to the SOAP request. You can use this<br />
handle can be used in subsequent calls to the SOAP API for<br />
UniVerse BASIC. [OUT]<br />
security_context A handle to the security context.<br />
SOAPCreateSecureRequest Parameters<br />
URL Format<br />
The URL you specify must follow the syntax defined in RFS 1738. The general<br />
format is:<br />
http://:/path>?<br />
SOAPCreateSecureRequest 1-749
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Note: If the URL you define contains a searchpart, you must define it in its encoded<br />
format. For example, a space is converted to +, and other nonalphanumeric<br />
characters are converted to %HH format.<br />
You do not need to specify the host and path parameters in their encoded formats.<br />
UniVerse BASIC encodes these parameters prior to communicating with the web<br />
server.<br />
Return Code<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
You can also use the UniVerse BASIC STATUS() function to obtain the return status<br />
from the function.<br />
1-750 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
host Either a name string or an IP address of the host system.<br />
port The port number to which you want to connect. If you do not specify<br />
port, UniVerse defaults to 80. Omit the preceding colon if you do not<br />
specify this parameter.<br />
path Defines the file you want to retrieve on the web server. If you do not<br />
specify path, UniVerse defaults to the home page.<br />
searchpart Use searchpart to send additional information to a web server.<br />
URL Parameters<br />
Return Code Description<br />
0 Function complete successfully.<br />
1 Invalid URL syntax.<br />
2 Invalid HTTP method (indicates the POST method is not supported by the<br />
HTTP server).<br />
101 Invalid security context handle.<br />
SOAPCreateSecureRequest Return Codes
Example<br />
The following code segment illustrates the SOAPCreateSecureRequest function:<br />
* Create the Request<br />
Ret = SoapCreateSecureRequest(URL, SoapAction, SoapReq,<br />
SecurityContext)<br />
IF Ret 0 THEN<br />
STOP "Error in SoapCreateSecureRequest: " : Ret<br />
END<br />
.<br />
.<br />
SOAPCreateSecureRequest 1-751
SOAPGetDefault<br />
Syntax<br />
SOAPGetDefault(option, value)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Gets default SOAP settings, such as the SOAP version.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-752 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
option A string containing an option name. UniData currently only supports the<br />
VERSION option. [IN]<br />
value A string returning the option value. [OUT]<br />
SOAPGetDefault Parameters
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
Return<br />
Code Description<br />
0 Function completed successfully.<br />
1 Invalid option (currently, UniData only supports the VERSION<br />
option).<br />
SOAPGetDefault Return Codes<br />
You can also use the <strong>UniBasic</strong> STATUS() function to obtain the return status from the<br />
function.<br />
SOAPGetDefault 1-753
SOAPGetFault<br />
Syntax<br />
SOAPGetFault(respData, soapFault)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Parses the response data from SOAPSubmitRequest after receiving a SOAP Fault,<br />
into a dynamic array of SOAP Fault components.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-754 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
respData Response data from SOAPSubmitRequest after receiving a SOAP fault.<br />
[IN]<br />
soapFault Dynamic array consisting of Fault Code, Fault String, and optional Fault<br />
Detail, for example:<br />
@AM@AM@AM<br />
Fault code values are XML-qualified names, consisting of:<br />
? VersionMismatch<br />
? MustUnderstand<br />
? DTDNotSupported<br />
? DataEncoding Unknown<br />
? Sender<br />
? Receiver<br />
SOAPGetFault Parameters
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
Return Code Description<br />
0 Function completed successfully.<br />
1 Invalid response data, possibly not a valid XML document.<br />
2 SOAP Fault not found in response data.<br />
SOAPGetFault Return Codes<br />
You can also use the <strong>UniBasic</strong> STATUS() function to obtain the return status from the<br />
function.<br />
SOAPGetFault 1-755
SOAPGetResponseHeader<br />
Syntax<br />
SOAPGetResponseHeader(Request, headerName, headerValue)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Gets a specific response header after issuing a SOAP request.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-756 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Request Handle to the request created with SOAPCreateRequest. [IN]<br />
headerName The header name whose value is being queried. [IN]<br />
headerValue The header value, if present in the response, or empty string if not (in<br />
which case the return status of the function is 2). [OUT]<br />
SOAPGetResponseHeader Parameters
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
Return Code Description<br />
0 Function completed successfully.<br />
1 Invalid request handle.<br />
2 Header not found in set of response headers.<br />
SOAPGetResponseHeader Return Codes<br />
You can also use the <strong>UniBasic</strong> STATUS() function to obtain the return status from the<br />
function.<br />
SOAPGetResponseHeader 1-757
SOAPRequestWrite<br />
Syntax<br />
SOAPRequestWrite(Request, reqDoc, docTypeFlag)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Outputs the SOAP request in XML format to a string or to a file.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-758 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Request Handle to the request created with SOAPCreateRequest. [IN]<br />
reqDoc Depending on docTypeFlag, either an output string containing<br />
the SOAP request content, or a path to a file where the SOAP<br />
request content will be written. [OUT]<br />
docTypeFlag A flag indicating whether reqDoc is an output string that is to<br />
hold the request content, or a path to a file where the SOAP<br />
request content will be written.<br />
? 0 – reqDoc is a file where the request content will be written<br />
upon successul completion.<br />
? 1 – reqDoc is a string that will hold the request upon<br />
successful completion. [IN]<br />
SOAPRequestWrite Parameters
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
Return<br />
Code Description<br />
0 Function completed successfully.<br />
1 Invalid request handle.<br />
2 Unable to open the file named by reqDoc.<br />
3 Unable to write to the file named by reqDoc.<br />
SOAPRequestWrite Return Codes<br />
You can also use the <strong>UniBasic</strong> STATUS() function to obtain the return status from the<br />
function.<br />
SOAPRequestWrite 1-759
SOAPSetDefault<br />
Syntax<br />
SOAPSetDefault(option, value)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Setup default SOAP settings, such as SOAP version.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-760 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
option A string containing an option name. UniData currently only supports the<br />
“VERSION” option. [IN]<br />
value A string containing the appropriate option value. For the VERSION<br />
option, the string should be 1.0, 1.1, or 1.2. [IN]<br />
SOAPSetDefault Paramreters
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
Return<br />
Code Description<br />
0 Function completed successfully.<br />
1 Invalid option (currently, UniData only supports VERSION).<br />
2 Invalid value. 1.1 assumed.<br />
SOAPSetDefault Return Codes<br />
You can also use the <strong>UniBasic</strong> STATUS() function to obtain the return status from the<br />
function.<br />
USAGE NOTES<br />
The default SOAP version is 1.1. The namespace prefixes "env" and "enc" are<br />
associated with the SOAP namespace names<br />
http://schemas.xmlsoap.org/soap/envelope/ and<br />
http://schemas.xmlsoap.org/soap/encoding/ respectively. The namespace prefixed<br />
"xsi" and "xsd" are associated with the namespace names<br />
http://www.w3.org/1999/XMLSchema-instance and<br />
http://www.w3.org/1999/XMLSchema respectively.<br />
The SOAP version can be set to 1.2 to support the newer SOAP 1.2 protocol. The<br />
namespace prefixes "env" and "enc" will be associated with the SOAP namespace<br />
names "http://www.w3.org/2001/12/soap-envelope" and<br />
"http://www.w3.org/2001/12/soap-encoding" respectively. The namespace prefixes<br />
"xsd" and "xsi" will be associated with the namespace names<br />
"http://www.w3.org/2001/XMLSchema" and<br />
"http://www.w3.org/2001/XMLSchema-instance" respectively.<br />
All defaults set by SOAPSetDefault will be in effect until the end of the current<br />
UniData session. If you do not want the setting to affect subsequent programs, you<br />
need to clear it before exiting the current program.<br />
SOAPRequestWrite 1-761
Along with SOAPSetDefault, the CallHTTP function setHTTPDefault may be called<br />
to set HTTP-specific settings or headers, if the HTTP default settings are not<br />
sufficient.<br />
1-762 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
SOAPSetParameters<br />
Syntax<br />
SOAPSetParameters(Request, URI, serviceName, value)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Descripton<br />
Sets up the SOAP request body, specifying a remote method to call along with the<br />
method's parameter list.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Request Handle to the request created with SOAPCreateRequest. [IN]<br />
namespace A string that is used as the namespace URI for the SOAP call. [IN]<br />
method The name of the method to be called. [IN]<br />
paramArray A dynamic array containing the method parameters for the SOAP call.<br />
Each method parameter consists of the following values:<br />
? A parameter name<br />
? A parameter value<br />
? A parameter type (if type is omitted, xsd:string will be used.<br />
name, value, and type are separated by @VM. Additional parameters are<br />
separated by @AM, as shown in the following example:<br />
@VM@VM@AM@VM@VM...[IN]<br />
SOAPSetParameters Parameters<br />
SOAPSetParameters 1-763
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
You can also use the <strong>UniBasic</strong> STATUS() function to obtain the return status from the<br />
function.<br />
Usage Notes<br />
As an example, the following inputs:<br />
will set the SOAP body as follows:<br />
1-764 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return<br />
Code Description<br />
0 Funtion completed successfully.<br />
1 Invalid request handle was passed to the function.<br />
SOAPSetParameters Return Codes<br />
Input Description<br />
Method “getStockQuote”<br />
namespace “http://host/#StockQuoteService”<br />
paramArray “symbol”:@VM:”IBM”:@VM:”xsd:string”<br />
SOAPSet Parameters Usage Notes<br />
<br />
<br />
IBM<br />
<br />
SOAPSetRequestBody<br />
Syntax<br />
SOAPSetRequestBody(Request, value)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Sets up a SOAP request body directly, as opposed to having it be constructed through<br />
the SOAPSetParameters function. With this function it also possible to attach<br />
multiple body blocks to the SOAP request.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Request Handle to the request created with SOAPCreateRequest. [IN]<br />
value A dynamic array containing SOAP body blocks, for example:<br />
@AM... [IN]<br />
SOAPSetRequestBody Parameters<br />
SOAPSetRequestBody 1-765
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
You can also use the <strong>UniBasic</strong> STATUS() function to obtain the return status from the<br />
function.<br />
1-766 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return<br />
Code Description<br />
0 Function completed successfully.<br />
1 Invalid request handle.<br />
SOAPSetRequestBody Return Codes
SOAPSetRequestContent<br />
Syntax<br />
SOAPSetRequestContent(Request, reqDoc, docTypeFlag)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Sets the entire SOAP request's content from an input string or from a file.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Request Handle to the request created with SOAPCreateRequest. [IN]<br />
reqDoc The input document to be used as the SOAP request content. [IN]<br />
docTypeFlag A flag indicating whether reqDoc is a string holding the actual content,<br />
or the path to a file holding the content.<br />
? 0 – reqDoc is a file holding the request content.<br />
? 1 – reqDoc is a string holding the request content.<br />
[IN]<br />
SOAPSetRequestContent Parameters<br />
SOAPSetRequestContent 1-767
Return Codes<br />
The return code indicating success or failure. The following table describes the status<br />
of each return code.<br />
You can also use the <strong>UniBasic</strong> STATUS() function to obtain the return status from the<br />
function.<br />
1-768 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return<br />
Code Description<br />
0 Function completed successfully.<br />
1 Invalid request handle.<br />
2 Unable to open the file named by reqDoc.<br />
3 Unable to read the file named by reqDoc.<br />
SOAPSetRequestContent Return Codes
SOAPSetRequestHeader<br />
Syntax<br />
SOAPSetRequestHeader(Request, value)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Sets up a SOAP request header. By default, there is no SOAP header.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Request Handle to the request created with SOAPCreateRequest. [IN]<br />
value A dynamic array containing SOAP header blocks, for example:<br />
@AM...[IN]<br />
SOAPSetRequestHeader Parameters<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
Return<br />
Code Description<br />
0 Function completed successfully.<br />
1 Invalid request handle.<br />
SOAPSetRequestHeader Return Codes<br />
SOAPSetRequestHeader 1-769
You can also use the <strong>UniBasic</strong> STATUS() function to obtain the return status from the<br />
function.<br />
1-770 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
SOAPSubmitRequest<br />
Syntax<br />
SOAPSubmitRequest(Request, timeout, respHeaders, respData, soapStatus)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Submits a request and gets the response.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Request Handle to the request created with SOAPCreateRequest. [IN]<br />
timeout Timeout, in milliseconds, to wait for a response. [IN]<br />
respHeaders Dynamic array of HTTP response headers and their associated values.<br />
[OUT]<br />
respData The SOAP response message. [OUT]<br />
soapStatus Dynamic array containing status code and explanatory text. [OUT]<br />
SOAPSubmitRequest Parameters<br />
SOAPSubmitRequest 1-771
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
You can also use the <strong>UniBasic</strong> STATUS() function to obtain the return status from the<br />
function.<br />
Usage Notes<br />
Internally, SOAPSubmitRequest utilizes CallHTTP's submitRequest() to send out the<br />
SOAP message. The soapStatus variable holds the status from the underlying<br />
CallHTTP function. If an error occurs on the SOAP server while processing the<br />
request, soapStatus will indicate an HTTP 500 "Internal Server Error", and respData<br />
will be a SOAP Fault message indicating the server-side processing error.<br />
1-772 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Code Description<br />
0 Function completed successfully.<br />
1 Invalid request handle.<br />
2 Request timed out.<br />
3 Network error occurred.<br />
4 Other error occurred.<br />
SOAPSubmitRequest Return Codes
SORT<br />
Syntax<br />
SORT(var)<br />
Description<br />
The SORT function enables you to sort a dynamic array.<br />
The elements in the dynamic array are sorted in ascending order, left-justified.<br />
<strong>UniBasic</strong> sorts the dynamic array by the highest system delimiter in the array.<br />
If the dynamic array contains any attribute marks, the sort is by attribute.<br />
Values and subvalues remain with the original attribute.<br />
If the dynamic array contains value marks and no attribute marks, the sort is<br />
by value. Subvalues are unaffected and remain with the original value.<br />
If the dynamic array contains subvalue marks and neither attribute marks<br />
nor value marks, the sort is by subvalue.<br />
Parameter<br />
The following table describes the parameter of the syntax.<br />
Parameter Description<br />
var The name of the dynamic array to sort.<br />
SORT Parameter<br />
SORT 1-773
SOUNDEX<br />
Syntax<br />
SOUNDEX(expr)<br />
Description<br />
The <strong>UniBasic</strong> SOUNDEX function converts an expression into a phonetic code. This<br />
function can return unpredictable results with multibyte characters.<br />
Tip: Use SOUNDEX to compare alphabetic strings, such as names, when an<br />
alternate spelling or misspelling should not cause a mismatch. expr is an expression<br />
evaluating to a string value.<br />
SOUNDEX evaluates the expression by:<br />
1-774 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Returning the first alphabetic letter.<br />
Converting the remainder of the string to uppercase.<br />
Ignoring letters A, E, H, I, O, U, W, Y, and nonalphabetic characters.<br />
Converting each valid letter to a phonetic code.<br />
Testing for duplication. If a character is next to another character that has<br />
the same phonetic code, it is not included.<br />
Adjusting the length of the code to four characters by truncating codes<br />
longer than four characters or padding with zeros any expression less than<br />
four characters.
SOUNDEX Phonetic Codes<br />
The following table displays the phonetic code for each letter that UniData evaluates.<br />
Examples<br />
The following table shows SOUNDEX sample output values.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
Code Letters<br />
1 B F P V<br />
2 C G J K Q S X Z<br />
3 D T<br />
4 L<br />
5 M N<br />
6 R<br />
<strong>UniBasic</strong> SOUNDEX Phonetic Codes<br />
Expression SOUNDEX<br />
STEPHEN S315<br />
STEVEN S315<br />
TERMINATE T655<br />
RRR R600<br />
SOUNDEX Sample Output Values<br />
ICONV SOUNDEX (S), OCONV SOUNDEX (S)<br />
SOUNDEX 1-775
SPACE<br />
Syntax<br />
SPACE(expr)<br />
Description<br />
The <strong>UniBasic</strong> SPACE function returns a string containing the specified number of<br />
spaces.<br />
Note: Functions can be concatenated within a PRINT statement.<br />
Example<br />
In the following example, the program statement prints HI and THERE separated by<br />
15 spaces:<br />
1-776 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
PRINT "HI":SPACE(15):"THERE"<br />
This results in:<br />
HI THERE<br />
Related Command<br />
<strong>UniBasic</strong><br />
SPACES
SPACES<br />
Syntax<br />
SPACES(dyn.array.expr)<br />
Description<br />
The <strong>UniBasic</strong> SPACES function returns the number of spaces specified in each<br />
element of the dynamic array dyn.array.expr.<br />
Example<br />
In the following example, the program segment prints the number of spaces specified<br />
in each element of the dynamic array ARR1:<br />
ARR1 = 1:@AM:2:@AM:3:@AM:4:@AM:5<br />
ARR2 = SPACES(ARR1)<br />
This results in ARR2 containing one space in the first element, two spaces in the<br />
second element, and so forth.<br />
Related Command<br />
<strong>UniBasic</strong><br />
SPACE<br />
SPACES 1-777
SPLICE<br />
Syntax<br />
SPLICE(expr1,"expr", expr2)<br />
Description<br />
The <strong>UniBasic</strong> SPLICE function concatenates two strings or arrays and inserts an<br />
expression between them.<br />
Parameters<br />
The following table describes each parameter of the syntax:<br />
Parameter Description<br />
Examples<br />
In the following example, the program segment concatenates PHONE to NUMBER<br />
and inserts a dash (-) between the two strings:<br />
1-778 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
expr1 Specifies the first string or array to concatenate.<br />
expr Specifies the expression to insert between expr1 and expr2 when concatenating<br />
them.<br />
expr2 Specifies the second string or array to concatenate.<br />
SPLICE s arameter<br />
PHONE = "555"<br />
NUMBER = "1234"<br />
PRINT SPLICE (PHONE,"-",NUMBER)<br />
This results in:<br />
555-1234
The following program inserts the null value between PHONE and NUMBER. The<br />
CALLED subroutine, PRINT.SETUP, converts UniData delimiters and the null value<br />
to printable characters (this subroutine is printed in the entry for CHANGE in this<br />
manual).<br />
PRT.STG=''<br />
PHONE = "555"<br />
NUMBER = "1234"<br />
STG = SPLICE (PHONE,@NULL,NUMBER)<br />
CALL PRINT.SETUP(STG,PRT.STG)<br />
PRINT PRT.STG<br />
END<br />
This program prints the following:<br />
555@NULL1234<br />
In the following example, the program segment concatenates each element of array<br />
ARR1 to array ARR2 and inserts a plus sign (+) between the two elements:<br />
ARR1 = 1:@AM:2:@AM:3<br />
ARR2 = 4:@AM:5:@AM:6<br />
PRINT SPLICE (ARR1,"+",ARR2)<br />
This results in the following:<br />
1+4}2+5}3+6<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CAT, CATS<br />
SPLICE 1-779
SQLAllocConnect<br />
Syntax<br />
status = SQLAllocConnect (bci.env, connect.env)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLAllocConnect allocates and initializes a connection environment in a UniData<br />
BCI environment.<br />
Use this function to create a connection environment to connect to a particular data<br />
source. One UniData BCI environment can have several connection environments,<br />
one for each data source. The function stores the internal representation of the<br />
connection environment in the connect.env variable.<br />
Note: Use the connection environment variable only in UniData BCI calls that<br />
require it. Using it improperly can cause a runtime error and break communication<br />
with the data source.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-780 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
bci.env UniData BCI environment variable returned in an SQLAllocEnv call.<br />
connect.env Variable that represents the allocated connection environment.<br />
SQLAllocConnect Parameters
Return Values<br />
The following table describes return values from the SQLAllocConnect function.<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLAllocConnect Return Values<br />
SQLAllocConnect 1-781
SQLAllocEnv<br />
Syntax<br />
status = SQLAllocEnv (bci.env)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLAllocEnv creates an environment in which to execute UniData BCI calls.<br />
Use this function to allocate memory for a UniData BCI environment. The function<br />
stores the address in the bci.env variable. SQLAllocEnv must be the first UniData<br />
BCI call issued in any application.<br />
You can allocate more than one UniData BCI environment.<br />
Note: Use the environment variable only in UniData BCI calls that require it. Using<br />
it in any other context causes a runtime error or breaks communication with the data<br />
source.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-782 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
bci.env Variable that represents the allocated UniData BCI environment.<br />
SQLAllocEnv Parameters
Return Values<br />
The following table describes return values from the SQLAllocEnv function.<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
−1 SQL.ERROR<br />
SQLAllocEnv Return Values<br />
SQLAllocEnv 1-783
SQLAllocStmt<br />
Syntax<br />
status = SQLAllocStmt (connect.env, statement.env)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLAllocStmt creates an SQL statement environment in which to execute SQL<br />
statements.<br />
Use this function to allocate memory for an SQL statement environment.<br />
Note: Use the SQL statement environment variable only in UniData BCI calls that<br />
require it. Using it in any other context causes a runtime error or breaks<br />
communication with the data source.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-784 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
connect.env Connection environment used in SQLAllocConnect and<br />
SQLConnect calls. If you have not established a connection to the<br />
data source using connect.env, an error is returned to the application.<br />
statement.env Variable that represents an SQL statement environment.<br />
SQLAllocStmt Parameters
Return Values<br />
The following table describes return values from the SQLAllocStmt function.<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLAllocStmt Return Values<br />
SQLAllocStmt 1-785
SQLBindCol<br />
Syntax<br />
status = SQLBindCol (statement.env, col#, data.type, column)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Use this function to tell UniData BCI where to return the results of an SQLFetch call.<br />
SQLBindCol defines the name of the variable (column) to contain column results<br />
retrieved by SQLFetch, and specifies the data conversion (data.type) on the fetched<br />
data. SQLBindCol has no effect until SQLFetch is used.<br />
Normally you call SQLBindCol once for each column of data in the result set. When<br />
SQLFetch is issued, data is moved from the result set at the data source and put into<br />
the variables specified in the SQLBindCol call, overwriting existing variable<br />
contents.<br />
Data is converted from the SQL data type at the data source to the <strong>UniBasic</strong> data type<br />
requested by the SQLBindCol call, if possible. If data cannot be converted to<br />
data.type, an error occurs.<br />
Values are returned only for bound columns. Unbound columns are ignored and are<br />
not accessible. For example, if a SELECT command returns three columns, but<br />
SQLBindCol was called for only two columns, data from the third column is not<br />
accessible to your program. If you bind more variables than there are columns in the<br />
result set, an error is returned. If you bind no columns and an SQLFetch is issued,<br />
the cursor advances to the next row of results.<br />
You need not use SQLBindCol with SQL statements that do not produce result sets.<br />
1-786 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
statement.env SQL statement environment of the executed SQL statement.<br />
col# Column number of result data, starting at 1. This value must be from 1<br />
to the number of columns returned in an operation.<br />
data.type BASIC data type into which to convert the incoming data. Possible<br />
values are the following:<br />
SQL.B.CHAR – Character string data.<br />
SQL.B.BINARY – Bit string (raw) data.<br />
SQL.B.NUMBER – Numeric data (integer or double).<br />
SQL.B.DEFAULT – SQL data type determines the BASIC data type.<br />
SQL.B.INTDATE – UniData date in internal format.<br />
SQL.B.INTTIME – UniData time in internal format.<br />
column Variable that will contain column results obtained with SQLFetch.<br />
SQLBindCol Parameters<br />
Return Values<br />
The following table describes the return values of the SQLBindCol function.<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLBindCol Return Values<br />
SQLBindCol 1-787
SQLBindParameter<br />
Syntax<br />
status = SQLBindParameter ( statement.env, mrk#, data.type, sql.type, prec, scale,<br />
param [ , param.type ] )<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLBindParameter specifies where to find values for input parameter markers<br />
when you issue an SQLExecute or SQLExecDirect call. For output parameter<br />
markers, SQLBindParameter specifies where to find the return value of a called<br />
procedure.<br />
Parameter markers are placeholders in SQL statements. Input parameter markers let<br />
a program send user-defined values with the SQL statement when an SQLExecute<br />
or SQLExecDirect call is executed repeatedly. Output parameter markers receive<br />
values returned from a called procedure. The placeholder character is ? (question<br />
mark).<br />
SQLBindParameter tells the system where to find the variables to substitute for<br />
parameter markers in the SQL statement and how to convert the data before sending<br />
it to the data source. You need to do only one SQLBindParameter for each<br />
parameter marker in the SQL statement, no matter how many times the statement is<br />
to be executed.<br />
For example, consider the following SQL statement:<br />
1-788 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
INSERT INTO T1 VALUES (?,?,?);<br />
If you want to load 1000 rows, you need issue only three SQLBindParameter calls,<br />
one for each question mark.
Normally you specify data.type as SQL.B.BASIC. If you specify sql.type as<br />
SQL.DATE, however, you can specify data.type as SQL.B.INTDATE; if you specify<br />
sql.type as SQL.TIME, you can specify data.type as SQL.B.INTTIME. If you specify<br />
sql.type as SQL.BINARY, SQL.VARBINARY, or SQL.LONGVARBINARY, you<br />
can specify data.type as SQL.B.BINARY.<br />
If you use SQL.B.INTDATE, the UniData BCI assumes the program variable holds<br />
a date in UniData internal date format and uses the DATEFORM conversion string<br />
to convert the internal date to an external format as required by the data source. To<br />
set or change the DATEFORM conversion string, see the SQLSetConnectOption<br />
function.<br />
If you specify sql.type as SQL.TIME and data.type as SQL.B.INTTIME, UniData<br />
BCI assumes the program variable holds a time in UniData internal time format and<br />
does not convert the data.<br />
SQLBindParameter uses the value of prec only for the following SQL data types:<br />
SQL.CHAR<br />
SQL.VARCHAR<br />
SQL.LONGVARCHAR<br />
SQL.WCHAR<br />
SQL.WVARCHAR<br />
SQL.WLONGVARCHAR<br />
SQL.BINARY<br />
SQL.VARBINARY<br />
SQL.LONGVARBINARY<br />
SQL.NUMERIC<br />
SQL.DECIMAL<br />
For all other data types, the extended parameters DBLPREC, FLOATPREC, and<br />
INTPREC determine the maximum length for strings representing double-precision<br />
numbers, floating-point numbers, and integers.<br />
SQLBindParameter 1-789
Parameters<br />
The following table describes each parameter of the syntax.<br />
Input Variable Description<br />
1-790 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
statement.env SQL statement environment associated with an SQL statement.<br />
mrk# Number of the parameter marker in the SQL statement to which this<br />
call refers. Parameter markers in the SQL statement are numbered left<br />
to right, starting at 1.<br />
data.type <strong>UniBasic</strong> data type to bind to the parameter. data.type must be one of<br />
the following:<br />
SQL.B.BASI – Use with any sql.type.<br />
SQL.B.BINARY – Use only when sql.type is SQL.BINARY,<br />
SQL.VARBINARY, or SQL.LONGVARBINARY.<br />
SQL.B.INTDATE – Use only when sql.type is SQL.DATE.<br />
SQL.B.INTTIME – Use only when sql.type is SQL.TIME.<br />
sql.type SQL data type to which the <strong>UniBasic</strong> variable is converted.<br />
prec Precision of the parameter, representing the width of the parameter. If<br />
prec is 0, default values are used.<br />
scale Scale of the parameter, used only when sql.type is SQL.DECIMAL or<br />
SQL.NUMERIC.<br />
param Variable that contains the data to use when SQLExecute or<br />
SQLExecDirect is called.<br />
param.type Type of parameter. param.type can be one of the following:<br />
SQL.PARAM.INPUT – Use for parameters in an SQL statement that<br />
does not call a procedure, or for input parameters in a procedure call.<br />
SQL.PARAM.OUTPUT – Use for parameters that mark the output<br />
parameter in a procedure.<br />
SQL.PARAM.INPUT.OUTPUT – Use for an input/output parameter<br />
in a procedure.<br />
If you do not specify param.type, SQL.PARAM.INPUT is used.<br />
SQLBindParameter Input Variables
Return Values<br />
The following table describes the return values of the SQLBindParameter function.<br />
Return<br />
Value Description<br />
0 SQL.SUCCESS<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLBindParameter Return Values<br />
SQLBindParameter 1-791
SQLCancel<br />
Syntax<br />
status = SQLCancel (statement.env)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
This function is equivalent to the SQLFreeStmt call with the SQL.CLOSE option. It<br />
closes any open cursor associated with the SQL statement environment and discards<br />
pending results at the data source.<br />
It is good practice to issue SQLCancel when all results have been read from the data<br />
source, even if the SQL statement environment will not be reused immediately for<br />
another SQL statement. Issuing SQLCancel frees any locks that may be held at the<br />
data source.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
1-792 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Input Variable Description<br />
statement.env SQL statement environment.<br />
SQLCancel Parameters
Return Values<br />
The following table describes the return values of the SQLCancel function.<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLCancel Return Values<br />
SQLCancel 1-793
SQLColAttributes<br />
Syntax<br />
status = SQLColAttributes (statement.env, col#, col.attribute, text.var, num.var)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Use this function to get information about a column. SQLColAttributes returns the<br />
specific information requested by the value of col.attribute.<br />
Some DBMSs (such as SYBASE) do not make column information available until<br />
after the SQL statement is executed. In such cases, issuing an SQLColAttributes<br />
call before executing the statement produces an error.<br />
The SQL.SUCCESS.WITH.INFO return occurs when you issue the call for a column<br />
that contains an unsupported data type or when text.var is truncated. The SQL data<br />
type returned is SQL.BINARY (−2).<br />
If you are connected to an ODBC database, SQL.COLUMN.NULLABLE always<br />
returns SQL.NULLABLE.UNKNOWN.<br />
When you are connected to an ODBC data source, calling SQLColAttributes with<br />
one of the column attributes returns a status of SQL.ERROR with SQLSTATE set to<br />
S1091.<br />
1-794 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
statement.env SQL statement environment of the executed SQL statement.<br />
col# Column number to describe, starting with 1.<br />
col.attribute Attribute of the column that needs information. col.attribute values<br />
are listed under “Description” in this section. These values are<br />
defined in the ODBC.H file.<br />
text.var Contains column information for attributes returning text data. If the<br />
return value is numeric, text.var contains invalid information.<br />
num.var Contains column information for attributes returning numeric data. If<br />
the return value is text, num.var contains invalid information.<br />
SQLColAttributes Parameters<br />
The following table lists the column attributes you can use with ODBC databases.<br />
Column Attribute Output Description<br />
SQL.COLUMN.AUTO.INCREMENT num.var 1 – TRUE if the column values<br />
are incremented automatically.<br />
0 – FALSE if the column values<br />
are not incremented<br />
automatically.<br />
SQL.COLUMN.CASE.SENSITIVE num.var 1 – TRUE for character data.<br />
0 – FALSE for all other data.<br />
SQL.COLUMN.COUNT num.var Number of columns in result set.<br />
The col# argument must be a<br />
valid column number in the result<br />
set.<br />
SQL.COLUMN.DISPLAY.SIZE num.var Maximum number of characters<br />
required to display data from the<br />
column.<br />
SQL.COLUMN.LABEL text.var<br />
Column Attributes<br />
Column heading.<br />
SQLColAttributes 1-795
1-796 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Column Attribute Output Description<br />
SQL.COLUMN.LENGTH num.var Number of bytes transferred by an<br />
SQLFetch call.<br />
SQL.COLUMN.NAME text.var Name of specified column.<br />
SQL.COLUMN.NULLABLE num.var Column can contain null values.<br />
Can return one of the following:<br />
0 – SQL.NO.NULLS<br />
1 – SQL.NULLABLE<br />
2 –<br />
SQL.NULLABLE.UNKNOWN<br />
SQL.COLUMN.PRECISION num.var Column precision.<br />
SQL.COLUMN.SCALE num.var Column scale.<br />
SQL.COLUMN.SEARCHABLE num.var Always returns 3,<br />
SQL.SEARCHABLE.<br />
SQL.COLUMN.TABLE.NAME text.var Name of the table to which the<br />
column belongs. If the column is<br />
an expression, an empty string is<br />
returned.<br />
SQL.COLUMN.TYPE num.var Number representing the SQL<br />
type of this column.<br />
SQL.COLUMN.TYPE.NAME text.var Data type name for column,<br />
specific to the data source.<br />
SQL.COLUMN.UNSIGNED num.var 1 – TRUE for nonnumeric data<br />
types.<br />
0 – FALSE for all other data<br />
types.<br />
SQL.COLUMN.UPDATABLE num.var Any expressions or computed<br />
columns return<br />
SQL.ATTR.READONLY, and<br />
stored data columns return<br />
SQL.ATTR.WRITE.<br />
Column Attributes (continued)
Return Values<br />
The following table describes the return values of the SQLColAttributes function.<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
ODBC Data Sources<br />
1 SQL.SUCCESS.WITH.INFO<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLColAttributes Return Values<br />
The following table lists the column attributes you can use only with ODBC<br />
databases.<br />
Column Attribute Output Description<br />
SQL.COLUMN.MONEY num.var 1 – TRUE if column is money<br />
data type.<br />
0 – FALSE if column is not<br />
money data type.<br />
SQL.COLUMN.OWNER.NAME text.var Owner of the table containing<br />
the column.<br />
SQL.COLUMN.QUALIFIER.NAME text.var Qualifier of the table<br />
containing the column.<br />
ODBC Column Attributes<br />
SQLColAttributes 1-797
SQLColumns<br />
Syntax<br />
status = SQLColumns (statement.env, schema, owner, tablename, columnname )<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
This function returns a result set in statement.env as a cursor of 12 columns<br />
describing those columns found by the search pattern (see SQLTables). As with<br />
SQLTables, the search is done on the SQL catalog. This is a standard result set that<br />
can be accessed with SQLFetch. The ability to obtain descriptions of columns does<br />
not imply that a user has any privileges on those columns.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
1-798 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Parameter Description<br />
statement.env SQL statement environment.<br />
schema Schema name search pattern.<br />
owner Table owner number search pattern.<br />
tablename Table name search pattern.<br />
columnname Column name search pattern.<br />
SQLColumns Input Variables
Result Set<br />
The result set contains 12 columns:<br />
Column Name Data Type<br />
TABLE.SCHEMA VARCHAR(128)<br />
OWNER INTEGER<br />
TABLE.NAME VARCHAR(128)<br />
COLUMN.NAME VARCHAR(128)<br />
DATA.TYPE SMALLINT<br />
TYPE.NAME VARCHAR(128)<br />
NUMERIC.PRECISION INTEGER<br />
CHAR.MAX.LENGTH INTEGER<br />
NUMERIC.SCALE SMALLINT<br />
NUMERIC.PREC.RADIX SMALLINT<br />
NULLABLE SMALLINT<br />
REMARKS VARCHAR(254)<br />
SQLColumns Result Set<br />
The application is responsible for binding variables for the output columns and<br />
fetching the results using SQLFetch.<br />
SQLColumns 1-799
Return Values<br />
The following table describes the returns values of the SQLColumns function.<br />
SQLSTATE Values<br />
The following table shows all possible SQLSTATE values returned by<br />
SQLColumns.<br />
SQLSTAT<br />
E Description<br />
1-800 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Value Description<br />
0 SQL.SUCCESS<br />
1 SQL.SUCCESS.WITH.INFO<br />
–1 SQL.ERROR<br />
–2 SQL.INVALID.HANDLE<br />
SQLColumns Return Values<br />
S1000 General error for which no specific SQLSTATE code has been defined.<br />
S1001 Memory allocation failure.<br />
S1008 Cancelled. Execution of the statement was stopped by an SQLCancel call.<br />
S1010 Function sequence error. The statement.env specified is currently executing<br />
an SQL statement.<br />
S1C00 The table owner field was not numeric.<br />
24000 Invalid cursor state. Results are still pending from the previous SQL<br />
statement. Use SQLCancel to clear the results.<br />
42000 Syntax error or access violation. This can be caused by a variety of reasons.<br />
The native error code returned by the SQLError call indicates the specific<br />
UniData error that occurred.<br />
SQLSTATE Values
SQLConnect<br />
Syntax<br />
status = SQLConnect (connect.env, data.source, login1, login2)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Use this function to connect to the ODBC data source specified by data.source. Use<br />
the login1 and login2 parameters to log in to the DBMS specified by the ODBC<br />
data.source.<br />
You cannot use SQLConnect within a transaction. An SQLConnect call issued<br />
within a transaction returns SQL.ERROR, and sets SQLSTATE to 25000, indicating<br />
that the SQLConnect function is illegal within a transaction.<br />
A connection is established when the data source validates the user name and<br />
authorization.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
connect.env Connection environment assigned in a previous SQLAllocConnect.<br />
SQLConnect Input Variables<br />
SQLConnect 1-801
Parameter Description<br />
Return Values<br />
The following table describes the return values of the SQLConnect function.<br />
1-802 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
data.source Data source name. For ODBC data sources, this is the name of a data<br />
source specified by the data source management program you are using.<br />
login1 For ODBC data sources, this is typically the password for the remote<br />
database or operating system.<br />
For the specific information required for login1 when connecting to ODBC<br />
data sources, see the configuration for the specific driver used.<br />
login2 For ODBC data sources, this is typically the password for the remote<br />
database or operating system.<br />
For the specific information required for login2 when connecting to ODBC<br />
data sources, see the configuration for the specific driver used.<br />
SQLConnect Input Variables (continued)<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
1 SQL.SUCCESS.WITH.INFO<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLConnect Return Values
SQLDescribeCol<br />
Syntax<br />
status = SQLDescribeCol (statement.env, col#, col.name, sql.type, prec, scale, null)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Use this function to get information about the column described by col#.<br />
The SQL.SUCCESS.WITH.INFO return occurs when you issue the call for a column<br />
that contains an unsupported data type, or if col.name is truncated. The SQL data type<br />
returned is SQL.BINARY (−2).<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
statement.env SQL statement environment of the executed SQL statement.<br />
col# Column number to describe, starting with 1.<br />
col.name Column name.<br />
sql.type SQL data type of the column, a numeric code defined in the ODBC.H<br />
file.<br />
SQLDescribeCol Input Variables<br />
SQLDescribeCol 1-803
Parameter Description<br />
Return Values<br />
The following table describes the return values of the SQLDescribeCol function.<br />
1-804 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
prec Precision of the column, or –1 if precision is unknown.<br />
scale Scale of the column, or –1 if scale is unknown.<br />
null One of the following:<br />
0 – SQL.NO.NULLS: field cannot contain NULL.<br />
1 – SQL.NULLABLE: field can contain NULL.<br />
2 – SQL.NULLABLE.UNKNOWN: not known whether field can<br />
contain NULL.<br />
SQLDescribeCol Input Variables (continued)<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
1 SQL.SUCCESS.WITH.INFO<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLDescribeCol Return Values
SQLDisconnect<br />
Syntax<br />
status = SQLDisconnect (connect.env)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLDisconnect disconnects a connection environment from a data source.<br />
You cannot use SQLDisconnect within a transaction. An SQLDisconnect call<br />
issued within a transaction returns SQL.ERROR, and sets SQLSTATE to 25000. You<br />
must commit or abort active transactions before disconnecting, and you must be in<br />
autocommit mode. If there is no active transaction, SQLDisconnect frees all SQL<br />
statement environments owned by this connection before disconnecting.<br />
SQLDisconnect returns SQL.SUCCESS.WITH.INFO if an error occurs but the<br />
disconnect succeeds.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
connect.env Connection environment.<br />
SQLDisconnect Input Variable<br />
SQLDisconnect 1-805
Return Values<br />
The following table describes the return values of the SQLDisconnect function.<br />
1-806 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Value Description<br />
0 SQL.SUCCESS<br />
1 SQL.SUCCESS.WITH.INFO<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLDisconnect Return Values
SQLError<br />
Syntax<br />
status = SQLError (bci.env, connect.env, statement.env, sqlstate, dbms.code, error)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLError returns error status information about one of the three environments you<br />
use.<br />
Use SQLError when a function returns a status value other than SQL.SUCCESS or<br />
SQL.INVALID.HANDLE. SQLError returns a value in sqlstate when UniData BCI<br />
detects an error condition. The dbms.code field contains information from the data<br />
source that identifies the error.<br />
Each environment type maintains its own error status. SQLError returns errors for<br />
the rightmost nonnull environment. For example, to get errors associated with a<br />
connection environment, specify input variables and constants in the following order:<br />
bci.env, connect.env, SQL.NULL.HSTMT<br />
To get errors associated with a particular SQL statement environment, specify the<br />
following:<br />
bci.env, connect.env, statement.env<br />
If all arguments are null, SQLError returns a status of SQL.NO.DATA.FOUND and<br />
sets SQLSTATE to 00000.<br />
Since multiple errors can be returned for a variable, you should call SQLError until<br />
it returns a status of SQL.NO.DATA.FOUND. This ensures that all errors are<br />
reported.<br />
SQLError 1-807
ODBC Data Sources<br />
When a program is connected to an ODBC server, errors can be detected by UniData<br />
BCI, by the ODBC driver, or by the data source. When the error is returned, the<br />
source of the error is indicated by bracketed items in the error output variable, as<br />
shown in the following examples.<br />
Errors detected by Unidata BCI:<br />
1-808 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
[IBM][SQL Client] An illegal configuration option was found<br />
Errors detected by the ODBC driver:<br />
SQLConnect error: Status = -1 SQLState = S1000 Natcode =<br />
9352<br />
[ODBC] [INTERSOLV][ODBC Oracle driver][Oracle]ORA-09352: Windows<br />
32-bit<br />
Two-Task driver unable to spawn new ORACLE task<br />
For information about errors detected by the ODBC driver manager, see the<br />
Microsoft ODBC 2.0 Programmer’s <strong>Reference</strong> and SDK Guide.<br />
Errors detected by the data source:<br />
[IBM][SQL Client][IBM] Database not found or no system<br />
permissions.<br />
For information about errors detected by the data source, see the documentation<br />
provided for the DBMS running on the data source.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
bci.env UniData BCI environment or the constant SQL.NULL.HENV.<br />
connect.env Connection environment or the constant SQL.NULL.HDBC.<br />
statement.env SQL statement environment or the constant SQL.NULL.HSTMT.<br />
SQLError Input Variables
Parameter Description<br />
sqlstate SQLSTATE code. This code describes the UniData BCI Client error<br />
associated with the environment passed. sqlstate is always a fivecharacter<br />
string.<br />
dbms.code Error code specific to the data source. dbms.code contains an integer<br />
error code from the data source. If dbms.code is 0, the error was detected<br />
by UniData BCI. For the meanings of specific error codes, see the<br />
documentation provided for the data source.<br />
error Text describing the error in more detail.<br />
Return Values<br />
SQLError Input Variables (continued)<br />
The following table describes the return values of the SQLError function.<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
1 SQL.SUCCESS.WITH.INFO<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
100 SQL.NO.DATA.FOUND<br />
SQLError Return Values<br />
SQLError 1-809
SQLExecDirect<br />
Syntax<br />
status = SQLExecDirect (statement.env, statement)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLExecDirect accepts an SQL statement or procedure call and delivers it to the<br />
data source for execution. It uses the current values of any SQL statement parameter<br />
markers.<br />
SQLExecDirect differs from SQLExecute in that it does not require a call to<br />
SQLPrepare. SQLExecDirect prepares the SQL statement or procedure call<br />
implicitly. Use SQLExecDirect when you do not need to execute the same SQL<br />
statement or procedure repeatedly.<br />
You can use parameter markers in the SQL statement or procedure call as long as you<br />
have resolved each marker with an SQLBindParameter call.<br />
After an SQLExecDirect call you can use SQLNumResultCols, SQLDescribeCol,<br />
SQLRowCount, or SQLColAttributes to get information about the resulting<br />
columns. You can use SQLNumResultCols to determine if the SQL statement or<br />
procedure call created a result set.<br />
If the executed SQL statement or procedure produces a set of results, you must use<br />
an SQLFreeStmt call with the SQL.CLOSE option before you execute another SQL<br />
statement or procedure call using the same SQL statement environment. The<br />
SQL.CLOSE option cancels any pending results still waiting at the data source.<br />
1-810 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Your application programs should not try to issue transaction control statements<br />
directly to the data source (for instance, by issuing a COMMIT statement with<br />
SQLExecDirect or SQLPrepare). Programs should use only <strong>UniBasic</strong> transaction<br />
control statements. UniData BCI issues the correct combination of transaction<br />
control statements and middleware transaction control function calls that are appropriate<br />
for the DBMS you are using. Trying to use SQLExecDirect to execute explicit<br />
transaction control statements on ODBC data sources can cause unexpected results<br />
and errors.<br />
When SQLExecDirect calls a procedure, it does not begin a transaction. If a transaction<br />
is active when a procedure is called, the current transaction nesting level is<br />
maintained.<br />
Note: If you execute a stored procedure or enter a command batch with multiple<br />
SELECT statements, the results of only the first SELECT statement are returned.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
statement.env SQL statement environment from a previous SQLAllocStmt.<br />
SQLExecDirect Input Variables<br />
SQLExecDirect 1-811
Parameter Description<br />
Return Values<br />
The following table describes the return values of the SQLExecDirect function.<br />
1-812 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
statement Either an SQL statement or a call to an SQL procedure, to be executed at<br />
the data source. If you are connected to an ODBC data source, it may<br />
treat identifiers and keywords in the SQL statement case-sensitively.<br />
To call an SQL procedure, use one of the following syntaxes:<br />
[ { ] CALL procedure [ ( [ parameter [ , parameter ] … ] ) ] [ } ]<br />
If you are connected to an ODBC data source, use the first syntax and<br />
enclose the entire call statement in braces.<br />
procedure Name of the procedure. If the procedure name contains characters other<br />
than alphabetic or numeric, enclose the name in double quotation marks.<br />
To embed a single double quotation mark in the procedure name, use two<br />
consecutive double quotation marks.<br />
parameter Either a literal value or a parameter marker that marks where to insert<br />
values to send to or receive from the data source. Programmatic SQL<br />
uses a ? (question mark) as a parameter marker.<br />
Use parameters only if the procedure is a subroutine. The number and<br />
order of parameters must correspond to the number and order of the<br />
subroutine arguments. For an ODBC data source, parameters should be<br />
of the same data type as the procedure requires.<br />
SQLExecDirect Input Variables (continued)<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
1 SQL.SUCCESS.WITH.INFO<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLExecDirect Return Values
SQLExecute<br />
Syntax<br />
status = SQLExecute (statement.env)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Use this function to repeatedly execute an SQL statement, using different values for<br />
parameter markers. You must use an SQLPrepare call to prepare the SQL statement<br />
before you can use SQLExecute. If the SQL statement specified in the SQLPrepare<br />
call contains parameter markers, you must also issue an SQLBindParameter call for<br />
each marker in the SQL statement before you use SQLExecute. After you load the<br />
parameter marker variables with data to send to the data source, you can issue the<br />
SQLExecute call. By setting new values in the parameter marker variables and<br />
calling SQLExecute, new data values are sent to the data source and the SQL<br />
statement is executed using those values.<br />
If the SQL statement uses parameter markers, SQLExecute performs any data<br />
conversions required by the SQLBindParameter call for the parameter markers. If<br />
the SQL statement executed produces a set of results, you must use an SQLFreeStmt<br />
call with the SQL.CLOSE option before you execute another SQL statement using<br />
the same SQL statement environment. The SQL.CLOSE option cancels any pending<br />
results still waiting at the data source.<br />
Your application programs should not try to issue transaction control statements<br />
directly to the data source (for instance, by issuing a TRANSACTION COMMIT<br />
statement with SQLExecDirect or SQLPrepare). Programs should use only<br />
<strong>UniBasic</strong> transaction control statements. UniData BCI issues the correct combination<br />
of transaction control statements and middleware transaction control function calls<br />
that are appropriate for the DBMS you are using. Trying to use SQLExecute to<br />
execute explicit transaction control statements on ODBC data sources can cause<br />
unexpected results and errors.<br />
SQLExecute 1-813
SQLExecute tells the data source to execute a prepared SQL statement or a called<br />
procedure, using the current values of any parameter markers used in the statement.<br />
Using SQLExecute with an SQLBindParameter call is the most efficient way to<br />
execute a statement repeatedly, since the statement does not have to be parsed by the<br />
data source each time it is issued.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Return Values<br />
The following table describes the return values of the SQLExecute function.<br />
1-814 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
statement.env SQL statement environment associated with a prepared SQL statement.<br />
SQLExecute Parameter<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
1 SQL.SUCCESS.WITH.INFO<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLExecute Return Values
SQLFetch<br />
Syntax<br />
status = SQLFetch (statement.env)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Use this function to retrieve the next row’s column values from the result set at the<br />
data source and put them into the variables specified with SQLBindCol. SQLFetch<br />
performs any required data conversions.<br />
SQLFetch returns SQL.SUCCESS.WITH.INFO if numeric data is truncated or<br />
rounded when converting SQL values to UniData values.<br />
SQLFetch logically advances the cursor to the next row in the result set. Unbound<br />
columns are ignored and are not available to the application. When no more rows are<br />
available, SQLFetch returns a status of 100 (SQL.NO.DATA.FOUND).<br />
Your application must issue an SQLFetch call at the same transaction nesting level<br />
(or deeper) as the corresponding SQLExecDirect or SQLExecute call. Also, an<br />
SQLFetch call must be executed at the same transaction isolation level as the<br />
SELECT statement that generates the data. If it does not, SQLFetch returns<br />
SQL.ERROR and sets SQLSTATE to S1000.<br />
Use SQLFetch only when a result set is pending at the data source.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
statement.env SQL statement environment of the executed SQL statement.<br />
SQLFetch Parameters<br />
SQLFetch 1-815
Return Values<br />
The following table describes the return values of the SQLFetch function.<br />
1-816 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Value Description<br />
0 SQL.SUCCESS<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
1 SQL.SUCCESS.WITH.INFO<br />
100 SQL.NO.DATA.FOUND<br />
SQLFetch Return Values
SQLFreeConnect<br />
Syntax<br />
status = SQLFreeConnect (connect.env)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLFreeConnect releases a connection environment and its resources.<br />
You must use SQLDisconnect to disconnect the connection environment from the<br />
data source before you release the connection environment with SQLFreeConnect,<br />
otherwise an error is returned.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
connect.env Connection environment.<br />
SQLFreeConnect Parameters<br />
SQLFreeConnect 1-817
Return Values<br />
The following table describes the return values of the SQLFreeConnect function.<br />
1-818 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Value Description<br />
0 SQL.SUCCESS<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLFreeConnect Return Values
SQLFreeEnv<br />
Syntax<br />
status = SQLFreeEnv (bci.env)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLFreeEnv releases an SQL Client Interface environment and its resources.<br />
You must use SQLFreeConnect to release all connection environments attached to<br />
the UniData BCI environment before you release the UniData BCI environment with<br />
SQLFreeEnv, otherwise an error is returned.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
bci.env UniData BCI environment.<br />
SQLFreeEnv Parameters<br />
SQLFreeEnv 1-819
Return Values<br />
The following table describes the return values of the SQLFreeEnv function.<br />
1-820 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Value Description<br />
0 SQL.SUCCESS<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLFreeEnv Return Values
SQLFreeStmt<br />
Syntax<br />
status = SQLFreeStmt (statement.env, option)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLFreeStmt frees some or all resources associated with an SQL statement<br />
environment.<br />
If your program uses the same SQL statement environment to execute different SQL<br />
statements, use SQLFreeStmt with the SQL.DROP option, then use SQLAllocStmt<br />
to reallocate a new SQL statement environment. This unbinds all bound columns and<br />
resets all parameter marker variables.<br />
It is good practice to issue SQLFreeStmt with the SQL.CLOSE option when all<br />
results have been read from the data source, even if the SQL statement environment<br />
will not be reused immediately for another SQL statement. Issuing SQLFreeStmt<br />
with the SQL.CLOSE option frees any locks that may be held at the data source.<br />
SQLFreeStmt 1-821
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-822 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
statement.env SQL statement environment.<br />
option option is one of the following:<br />
SQL.CLOSE – Closes any open cursor associated with<br />
the SQL statement environment and discards pending<br />
results at the data source. Using the SQL.CLOSE<br />
option cancels the current query. All parameter<br />
markers and columns remain bound to the variables<br />
specified in the SQLBindCol and<br />
SQLBindParameter calls.<br />
SQL.UNBIND – Releases all bound column variables<br />
defined in SQLBindCol for this SQL statement<br />
environment.<br />
SQL.RESET.PARAMS – Releases all parameter<br />
marker variables set by SQLBindParameter for this<br />
SQL statement environment.<br />
SQL.DROP – Releases the SQL statement<br />
environment. This option terminates all access to the<br />
SQL statement environment. SQL.DROP also closes<br />
cursors, discards pending results, unbinds columns,<br />
and resets parameter marker variables.<br />
Options are defined in the ODBC.H file.<br />
SQLFreeStmt Input Variables
Return Values<br />
The following table describes the return values of the SQLFreeStmt function.<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLFreeStmt Return Values<br />
SQLFreeStmt 1-823
SQLGetInfo<br />
Syntax<br />
status = SQLGetInfo (connect.env, info.type, info.value)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLGetInfo returns general information about the ODBC driver and the data<br />
source.<br />
This function supports all of the possible requests for information defined in the<br />
ODBC 2.0 specification. The #defines for info.type are contained in the ODBC.H<br />
include file.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-824 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
connect.env Connection environment.<br />
info.type The specific information requested. For a list of values, see the info.type<br />
tables under “Description.”<br />
info.value The information returned by SQLGetInfo.<br />
SQLGetInfo Parameters
ODBC info.type Values<br />
The following table lists the valid ODBC values for info.type. For more detailed<br />
information about information types, see Microsoft ODBC 2.0 Programmer’s<br />
<strong>Reference</strong> and SDK Guide.<br />
Driver Information<br />
SQL.ACTIVE.CONNECTIONS SQL.DRIVER.VER<br />
SQL.ACTIVE.STATEMENTS SQL.FETCH.DIRECTION<br />
SQL.DATA.SOURCE.NAME SQL.FILE.USAGE<br />
SQL.DRIVER.HDBC SQL.GETDATA.EXTENSIONS<br />
SQL.DRIVER.HENV SQL.LOCK.TYPES<br />
SQL.DRIVER.HLIB SQL.ODBC.API.CONFORMANCE<br />
SQL.DRIVER.HSTMT SQL.ODBC.SAG.CLI.CONFORMANCE<br />
SQL.DRIVER.NAME SQL.ODBC.VER<br />
SQL.DRIVER.ODBC.VER SQL.POS.OPERATIONS<br />
SQL.ROW.UPDATES SQL.SERVER.NAME<br />
SQL.SEARCH.PATTERN.ESCAPE<br />
DBMS Product Information<br />
SQL.DATABASE.NAME SQL.DBMS.VER<br />
SQL.DBMS.NAME<br />
Data Source Information<br />
SQL.ACCESSIBLE.PROCEDURES SQL.OWNER.TERM<br />
SQL.ACCESSIBLE.TABLES SQL.PROCEDURE.TERM<br />
SQL.BOOKMARK.PERSISTENCE SQL.QUALIFIER.TERM<br />
ODBC info.type Values<br />
SQLGetInfo 1-825
1-826 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
SQL.CONCAT.NULL.BEHAVIOR SQL.SCROLL.CONCURRENCY<br />
SQL.CURSOR.COMMIT.BEHAVIOR SQL.SCROLL.OPTIONS<br />
SQL.DATA.SOURCE.READ.ONLY SQL.STATIC.SENSITIVITY<br />
SQL.DEFAULT.TXN.ISOLATION SQL.TABLE.TERM<br />
SQL.MULT.RESULT.SETS SQL.TXN.CAPABLE<br />
SQL.MULTIPLE.ACTIVE.TXN SQL.TXN.ISOLATION.OPTION<br />
SQL.NEED.LONG.DATA.LEN SQL.USER.NAME<br />
SQL.NULL.COLLATION<br />
Supported SQL<br />
SQL.ALTER.TABLE SQL.ODBC.SQL.OPT.IEF<br />
SQL.COLUMN.ALIAS SQL.ORDER.BY.COLUMNS.IN.SELECT<br />
SQL.CORRELATION.NAME SQL.OUTER.JOINS<br />
SQL.EXPRESSIONS.IN.ORDER.BY SQL.OWNER.USAGE<br />
SQL.GROUP.BY SQL.POSITIONED.STATEMENTS<br />
SQL.IDENTIFIER.CASE SQL.PROCEDURES<br />
SQL.IDENTIFIER.QUOTE.CHAR SQL.QUALIFIER.LOCATION<br />
SQL.KEYWORDS SQL.QUALIFIER.NAME.SEPARATOR<br />
SQL.LIKE.ESCAPE.CLAUSE SQL.QUALIFIER.USAGE<br />
SQL.NON.NULLABLE.COLUMNS SQL.QUOTED.IDENTIFIER.CASE<br />
SQL.ODBC.SQL.CONFORMANCE SQL.SPECIAL.CHARACTERS<br />
SQL.SUBQUERIES SQL.UNION<br />
SQL Limits<br />
ODBC info.type Values (continued)
SQL.MAX.BINARY.LITERAL.LEN SQL.MAX.OWNER.NAME.LEN<br />
SQL.MAX.CHAR.LITERAL.LEN SQL.MAX.PROCEDURE.NAME.LEN<br />
SQL.MAX.COLUMN.NAME.LEN SQL.MAX.QUALIFIER.NAME.LEN<br />
SQL.MAX.COLUMNS.IN.GROUP.BY SQL.MAX.ROW.SIZE<br />
SQL.MAX.COLUMNS.IN.ORDER.BY SQL.MAX.ROW.SIZE.INCLUDES.LONG<br />
SQL.MAX.COLUMNS.IN.INDEX SQL.MAX.STATEMENT.LEN<br />
SQL.MAX.COLUMNS.IN.SELECT SQL.MAX.TABLE.NAME.LEN<br />
SQL.MAX.COLUMNS.IN.TABLE SQL.MAX.TABLES.IN.SELECT<br />
SQL.MAX.CURSOR.NAME.LEN SQL.MAX.USER.NAME.LEN<br />
SQL.MAX.INDEX.SIZE<br />
Scalar Function Information<br />
SQL.CONVERT.FUNCTIONS SQL.TIMEDATE.ADD.INTERVALS<br />
SQL.NUMERIC.FUNCTIONS SQL.TIMEDATE.DIFF.INTERVALS<br />
SQL.STRING.FUNCTIONS SQL.TIMEDATE.FUNCTIONS<br />
SQL.SYSTEM.FUNCTIONS<br />
Conversion Information<br />
SQL.CONVERT.BIGINT SQL.CONVERT.LONGVARCHAR<br />
SQL.CONVERT.BINARY SQL.CONVERT.NUMERIC<br />
SQL.CONVERT.BIT SQL.CONVERT.REAL<br />
SQL.CONVERT.CHAR SQL.CONVERT.SMALLINT<br />
SQL.CONVERT.DATE SQL.CONVERT.TIME<br />
SQL.CONVERT.DECIMAL SQL.CONVERT.TIMESTAMP<br />
ODBC info.type Values (continued)<br />
SQLGetInfo 1-827
Return Values<br />
The following table lists the return values of the SQLGetInfo function.<br />
1-828 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
SQL.CONVERT.DOUBLE SQL.CONVERT.TINYINT<br />
SQL.CONVERT.FLOAT SQL.CONVERT.VARBINARY<br />
SQL.CONVERT.INTEGER SQL.CONVERT.VARCHAR<br />
SQL.CONVERT.LONGVARBINARY<br />
ODBC info.type Values (continued)<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
1 SQL.SUCCESS.WITH.INFO<br />
–1 SQL.ERROR<br />
–2 SQL.INVALID.HANDLE<br />
SQLGetInfo Return Values
SQLGetTypeInfo<br />
Syntax<br />
status = SQLGetTypeInfo (statement.env, sql.type)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLGetTypeInfo returns information about an SQL on the data source. You can use<br />
SQLGetTypeInfo only against ODBC data sources.<br />
SQLGetTypeInfo returns a standard result set ordered by DATA.TYPE and<br />
TYPE.NAME.<br />
SQLGetTypeInfo 1-829
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-830 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
statement.env SQL statement environment.<br />
sql.type A driver-specific SQL data type, or one of the following:<br />
SQL.B.BINARY<br />
SQL.BIGINT<br />
SQL.BINARY<br />
SQL.BIT<br />
SQL.C.BINARY<br />
SQL.CHAR<br />
SQL.DATE<br />
SQL.DECIMAL<br />
SQL.DOUBLE<br />
SQL.FLOAT<br />
SQL.INTEGER<br />
SQL.LONGVARBINARY<br />
SQL.LONGVARCHAR<br />
SQL.NUMERIC<br />
SQL.REAL<br />
SQL.SMALLINT<br />
SQL.TIME<br />
SQL.TIMESTAMP<br />
SQL TINYINT<br />
SQL.VARBINARY<br />
SQL.VARCHAR<br />
SQL.WCHAR<br />
SQL.WLONGVARCHAR<br />
SQL.WVARCHAR<br />
SQLGetTypeInfo Input Variables
Result Set<br />
The following table lists the columns in the result set. For more detailed information<br />
about data type information, see the Microsoft ODBC 2.0 Programmer’s <strong>Reference</strong><br />
and SDK Guide.<br />
Column Name Data Type Description<br />
TYPE.NAME Varchar Data-source-dependent data type name.<br />
DATA.TYPE Smallint Driver-dependent or SQL data type.<br />
PRECISION Integer Maximum precision of the data type on<br />
the data source.<br />
LITERAL.PREFIX Varchar(128) Characters used to prefix a literal.<br />
LITERAL.SUFFIX Varchar(128) Characters used to terminate a literal.<br />
CREATE.PARAMS Varchar(128) Parameters for a data type definition.<br />
NULLABLE Smallint Data type accepts null values. Returns<br />
one of the following:<br />
SQL.NO.NULLS<br />
SQL.NULLABLE<br />
SQL.NULLABLE.UNKNOWN<br />
CASE.SENSITIVE Smallint Character data type is case-sensitive.<br />
Returns one of the following:<br />
TRUE if data type is a character data<br />
type and is case-sensitive<br />
FALSE if data type is not a character<br />
data type and is not case-sensitive<br />
SQLGetTypeInfo Results<br />
SQLGetTypeInfo 1-831
1-832 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Column Name Data Type Description<br />
SEARCHABLE Smallint How the WHERE clause uses the data<br />
type. Returns one of the following:<br />
SQL.UNSEARCHABLE if data type<br />
cannot be used<br />
SQL.LIKE.ONLY if data type can be<br />
used only with the LIKE predicate<br />
SQL.ALL.EXCEPT.LIKE if data type<br />
can be used with all comparison<br />
operators except LIKE<br />
SQL.SEARCHABLE if data type can be<br />
used with any comparison operator<br />
UNSIGNED.ATTRIBUTE Smallint Data type is unsigned. Returns one of the<br />
following:<br />
TRUE if data type is unsigned<br />
FALSE if data type is signed<br />
NULL if attribute is not applicable to the<br />
data type or the data type is not numeric<br />
MONEY Smallint Data type is a money data type. Returns<br />
one of the following:<br />
TRUE if data type is a money data type<br />
FALSE if it is not<br />
AUTO.INCREMENT Smallint Data type is autoincrementing. Returns<br />
one of the following:<br />
TRUE if data type is autoincrementing<br />
FALSE if it is not<br />
NULL if attribute is not applicable to the<br />
data type or the data type is not numeric<br />
LOCAL.TYPE.NAME Varchar(128) Localized version of TYPE.NAME.<br />
MINIMUM.SCALE Smallint Minimum scale of the data type on the<br />
data source.<br />
MAXIMUM.SCALE Smallint Maximum scale of the data type on the<br />
data source.<br />
SQLGetTypeInfo Results
Return Values<br />
The following table describes the return values of the SQLGetTypeInfo function.<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
1 SQL.SUCCESS.WITH.INFO<br />
–1 SQL.ERROR<br />
–2 SQL.INVALID.HANDLE<br />
SQLGetTypeInfo Return Values<br />
SQLGetTypeInfo 1-833
SQLNumParams<br />
Syntax<br />
status = SQLNumParams (statement.env, parameters)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLNumParams returns the number of parameters in an SQL statement.<br />
Use this function after preparing or executing an SQL statement or procedure call to<br />
find the number of parameters in an SQL statement. If the statement associated with<br />
statement.env contains no parameters, parameters is set to 0.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-834 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
statement.env SQL statement environment containing the prepared or executed<br />
SQL statement.<br />
parameters Number of parameters in the statement.<br />
SQLNumParams Parameters
Return Values<br />
The following table describes the return values of the SQLNumParams function.<br />
Return<br />
Value Description<br />
0 SQL.SUCCESS<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLNumParams Return Values<br />
SQLNumParams 1-835
SQLNumResultCols<br />
Syntax<br />
status = SQLNumResultCols (statement.env, cols)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLNumResultCols returns the number of columns in a result set.<br />
Use this function after executing an SQL statement to find the number of columns in<br />
the result set. If the executed statement was not a SELECT statement or a called<br />
procedure that produced a result set, the number of result columns returned is 0.<br />
Use this function when the number of columns to be bound to application variables<br />
is unknown, for example, when your program is processing SQL statements entered<br />
by users.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-836 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
statement.env SQL statement environment containing the executed SQL statement.<br />
cols Number of report columns generated.<br />
SQLNumResultCols Parameters
Return Values<br />
The following table describes the return values of the SQLNumResultCols function.<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLNumResultCols Return Values<br />
SQLNumResultCols 1-837
SQLParamOptions<br />
Syntax<br />
status = SQLParamOptions (statement.env, option, value)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLParamOptions lets applications load an array of parameter markers in a single<br />
SQLExecDirect or SQLExecute function call. Use this function only when you are<br />
connected to an ODBC data source.<br />
SQLParamOptions works for all parameter types—output and input/output parameters<br />
as well as the more usual input parameters.<br />
Be careful when you use matrices instead of arrays. For example, in the matrix:<br />
dim matrix(10,10)<br />
the elements 1,1, 1,2, ..., 1,10, 2,1, 2,2, ... occupy consecutive memory locations.<br />
Since SQLParamOptions requires each location specified in SQLBind Parameter to<br />
point to a consecutive series of values in memory, an application using a matrix must<br />
load the values of the matrix in the correct order.<br />
When the SQL statement is executed, all variables are checked, data is converted<br />
when necessary, and all values in the set are verified to be appropriate and within the<br />
bounds of the marker definition. Values are then copied to low-level structures<br />
associated with each parameter marker. If a failure occurs while the values are being<br />
checked, SQLExecDirect or SQLExecute returns SQL.ERROR, and value contains<br />
the number of the row where the failure occurred.<br />
1-838 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
statement.env SQL statement environment.<br />
option One of the following, followed by a value:<br />
SQL.PARAMOPTIONS.SET – value is an input variable containing the<br />
number of rows to process. It can be an integer from 1 through 1024.<br />
SQL.PARAMOPTIONS.READ – value is an output variable containing<br />
the number of parameter rows processed by SQLExecDirect or SQLExecute.<br />
As each set of parameters is processed, value is updated to the<br />
current row number. If SQLExecDirect or SQLExecute encounters<br />
an error, value contains the number of the row that failed.<br />
value If option is SQL.PARAMOPTIONS.SET, value is the number of rows to<br />
process. It can be an integer from 1 through 1024. 1 is the default.<br />
If option is SQL.PARAMOPTIONS.READ, value contains the number of<br />
parameter rows processed by SQLExecDirect or SQLExecute. As each<br />
set of parameters is processed, value is updated to the current row number.<br />
SQLParamOptions Parameters<br />
Return Values<br />
The following table describes the return values of the SQLParamOptions function.<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
1 SQL.SUCCESS.WITH.INFO<br />
–1 SQL.ERROR<br />
–2 SQL.INVALID.HANDLE<br />
SQLParamOptions Return Values<br />
SQLParamOptions 1-839
Example<br />
This example shows how you might use SQLParamOptions to load a simple table.<br />
Table TAB1 has two columns: an integer column and a CHAR(30) column.<br />
1-840 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
$include INCLUDE ODBC.H<br />
arrsize = 20<br />
dim p1(arrsize)<br />
dim p2(arrsize)<br />
SQLINS1 = "INSERT INTO TAB1 VALUES(?,?)"<br />
rowindex = 0<br />
status = SQLAllocEnv(henv)<br />
status = SQLAllocConnect(henv, hdbc)<br />
status = SQLConnect(hdbc, "odbcds", "dbuid", "dbpwd")<br />
status = SQLAllocStmt(hdbc, hstmt)<br />
status = SQLPrepare(hstmt, SQLINS1)<br />
status = SQLBindParameter(hstmt, 1, SQL.B.BASIC, SQL.INTEGER, 0,<br />
0, p1(1),<br />
SQL.PARAM.INPUT)<br />
status = SQLBindParameter(hstmt, 2, SQL.B.BASIC, SQL.CHAR, 30, 0,<br />
p2(1),<br />
SQL.PARAM.INPUT)<br />
status = SQLParamOptions(hstmt, SQL.PARAMOPTIONS.SET, arrsize)<br />
for index = 1 to arrsize<br />
p1(index) = index<br />
p2(index) = "This is row ":index<br />
next index<br />
* now execute, delivering 20 sets of parameters in one network<br />
operation<br />
stexec = SQLExecute(hstmt)<br />
status = SQLParamOptions(hstmt, SQL.PARAMOPTIONS.READ, rowindex)<br />
if stexec = SQL.ERROR then<br />
print "Error in parameter row number ":rowindex<br />
end else<br />
print rowindex:" parameter marker sets were processed"<br />
end
SQLPrepare<br />
Syntax<br />
status = SQLPrepare (statement.env, statement)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLPrepare passes an SQL statement or procedure call to the data source in order<br />
to prepare it for execution by SQLExecute.<br />
Use this function to deliver either an SQL statement or a call to an SQL procedure to<br />
the data source where it can prepare to execute the passed SQL statement or the<br />
procedure. The application subsequently uses SQLExecute to tell the data source to<br />
execute the prepared SQL statement or procedure.<br />
What happens when the data source executes the SQLPrepare call depends on the<br />
data source. In many cases the data source parses the SQL statement and generates<br />
an execution plan that allows rapid, efficient execution of the SQL statement.<br />
Use SQLPrepare and SQLExecute functions when you are issuing SQL statements<br />
or calling a procedure repeatedly. You can supply values to a prepared INSERT or<br />
UPDATE statement and issue an SQLExecute call each time you change the values<br />
of parameter markers. SQLExecute sends the current values of the parameter<br />
markers to the data source and executes the prepared SQL statement or procedure<br />
with the current values.<br />
Note: Before you issue an SQLExecute call, all parameter markers in the SQL<br />
statement or procedure call must be defined using an SQLBindParameter call,<br />
otherwise SQLExecute returns an error.<br />
If the parameter type of an SQLBindParameter procedure is<br />
SQL.PARAM.OUTPUT or SQL.PARAM.INPUT.OUTPUT, values are returned to<br />
the specified program variables.<br />
SQLPrepare 1-841
ODBC Data Sources<br />
If you execute a stored procedure or enter a command batch with multiple SELECT<br />
statements, the results of only the first SELECT statement are returned.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-842 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
statement.env SQL statement environment from a previous SQLAllocStmt.<br />
statement Either an SQL statement or a call to an SQL procedure, to be executed at<br />
the data source.<br />
To call an SQL procedure, use the following syntax:<br />
[ { ] CALL procedure [ ( [ parameter [ , parameter ] … ] ) ] [ } ]<br />
procedure Name of the procedure. If the procedure name contains characters other<br />
than alphabetic or numeric, enclose the name in double quotation marks.<br />
To embed a single double quotation mark in the procedure name, use two<br />
consecutive double quotation marks.<br />
parameter Either a literal value or a parameter marker that marks where to insert<br />
values to send to or receive from the data source. Programmatic SQL<br />
uses a ? (question mark) as a parameter marker.<br />
Use parameters only if the procedure is a subroutine. The number and<br />
order of parameters must correspond to the subroutine arguments. For an<br />
ODBC data source, parameters should be of the same data type as the<br />
procedure requires.<br />
SQLPrepare Parameters
Return Values<br />
The following table describes the returns values of the SQLPrepare function.<br />
Return<br />
Value Description<br />
0 SQL.SUCCESS<br />
1 SQL.SUCCESS.WITH.INFO<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLPrepare Return Values<br />
SQLPrepare 1-843
SQLRowCount<br />
Syntax<br />
status = SQLRowCount (statement.env, rows)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLRowCount returns the number of rows changed by UPDATE, INSERT, or<br />
DELETE statements, or by a called procedure that executes one of these statements.<br />
Statements such as GRANT and CREATE TABLE, which do not update rows in the<br />
database, return 0 in rows.<br />
For a SELECT statement, a 0 row count is always returned, unless the SELECT<br />
statement includes the TO SLIST clause. In that case, SQLRowCount returns the<br />
number of rows in the select list.<br />
The value of rows returned after executing a stored procedure at the data source may<br />
not be accurate. It is accurate for a single UPDATE, INSERT, or DELETE statement.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Input Variable Description<br />
1-844 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
statement.env SQL statement environment containing the executed SQL statement.<br />
rows Number of rows affected by the operation.<br />
SQLRowCount Parameters
Return Values<br />
The following table describes the return values of the SQLRowCount function.<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLRowCount Return Values<br />
SQLRowCount 1-845
SQLSetConnectOption<br />
Syntax<br />
status = SQLSetConnectOption (connect.env, option, value)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLSetConnectOption controls some aspects of the connection to a data source.<br />
Parameters<br />
The following table describes each paramenter of the syntax.<br />
Parameter Description<br />
1-846 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
connect.env Connection environment returned from a previous SQLAllocConnect.<br />
SQLSetConnectOption Parameters
Options<br />
The following table describes the options available with SQLSetConnectOption.<br />
Option Description<br />
SQL.AUTO.COMMIT Determines the commit mode for transactions. When you use<br />
this option, the connection must already be established, and the<br />
SQL.PRIVATE.TX option must be set to<br />
SQL.PRIVATE.TX.ON. Valid settings are:<br />
SQL.AUTO.COMMIT.ON – Puts a private connection into<br />
autocommit mode.<br />
SQL.AUTO.COMMIT.OFF – Puts a private connection into<br />
manual commit mode.<br />
SQL.PRIVATE.TX Determines if a transaction is controlled by <strong>UniBasic</strong> or the data<br />
source. Valid settings are:<br />
SQL.PRIVATE.TX.ON – Transaction processing is controlled<br />
directly by the DBMS on the server.<br />
SQL.PRIVATE.TX.OFF – Transaction processing is fully<br />
managed by <strong>UniBasic</strong>.<br />
SQL.TXN.ISOLATION Determines the isolation level on the server. When you use this<br />
option, the connection must already be established, the<br />
SQL.PRIVATE.TX option must be set to<br />
SQL.PRIVATE.TX.ON, and no transactions may be active.Valid<br />
settings are:<br />
SQL.TXN.READ.UNCOMMITTED – Sets the isolation level<br />
on the server to 1.<br />
SQL.TXN.READ.COMMITTED – Sets the isolation level on<br />
the server to 2.<br />
SQL.TXN.REPEATABLE.READ – Sets the isolation level on<br />
the server to 3.<br />
SQL.TXN.SERIALIZABLE – Sets the isolation level on the<br />
server to 4.<br />
SQLSetConnectOption Options<br />
SQLSetConnectOption 1-847
Return Values<br />
The following table describes the return values for the<br />
SQLSetConnectOption.<br />
Private Transactions<br />
SQL.PRIVATE.TX.ON frees the connection from being managed by the UniData<br />
transaction manager. When you make a connection private, the application can use<br />
the SQL.AUTOCOMMIT option to put the connection into either autocommit mode<br />
or manual commit mode. By default, private connections are in autocommit mode, in<br />
which each SQL statement is treated as a separate transaction, committed after the<br />
statement is executed.<br />
In manual commit mode the application can do either of the following:<br />
1-848 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Value Description<br />
0 SQL.SUCCESS<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLSetConnectOption Return Values<br />
Use the SQLTransact function to commit or roll back changes to the<br />
database.<br />
Set the SQL.AUTOCOMMIT option of SQLSetConnectOption to<br />
SQL.AUTOCOMMIT.ON. This commits any outstanding transactions and<br />
returns the connection to autocommit mode.<br />
You must return the connection to autocommit mode before using SQLDisconnect<br />
to close the connection. You can do this in two ways:<br />
Set the SQL.AUTOCOMMIT option of SQLSetConnectOption to<br />
SQL.AUTOCOMMIT.ON<br />
Set the SQL.PRIVATE.TX option of SQLSetConnectOption to<br />
SQL.PRIVATE.TX.OFF
When a connection is private, SQL.TXN.ISOLATION lets the application define the<br />
default transaction isolation level at which to execute server operations. To determine<br />
what isolation levels the data source supports, use the<br />
SQL.TXN.ISOLATION.OPTION option of the SQLGetInfo function. This returns<br />
a bitmap of the options the data source supports. The application can then use the<br />
<strong>UniBasic</strong> BIT functions to determine whether a particular bit is set in the bitmap.<br />
Use SQLSetConnectOption with the SQL.TXN.ISOLATION option only in the<br />
following two places:<br />
Immediately following an SQLConnect function call<br />
Immediately following an SQLTransact call to commit or roll back an<br />
operation<br />
Whenever you execute an SQL statement, a new transaction exists, which makes<br />
setting the SQL.TXN.ISOLATION option illegal. If a transaction is active when the<br />
SQL.TXN.ISOLATION.OPTION is set, UniData BCI returns SQL.ERROR and sets<br />
SQLSTATE to S1C00.<br />
SQLSetConnectOption 1-849
SQLSetParam<br />
SQLSetParam is a synonym for SQLBindParameter.<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
1-850 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
SQLSpecialColumns<br />
Syntax<br />
status = SQLSpecialColumns (statement.env, col.type, schema, owner, tablename,<br />
IDscope, null)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLSpecialColumns gets information about columns in a table.<br />
SQLSpecialColumns lets applications scroll forward and backward in a result set to<br />
get the most recent data from a set of rows. Columns returned for column type<br />
SQL.BEST.ROWID are guaranteed not to change while positioned on that row.<br />
Columns of the row ID can remain valid even when the cursor is not positioned on<br />
the row. The application can determine this by checking the SCOPE column in the<br />
result set.<br />
Once the application gets values for SQL.BEST.ROWID, it can use these values to<br />
reselect that row within the defined scope. The SELECT statement is guaranteed to<br />
return either no rows or one row.<br />
Columns returned for SQL.BEST.ROWID can always be used in an SQL select<br />
expression or WHERE clause. However, SQLColumns does not necessarily return<br />
these columns. If no columns uniquely identify each row in the table, SQLSpecial-<br />
Columns returns a row set with no rows; a subsequent call to SQLFetch returns<br />
SQL.NO.DATA.FOUND.<br />
Columns returned for column type SQL.ROWVER let applications check if any<br />
columns in a given row have been updated while the row was reselected using the<br />
row ID.<br />
If col.type, IDscope, or null specifies characteristics not supported by the data source,<br />
SQLSpecialColumns returns a result set with no rows, and a subsequent call to<br />
SQLFetch returns SQL.NO.DATA.FOUND.<br />
SQLSpecialColumns 1-851
For complete details about the SQLSpecialColumns function, see the Microsoft<br />
ODBC 2.0 Programmer’s <strong>Reference</strong> and SDK Guide.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-852 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
statement.env SQL statement environment.<br />
col.type Type of column to return. col.type is one of the following:<br />
SQL.BEST.ROWID – Returns the best column or set of columns that<br />
uniquely identifies a row in a table.<br />
SQL.ROWVER – Returns the column or columns that are automatically<br />
updated when any value in the row is updated by a transaction.<br />
schema Qualifier name for tablename. If a driver supports qualifiers for some<br />
tables but not others, use an empty string for tables that do not have<br />
qualifiers.<br />
owner Name of the owner of the table. If a driver supports owners for some<br />
table but not others, use an empty string for tables that do not have<br />
owners.<br />
tablename Name of the table.<br />
IDscope Minimum required scope of the row ID. IDscope is one of the<br />
following:<br />
SQL.SCOPE.CURROW – Row ID is guaranteed to be valid only while<br />
positioned on that row.<br />
SQL.SCOPE.TRANSACTION – Row ID is guaranteed to be valid for<br />
the duration of the current transaction.<br />
SQL.SCOPE.SESSION – Row ID is guaranteed to be valid for the<br />
duration of the session.<br />
null Can be one of the following:<br />
SQL.NO.NULLS – Excludes special columns that can have null values.<br />
SQL.NULLABLE – Returns special columns even if they can have null<br />
values.<br />
SQLSpecialColumns Input Variables
Return Values<br />
The following table describes the return values of the SQLSpecialColumns<br />
function.<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
1 SQL.SUCCESS.WITH.INFO<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLSpecialColumns Return Values<br />
Results are returned as a standard result set ordered by SCOPE. The following table<br />
lists the columns in the result set. The lengths of VARCHAR columns are maximums;<br />
the actual lengths depend on the data source. To get the length of the<br />
COLUMN.NAME column, use the SQL.MAX.COLUMN.NAME.LEN option of<br />
the SQLGetInfo function.<br />
Column Name Data Type Description<br />
SCOPE Smallint Actual scope of the row ID. It contains<br />
one of the following:<br />
SQL.SCOPE.CURROW<br />
SQL.SCOPE.TRANSACTION<br />
SQL.SCOPE.SESSION<br />
The null value is returned when col.type<br />
is SQL.ROWVER.<br />
COLUMN.NAME Varchar(128)<br />
Not null<br />
DATA.TYPE Smallint<br />
Not null<br />
TYPE.NAME Varchar(128)<br />
Not null<br />
Column identifier.<br />
SQLSpecialColumns Results<br />
Either an ODBC SQL data type or a<br />
driver-specific SQL data type.<br />
Data-source-dependent data type name.<br />
SQLSpecialColumns 1-853
1-854 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Column Name Data Type Description<br />
PRECISION Integer Precision of the column on the data<br />
source. The null value is returned for<br />
data types where precision does not<br />
apply.<br />
LENGTH Integer The length in bytes of data transferred<br />
on an SQLGetData or SQLFetch if<br />
SQL.C.DEFAULT is specified. For<br />
numeric data, this size can differ from<br />
the size of the data stored on the data<br />
source. This value is the same as the<br />
PRECISION column for character or<br />
binary data.<br />
SCALE Smallint The scale of the column on the data<br />
source. The null value is returned for<br />
data types where scale does not apply.<br />
PSEUDO.COLUMN Smallint Indicates whether the column is a<br />
pseudo-column:<br />
SQL.PC.UNKNOWN<br />
SQL.PC.PSEUDO<br />
SQL.PC.NOT.PSEUDO<br />
Pseudo-columns should not be quoted<br />
with the identifier quote character<br />
returned by SQLGetInfo.<br />
SQLSpecialColumns Results (continued)
SQLStatistics<br />
Syntax<br />
status = SQLStatistics (statement.env, schema, owner, tablename, index.type,<br />
accuracy)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLStatistics gets a list of statistics about a single table and its indexes. Use this<br />
function only when you are connected to an ODBC data source.<br />
SQLStatistics returns information as a standard result set ordered by<br />
NON.UNIQUE, TYPE, INDEX.QUALIFIER, INDEX.NAME, and<br />
SEQ.IN.INDEX. The result set combines statistics for the table with statistics for<br />
each index.<br />
Note: SQLStatistics might not return all indexes. For example, a driver might return<br />
only the indexes in files in the current directory. Applications can use any valid index<br />
regardless of whether it is returned by SQLStatistics.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
statement.env SQL statement environment.<br />
schema Qualifier name for tablename. If a driver supports qualifiers for some<br />
tables but not others, use an empty string for tables that do not have<br />
qualifiers.<br />
owner Name of the owner of the table. If a driver supports owners for some table<br />
but not others, use an empty string for tables that do not have owners.<br />
SQLStatistics Parameters<br />
SQLStatistics 1-855
Parameter Description<br />
tablename Name of the table.<br />
index.type One of the following:<br />
SQL.INDEX.UNIQUE<br />
SQL.INDEX.ALL<br />
Return Values<br />
The following table describes the return values of the SQLStatistics function.<br />
1-856 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
accuracy The importance of the CARDINALITY and PAGES columns in the result<br />
set:<br />
SQL.ENSURE – The driver unconditionally gets the statistics.<br />
SQL.QUICK – The driver gets results only if they are readily available<br />
from the server. The driver does not ensure that the values are current.<br />
SQLStatistics Parameters<br />
Return Value Description<br />
0 SQL.SUCCESS<br />
1 SQL.SUCCESS.WITH.INFO<br />
−1 SQL.ERROR<br />
−2 SQL.INVALID.HANDLE<br />
SQLStatistics Return Values
The lengths of VARCHAR columns are maximums; the actual lengths depend on the<br />
data source. Use SQLGetInfo to determine the actual lengths of the<br />
TABLE.QUALIFIER, TABLE.OWNER, TABLE.NAME, and COLUMN.NAME<br />
columns.<br />
Column Name Data Type Description<br />
TABLE.QUALIFIER Varchar(128) Table qualifier identifier (schema) of the<br />
table. The null value is returned if it is not<br />
applicable to the data source. If a driver<br />
supports qualifiers for some tables but not<br />
others, it returns an empty string for tables<br />
without qualifiers.<br />
TABLE.OWNER Varchar(128) Name of the owner of the table. The null<br />
value is returned if it is not applicable to the<br />
data source. If a driver supports owners for<br />
some tables but not others, it returns an empty<br />
string for tables without owners.<br />
TABLE.NAME Varchar(128)<br />
Not null<br />
Name of the table.<br />
NON.UNIQUE Smallint The index prohibits duplicate values:<br />
TRUE if the index values can be nonunique.<br />
FALSE if the index values must be unique.<br />
NULL if TYPE is SQL.TABLE.STAT.<br />
INDEX.QUALIFIER Varchar(128) Index qualifier identifier used by the DROP<br />
INDEX statement. The null value is returned<br />
if the data source does not support index<br />
qualifiers or if TYPE is SQL.TABLE.STAT.<br />
If a nonnull value is returned, it must be used<br />
to qualify the index name in a DROP INDEX<br />
statement, otherwise the TABLE.OWNER<br />
name should be used to qualify the index<br />
name.<br />
INDEX.NAME Varchar(128) Name of the index. The null value is returned<br />
if TYPE is SQL.TABLE.STAT.<br />
SQLStatistics Results<br />
SQLStatistics 1-857
TYPE Smallint<br />
Not null<br />
1-858 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Column Name Data Type Description<br />
Type of information returned:<br />
SQL.TABLE.STAT indicates a statistic for<br />
the table.<br />
SQL.INDEX.CLUSTERED indicates a<br />
clustered index.<br />
SQL.INDEX.HASHED indicates a hashed<br />
index.<br />
SQL.INDEX.OTHER indicates another type<br />
of index.<br />
SEQ.IN.INDEX Smallint Column sequence number in index, starting<br />
with 1. The null value is returned if TYPE is<br />
SQL.TABLE.STAT.<br />
COLUMN.NAME Varchar(128) Name of a column. If the column is based on<br />
an expression, the expression is returned. If<br />
the expression cannot be determined, an<br />
empty string is returned. If the index is<br />
filtered, each column in the filter condition is<br />
returned (this may require more than one<br />
row). The null value is returned if TYPE is<br />
SQL.TABLE.STAT.<br />
COLLATION Char(1) Sort sequence for the column:<br />
A indicates ascending.<br />
B indicates descending.<br />
The null value is returned if the data source<br />
does not support column sort sequence.<br />
SQLStatistics Results (continued)
Column Name Data Type Description<br />
CARDINALITY Integer Number of rows in the table if TYPE is<br />
SQL.TABLE.STAT. Number of unique<br />
values in the index if TYPE is not<br />
SQL.TABLE.STAT. The null value is<br />
returned if the value is not available from the<br />
data source or if it is not applicable to the data<br />
source.<br />
PAGES Integer Number of pages for the table if TYPE is<br />
SQL.TABLE.STAT. Number of pages for the<br />
index if TYPE is not SQL.TABLE.STAT. The<br />
null value is returned if the value is not<br />
available from the data source or if it is not<br />
applicable to the data source.<br />
FILTER.CONDITION Varchar(128) If the index is filtered, the filter condition, or<br />
an empty string if the filter condition cannot<br />
be determined.<br />
The null value is returned if the index is not<br />
filtered, or if it cannot be determined that the<br />
index is filtered, or TYPE is<br />
SQL.TABLE.STAT.<br />
If the row in the result set corresponds to a table, the driver sets TYPE to<br />
SQL.TABLE.STAT and sets the following columns to NULL:<br />
NON.UNIQUE<br />
INDEX.QUALIFIER<br />
INDEX.NAME<br />
SEQ.IN.INDEX<br />
COLUMN.NAME<br />
COLLATION<br />
SQLStatistics Results (continued)<br />
If CARDINALITY or PAGES are not available from the data source, the driver sets<br />
them to NULL.<br />
For complete details about the SQLStatistics function, see the Microsoft ODBC 2.0<br />
Programmer’s <strong>Reference</strong> and SDK Guide.<br />
SQLStatistics 1-859
SQLTables<br />
Syntax<br />
status = SQLTables (statement.env, schema, owner, tablename, type)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLTables returns a result set listing the tables matching the search patterns. Use this<br />
function only when you are connected to an ODBC data source.<br />
This function returns statement.env as a standard result set of five columns containing<br />
the schemas, owners, names, types, and remarks for all tables found by the search.<br />
The search criteria arguments can contain a literal, an SQL LIKE pattern, or be<br />
empty. If a literal or LIKE pattern is specified, only values matching the pattern are<br />
returned. If a criterion is empty, tables with any value for that attribute are returned.<br />
owner cannot specify a LIKE pattern.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-860 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
statement.env SQL statement environment.<br />
schema Schema name search pattern.<br />
owner Table owner number search pattern.<br />
tablename Table name search pattern.<br />
type Table type (one of the following: BASE TABLE, VIEW,<br />
ASSOCIATION, or TABLE) search pattern.<br />
SQLTables Parameters
You can access the result set with SQLFetch. These five columns have the following<br />
descriptors:<br />
Special Search Criteria<br />
Three special search criteria combinations enable an application to enumerate the set<br />
of schemas, owners, and tables:<br />
Table<br />
Qualifier<br />
Column Name Data Type<br />
TABLE.SCHEMA VARCHAR(128)<br />
TABLE.OWNER VARCHAR(128)<br />
TABLE.NAME VARCHAR(128)<br />
TABLE.TYPE VARCHAR(128)<br />
REMARKS VARCHAR(254)<br />
SQL Tables Results<br />
Table<br />
Owner Table Name Table Type Return Is ...<br />
% empty string empty string ignored Set of distinct<br />
schema names<br />
empty string empty string ignored Set of distinct table<br />
owners<br />
empty string empty string empty string % Set of distinct table<br />
types<br />
Special Search Criteria for Enumerating the Set of Schemas, Owners, and<br />
Tables<br />
The ability to obtain information about tables does not imply that you have any privileges<br />
on those tables.<br />
SQLTables 1-861
Return Values<br />
The following table describes the return values of the SQLTables function.<br />
SQLSTATE Values<br />
The following table describes the SQLSTATE values.<br />
SQLSTAT<br />
E Description<br />
1-862 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Value Description<br />
0 SQL.SUCCESS<br />
1 SQL.SUCCESS.WITH.INFO<br />
–1 SQL.ERROR<br />
–2 SQL.INVALID.HANDLE<br />
SQLTables Return Values<br />
S1000 General error for which no specific SQLSTATE code has been defined.<br />
S1001 Memory allocation failure.<br />
S1008 Cancelled. Execution of the statement was stopped by an SQLCancel call.<br />
S1010 Function sequence error. The statement.env specified is currently executing<br />
an SQL statement.<br />
S1C00 The table owner field was not numeric.<br />
24000 Invalid cursor state. Results are still pending from the previous SQL<br />
statement. Use SQLCancel to clear the results.<br />
42000 Syntax error or access violation. This can be caused by a variety of reasons.<br />
The native error code returned by the SQLError call indicates the specific<br />
error that occurred.<br />
SQLSTATE Values
SQLTransact<br />
Syntax<br />
status = SQLTransact (bci.env, connect.env, type)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
SQLTransact requests a COMMIT or ROLLBACK for all SQL statements<br />
associated with a connection or all connections associated with an environment. Use<br />
this function only when you are connected to an ODBC data source.<br />
This function provides the same transaction functions as the <strong>UniBasic</strong> statement<br />
TRANSACTION COMMIT. When connect.env is a valid connection environment<br />
with SQL.AUTOCOMMIT set to OFF, SQLTransact commits the connection.<br />
To use SQLTransact, all of the following conditions must be met:<br />
The SQL.PRIVATE.TX option of SQLSetConnectOption is set to<br />
SQL.PRIVATE.TX.ON.<br />
The SQL.AUTOCOMMIT option is set to SQL.AUTOCOMMIT.OFF.<br />
The connection is active.<br />
Setting bci.env to a valid environment handle and connect.env to SQL.NULL.HDBC<br />
requests the server to try to execute the requested action on all hdbcs that are in a<br />
connected state.<br />
If any action fails, SQL.ERROR is returned, and the user can determine which<br />
connections failed by calling SQLError for each connection environment in turn.<br />
If you call SQLTransact with a type of SQL.COMMIT or SQL.ROLLBACK when<br />
no transaction is active, SQL.SUCCESS is returned.<br />
SQLTransact 1-863
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Return Values<br />
The following table describes the return values of the SQLTransact function.<br />
1-864 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
bci.env UniData BCI environment.<br />
connect.env Connection environment or SQL.NULL.HDBC.<br />
type One of the following:<br />
SQL.COMMIT – Writes all modified data to the data source, releases all<br />
lock acquired by the current transaction, and terminates the transaction.<br />
SQL.ROLLBACK – Discards any changes written during the transaction<br />
and terminates it.<br />
SQLTransact Input Variables<br />
Return<br />
Value Description<br />
0 SQL.SUCCESS<br />
–1 SQL.ERROR<br />
–2 SQL.INVALID.HANDLE<br />
SQLTransact Return Values
SQLSTATE Values<br />
The following table describes the SQLSTATE values for the SQLTransact function.<br />
SQLSTAT<br />
E Description<br />
S1000 General error for which no specific SQLSTATE code has been defined.<br />
S1001 Memory allocation failure.<br />
S1012 type did not contain SQL.COMMIT or SQL.ROLLBACK.<br />
08003 No connection is active on connect.env.<br />
08007 The connection associated with the transaction failed during the execution of<br />
the function. It cannot be determined if the requested operation completed<br />
before the failure.<br />
SQLSTATE Values<br />
SQLTransact 1-865
SQRT<br />
Syntax<br />
SQRT(num.expr)<br />
Description<br />
The <strong>UniBasic</strong> SQRT function returns the square root of a positive numeric argument.<br />
Example<br />
In the following example, the program statement prints SQUARE ROOT OF 16 IS 4:<br />
1-866 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
PRINT "SQUARE ROOT OF 16 IS ":SQRT(16)
SQUOTE<br />
Syntax<br />
SQUOTE(str.expr)<br />
Description<br />
The <strong>UniBasic</strong> SQUOTE function encloses a string with single quotation marks.<br />
Examples<br />
In the following example, the program statement prints ‘This is ‘a’ test’ on the screen:<br />
PRINT SQUOTE("This is 'a' test")<br />
In the next example, the program segment prints ‘This is another test’ on the screen:<br />
X = "This is another test"<br />
PRINT SQUOTE(X)<br />
Related Command<br />
<strong>UniBasic</strong><br />
QUOTE<br />
SQUOTE 1-867
SSUB<br />
Syntax<br />
SSUB(x, y)<br />
Description<br />
The <strong>UniBasic</strong> SSUB function subtracts the second string number from the first string<br />
number and returns the result as a string number. Arguments can be any valid<br />
numbers or string numbers of any magnitude or precision.<br />
Tip: Processing string data type numbers rather than numeric data type numbers<br />
degrades processing speed. Numbers specified in quotation marks are string data<br />
type. Numbers specified without quotation marks are numeric data type. The data<br />
type of a variable is determined by the data first loaded into it.<br />
If x or y contains nonnumeric data, UniData displays an error message and returns a<br />
result of 0.<br />
The SSUB function results in a string number, so you can use the function in any<br />
expression in which a string number is valid. Because string numbers can exceed the<br />
range of numbers that standard arithmetic operators can accommodate, you might not<br />
want to use the SSUB function in any expression in which a standard number is valid.<br />
Example<br />
In the following example, the program statement assigns to B the result of subtracting<br />
1.4149 from A, and then prints the answer 98.5851:<br />
A = 100<br />
B = SSUB(A, "1.4149")<br />
PRINT B<br />
1-868 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
STATUS<br />
Syntax<br />
STATUS( )<br />
Description<br />
The <strong>UniBasic</strong> STATUS function returns a code indicating the condition of the<br />
command or function just executed.<br />
Several <strong>UniBasic</strong> commands and functions set STATUS function return values. For<br />
information about the return values set by a particular command or function, see<br />
Appendix F, “<strong>Commands</strong> That Set STATUS() Return Values.”<br />
Example<br />
In the following example, the STATUS function returns a value of 0, indicating a<br />
successful conversion of a valid date by OCONV. STATUS would return 1 if 7334<br />
were an invalid input date or 2 if D were an invalid conversion specification.<br />
PRINT OCONV(7334,"D")<br />
PRINT STATUS()<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
SYSTEM<br />
@variables – For information, see Appendix B, “<strong>UniBasic</strong>@variables.”<br />
STATUS 1-869
STOP<br />
Syntax<br />
STOP [expr]<br />
Description<br />
The <strong>UniBasic</strong> STOP command halts execution of the current program. If you specify<br />
an expression, UniData prints the expression on the display terminal before halting<br />
the program. expr can contain variables, functions, and arithmetic or string operators.<br />
STOP returns the cursor to the UniData prompt, a calling menu, or a calling<br />
paragraph, depending on how the program was executed.<br />
Tip: The ABORT command returns the cursor to UniData level regardless of what<br />
process initiated the program.<br />
Note: The STOP command performs differently with BASICTYPE P. The following<br />
syntax is valid in BASICTYPE P:<br />
STOP [message-id]<br />
STOP [expr,...]<br />
message-id must evaluate to a key contained in UniData error message file ERRMSG.<br />
expr can contain variables, functions, and arithmetic or string operators.<br />
Examples<br />
In the following example, the program segment attempts to read a record from a file.<br />
If the record does not exist, the program aborts and prints the message RECORD IS<br />
MISSING at line 10, column 10 on the terminal.<br />
1-870 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
CUST.ID = 1234<br />
OPEN 'CLIENTS' READONLY TO CLIENT.FILE ELSE STOP "Cannot Open"<br />
READ REC FROM CLIENTR, CLIENT.ID ELSE<br />
STOP @(10,10):'RECORD IS MISSING'<br />
END
In the next example, the segment prints a prompt if an error flag ERR.FLAG has been<br />
set, and reads the user’s input into the variable ANS. If ANS equals Y, the program<br />
stops.<br />
ERR.FLAG = 1<br />
IF ERR.FLAG THEN<br />
PRINT "STOP PROGRAM?"<br />
INPUT ANS<br />
IF ANS = "Y" THEN STOP<br />
END<br />
In the next example, in BASICTYPE P, the program segment prints an error message<br />
from record 10075 in the ERRMSG file if the program aborts:<br />
If A < 0 THEN ABORT 10075<br />
Related Command<br />
<strong>UniBasic</strong><br />
ABORT<br />
STOP 1-871
STR<br />
Syntax<br />
STR(str.expr, num.expr)<br />
Description<br />
The <strong>UniBasic</strong> STR function returns a string composed of a number of repetitions of<br />
a string.<br />
Null Value Handling<br />
If a function encounters the null value in a parameter when a number is expected<br />
(num.expr), a warning message displays, and <strong>UniBasic</strong> uses 0.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Example<br />
In the following example, the program statement prints a string of 25 hyphens on the<br />
terminal screen:<br />
PRINT STR("-",25)<br />
1-872 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
str.expr Specifies a string expression to concatenate num.expr times.<br />
num.expr Specifies the number of repetitions of the string expression to concatenate.<br />
STR Parameters
Related Command<br />
<strong>UniBasic</strong><br />
STRS<br />
STR 1-873
STRS<br />
Syntax<br />
STRS(dyn.array, expr)<br />
Description<br />
The <strong>UniBasic</strong> STRS function returns each element of dyn.array the number of times<br />
specified in expr.<br />
Null Value Handling<br />
If a function encounters the null value in a parameter when a number is expected<br />
(expr), a warning message displays, and <strong>UniBasic</strong> uses 0.<br />
Example<br />
In the following example, the program segment prints the each element of the ARR1<br />
dynamic array 10 times:<br />
1-874 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ARR1 = 1:@AM:2:@AM:3:@AM:4:@AM:5<br />
ARR2 = STRS(ARR1,10)<br />
PRINT ARR2<br />
This results in the following:<br />
1111111111}2222222222}3333333333}4444444444}5555555555<br />
Related Command<br />
<strong>UniBasic</strong><br />
STR
submitRequest<br />
Syntax<br />
submitRequest(request_handle, time_out, post_data, response_headers,<br />
response_data, http_status)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The submitRequest function submits a request and gets a response.<br />
The request is formed on the basis of default HTTP settings and previous setRequestHeader()<br />
and addRequestParameter() values. Specifically, for a GET<br />
method with parameters added, <strong>UniBasic</strong> creates a parameter string (properly<br />
encoded) and attaches to the URL string after the ‘?’ character.<br />
For a POST request with non-empty post_data, the data is attached to the request<br />
message as is. No encoding is performed, and any parameters added through addRequestParameter()<br />
will be totally ignored. Otherwise the following processing will<br />
be performed.<br />
For a POST request with default content type, the parameter string will be assembled,<br />
a Content-Length header created, and then the string is attached as the last part of the<br />
request message.<br />
For a POST request with multipart/* content type, a unique boundary string is created<br />
and then multiple parts will be generated in the sequence they were added through<br />
calling addRequestParameter(). Each will have a unique boundary, followed by<br />
optional Content-* headers, and data part. The total length is calculated and a<br />
Content-Length header is added to the message header.<br />
The request is then sent to the Web server identified by the URL supplied with the<br />
request and created through createRequest() (maybe through a proxy server).<br />
<strong>UniBasic</strong> is then waiting for the web server to respond. Once the response message<br />
is received, the status contained in the response is analyzed.<br />
submitRequest 1-875
If the response status indicates that redirection is needed (status 301, 302, 305 or<br />
307), it will be performed automatically, up to five consecutive redirections (the limit<br />
is set to prevent looping, suggested by RFC 2616).<br />
If the response status is 401 or 407 (access denied), the response headers will be<br />
examined to see if the server requires (or accepts) Basic authentication. If no Basic<br />
authentication request is found, the function will return with an error. Otherwise<br />
default Authentication (set by setHTTPDefault) will be used to resend the request.<br />
If no default authentication is set, and no other cached user authentication is found,<br />
the function will return with an error.<br />
If the user provides authentication information through “Authorization” or “Proxy-<br />
Authorization” header, the encoded information is cached. If later, a Basic authentication<br />
request is raised, no default authentication is found, and only one<br />
user/password encoding is cached, then it will be used to resend the request.<br />
The response from the HTTP server is disposed into response_header and<br />
response_data. It is the user’s responsibility to parse the headers and data. <strong>UniBasic</strong><br />
only performs transfer encoding (chunked encoding), and nothing else is done on the<br />
data. In other words, content-encoding (gzip, compress, deflate, and so forth) are<br />
supposed to be handled by the user, as with all MIME types.<br />
Also, if a response contains header “Content-type: multipart/*”, all the data (multiple<br />
bodies enclosed in “boundary delimiters”, see RFC 2046) will be stored in<br />
response_data. It is the user’s responsibility to parse it according to “boundary”<br />
parameter.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-876 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
request_handle The handle to the request.<br />
time_out The timeout value (in milliseconds) before the wait response is<br />
abandoned.<br />
post_data The data sent with the POST request.<br />
submitRequest Parameters
Parameter Description<br />
response_headers A dynamic array to stre header/value pairs.<br />
response_data The resultant data (may be in binary format).<br />
http_status A dynamic array containing the status code and explanatory text.<br />
submitRequest Parameters<br />
The following table describes the status of each return code.<br />
Return Code Status<br />
0 Success.<br />
1 Invalid request handle.<br />
2 Timed out.<br />
3 Network Error.<br />
4 Other Errors.<br />
Return Code Status<br />
submitRequest 1-877
SUBROUTINE<br />
Syntax<br />
SUBROUTINE sub.name[(argument1 [, argument2] ...)]<br />
Description<br />
The <strong>UniBasic</strong> SUBROUTINE command determines the beginning of an external<br />
subroutine.<br />
The SUBROUTINE statement must be the first noncomment line in a subroutine.<br />
You can specify arguments to pass data between the main program and the<br />
subroutine. If you pass arguments, the number of arguments in the CALL statement<br />
and the SUBROUTINE statement must match, although variable names do not need<br />
to be the same. Changes made to arguments in the subroutine retain their new values<br />
when UniData exits the subroutine and control reverts to the calling program.<br />
When calling a subroutine from UniData ODBC, the subroutine name cannot contain<br />
any special characters.<br />
Note: All subroutines must be cataloged using the ECL CATALOG command before<br />
being called. For more information about the CATALOG command, see the UniData<br />
<strong>Commands</strong> <strong>Reference</strong>.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
1-878 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Parameter Description<br />
sub.name Specifies the subroutine name.<br />
(argument1 ,argument2 ...) Specifies arguments to pass to the subroutine. The<br />
arguments can be simple variables, dynamic arrays, or<br />
dimensioned arrays.<br />
SUBROUTINE Parameters
Examples<br />
In the following example, the main program prompts the user for two numbers. These<br />
are sent to the subroutine COMP, together with an empty variable C. The subroutine,<br />
COMP, renames the passed arguments, calculates their average, and returns the result<br />
in the third variable.<br />
This is the main program:<br />
REM Main program<br />
PRINT "Enter A,B:":; INPUT A; INPUT B<br />
CALL COMP(A,B,C)<br />
PRINT "Average = ":C<br />
STOP<br />
This is the subroutine:<br />
REM Calculates average of two numbers<br />
SUBROUTINE COMP(X,Y,Z)<br />
Z = (X+Y)/2<br />
RETURN<br />
END<br />
The sample program in Appendix A, “Sample Program,” in Developing <strong>UniBasic</strong><br />
Applications includes the following subroutine, which is called by the main program<br />
to display messages on the screen:<br />
SUBROUTINE DISPLAY_MESSAGE(MESSAGE)<br />
DISPLAY @(5,20):MESSAGE<br />
DISPLAY @(5,21):"Press the (Return) key.":<br />
INPUT PAUSE,1_<br />
RETURN<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CALL, PROGRAM, SUBROUTINE (Update Trigger), SUBROUTINE (Delete<br />
Trigger)<br />
UniData<br />
BASIC, CATALOG – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
SUBROUTINE 1-879
SUBROUTINE (Update Trigger)<br />
Syntax<br />
SUBROUTINE trigname(execstat, dictflag, filename, record.ID.expr, recordval)<br />
FUNCTION trigname(dictflag, filename, record.ID.expr, recordval)<br />
Description<br />
Triggers enforce user-defined constraints that must be met before data can be<br />
updated. The trigger is associated with the data file, so it verifies any access to the<br />
data. A <strong>UniBasic</strong> trigger subroutine or function serves as an UPDATE trigger. The<br />
SUBROUTINE or FUNCTION definition must be the first line in the <strong>UniBasic</strong><br />
trigger.<br />
You must include a RETURN statement in the function:<br />
RETURN [execstat]<br />
Points to Remember<br />
1-880 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
When you attempt to update a record, UniData calls the trigger, passing the<br />
file name, DICT if dictionary file, record ID, and the input value before<br />
updating the record. The subroutine returns the execution status and the new<br />
record value.<br />
If the update request fails, the subroutine must return an execstat value of 0.<br />
If the request passes, the return value must be 1.<br />
Tip: You can call a C routine from the <strong>UniBasic</strong> subroutine or function that is called<br />
from a trigger.
Parameters<br />
The following table describes each parameter of the syntax.<br />
Paragraph Description<br />
trigname Name of the globally cataloged subroutine.<br />
execstat Execution status returned by the trigger subroutine:<br />
0 – No updates allowed.<br />
1 – Update is allowed.<br />
2 – Update is allowed; uses the return recordval.<br />
dictflag “DICT” – Indicates that the trigger is operating on the dictionary file.<br />
“” – Indicates that the trigger is operating on the data file.<br />
The quotation marks are required.<br />
filename The name of the file on which the trigger is operating.<br />
record.ID.expr The record to be updated.<br />
recordval The input record value submitted to the UPDATE trigger. recordval is<br />
both an input and output parameter. The trigger can change this value<br />
(for example, by performing a conversion). Then, if the trigger sets<br />
execstat to 2, this value is passed back in recordval and updates the data<br />
record. Only strings and numbers are valid.<br />
If the value returned in recordval is invalid, the record is not updated,<br />
even if the trigger subroutine sets execstat to 2. In this case, the<br />
<strong>UniBasic</strong> STATUS function returns 3 when executed immediately after<br />
the command that calls the trigger. Only strings and numbers are valid.<br />
SUBROUTINE Update Trigger Parameters<br />
STATUS Function Return Values<br />
After you execute a trigger subroutine, the STATUS function returns one of the<br />
values described in the following table.<br />
SUBROUTINE (Update Trigger) 1-881
Tip: The <strong>UniBasic</strong> STATUS function returns the status of the preceding command.<br />
You can place it within the trigger subroutine to learn about the status of individual<br />
commands executed within the trigger. If you place it immediately after the statement<br />
that calls the trigger, it returns the status of the <strong>UniBasic</strong> command as determined by<br />
the trigger. The trigger subroutine also returns a value indicating its status in the<br />
parameter execstat. These values returned in execstat are listed in the Parameters<br />
section.<br />
Return<br />
Value Description<br />
0 No error.<br />
Examples<br />
The following example begins with an UPDATE trigger subroutine called TRIG1.<br />
Because the return status is always 0, no record in the file can be updated.<br />
1-882 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
1 System error, such as a damaged file.<br />
2 Constraint violation. In this case, the <strong>UniBasic</strong> trigger subroutine returns a<br />
value of 0 in the parameter execstat, indicating that the update or delete is not<br />
allowed.<br />
3 Trigger execution error or unexpected return from trigger routine (for<br />
example, the trigger subroutine is not cataloged).<br />
STATUS Function Return Values<br />
SUBROUTINE<br />
TRIG1(exec.stat,dict.flag,trig.name,rec.id.expr,rec.val)<br />
exec.stat=0<br />
RETURN<br />
Next, we create the trigger, associate it with the ORDERS file, and list the triggers<br />
associated with the ORDERS file:<br />
:CREATE.TRIGGER ORDERS TRIG1 UPDATE<br />
:LIST.TRIGGER ORDERS<br />
BEFORE UPDATE TRIGGER: TRIG1<br />
BEFORE DELETE TRIGGER: not defined
Finally, we attempt to copy record 969 into record 970 in the ORDERS file, and the<br />
trigger prevents the copy:<br />
:COPY FROM ORDERS TO ORDERS 969,970<br />
Cannot update 970, due to trigger constraint.<br />
0 records copied<br />
SUBROUTINE (Update Trigger) 1-883
SUBROUTINE (Delete Trigger)<br />
Syntax<br />
SUBROUTINE trigname(execstat, dictflag, filename, record.ID.expr)<br />
FUNCTION trigname(dictflag, filename, record.ID.expr)<br />
Description<br />
A <strong>UniBasic</strong> subroutine or function serves as the DELETE trigger that is executed<br />
when you attempt to delete a record in the subject file. The SUBROUTINE or<br />
FUNCTION definition must be the first line in the <strong>UniBasic</strong> trigger subroutine.<br />
You must include a RETURN statement in the function:<br />
RETURN [execstat]<br />
Points to Remember<br />
Remember the following items when writing a subroutine that is triggered by a user<br />
attempting to delete a record:<br />
1-884 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
When you attempt to delete a record, UniData calls the trigger, passing the<br />
file name, DICT if dictionary file, record ID, and the input value before<br />
deleting the record. The subroutine returns the execution status.<br />
If the delete request fails the constraint, the subroutine must return a status<br />
of 0. If the request passes, the return must be 1.<br />
Tip: You can call a C routine from the <strong>UniBasic</strong> subroutine or function that is called<br />
from a trigger.
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
trigname Name of the globally cataloged subroutine.<br />
execstat Execution status returned by the trigger subroutine. Valid values for this<br />
include:<br />
0 – Delete is not allowed.<br />
1 – Delete is allowed.<br />
dictflag “DICT” – Indicates that the trigger is operating on the dictionary file.<br />
“” – Indicates that the trigger is operating on the data file.<br />
The quotation marks are required.<br />
filename Name of the file the trigger is operating on.<br />
record.ID.expr Record to be deleted.<br />
SUBROUTINE Delete Trigger Parameters<br />
STATUS Function Return Values<br />
After you execute a trigger subroutine, the STATUS function returns one of the<br />
values described in the following table.<br />
SUBROUTINE (Delete Trigger) 1-885
Tip: The <strong>UniBasic</strong> STATUS function returns the status of the preceding command.<br />
You can place it within the trigger subroutine to learn about the status of individual<br />
commands executed within the trigger. If you place it immediately after the statement<br />
that calls the trigger, it returns the status of the <strong>UniBasic</strong> command as determined by<br />
the trigger. The trigger subroutine also returns a value indicating its status in the<br />
parameter execstat. These values returned in execstat are listed in the “Parameters”<br />
section.<br />
Return Value Description<br />
0 No error.<br />
Example<br />
The following example begins with a DELETE trigger subroutine called DEL_TRIG.<br />
This subroutine always returns 1 and always allows records to be deleted:<br />
1-886 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
1 System error, such as a damaged file.<br />
2 Constraint violation. In this case, the <strong>UniBasic</strong> trigger subroutine<br />
returns a value of 0 in the parameter execstat, indicating that the update<br />
or delete is not allowed.<br />
3 Trigger execution error or unexpected return from trigger routine (for<br />
example, the trigger subroutine is not cataloged).<br />
STATUS Function Return Values<br />
SUBROUTINE<br />
DEL_TRIG(exec.stat,dict.flag,trig.name,rec.id.expr,rec.val)<br />
exec.stat=1<br />
RETURN<br />
Note: After creating and compiling the subroutine, you must catalog it globally.<br />
Next, we create the trigger and associate it with the ORDERS file:<br />
:CREATE.TRIGGER ORDERS DEL_TRIG DELETE<br />
Finally, we delete records in the ORDERS file. The trigger always allows the deletion<br />
because the subroutine sets the execution status to 1.<br />
:DELETE ORDERS 912<br />
'912' deleted.<br />
:
SUBSTRINGS<br />
Syntax<br />
SUBSTRINGS(dyn.array, num.expr1, num.expr2)<br />
Description<br />
The <strong>UniBasic</strong> SUBSTRINGS function extracts strings from elements within a<br />
dynamic array. SUBSTRINGS supports multibyte languages.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dyn.array Specifies the dynamic array from which to extract the substring.<br />
num.expr1 Specifies a starting position for the extraction operation.<br />
num.expr2 Specifies the number of characters to return.<br />
SUBSTRINGS Parameters<br />
Example<br />
In the following example, the program segment extracts the first character of each<br />
element of the dynamic array LASTNAMES. This results in S}J}J}H.<br />
LASTNAMES = "Smith":@AM:"Jones":@AM:"Johnson":@AM:"Howard"<br />
LINITIAL = SUBSTRINGS(LASTNAMES,1,1)<br />
PRINT LINITIAL<br />
SUBSTRINGS 1-887
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DEL, INSERT, REMOVE, REPLACE<br />
1-888 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
SUM<br />
Syntax<br />
SUM(dyn.array [, ] [, start.expr [, stop.expr]])<br />
Description<br />
The <strong>UniBasic</strong> SUM function adds the numeric values in the dynamic array dyn.array<br />
according to dynamic array delimiters. SUM begins with the lowest level of delimiter<br />
and sums all values to the next level. You can input a range, starting position, and<br />
level at which to perform the sum.<br />
Note: The SUM function can contain a maximum of 1621 characters.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dyn.array Specifies a dynamic array of numeric values to sum.<br />
, , start.expr<br />
, stop.expr<br />
Specifies a range within the dynamic array to sum. The range is<br />
specified as an attribute, a value, a starting point, and a stopping<br />
point.<br />
SUM Parameters<br />
Tip: To sum all elements in an array, execute SUM twice. The first execution sums<br />
each group of subvalues and returns a string of numeric values; the second SUM<br />
returns a single value.<br />
SUM 1-889
Examples<br />
In the following example, the program segment begins with an array of two values,<br />
each with two subvalues. The SUM function sums the subvalues and returns a string<br />
with two numeric values.<br />
1-890 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
NUM.ARRAY = 12:@SM:10:@VM:15:@SM:15<br />
VAL1 = SUM(NUM.ARRAY)<br />
This results in:<br />
VAL1 = 22:@VM:30<br />
In the next example, the program statement sums VAL1 and returns the numeric<br />
value 52 with no dynamic array delimiters:<br />
VAL1 = SUM(VAL1)
SWAP<br />
Syntax<br />
SWAP str.expr1 WITH str.expr2 IN var<br />
Description<br />
The <strong>UniBasic</strong> SWAP command replaces all occurrences of one substring with a<br />
second substring. The search string does not have to be the same length as the<br />
replacement string. SWAP supports mulitbyte languages.<br />
Tip: CONVERT compares and replaces substrings on a character-by-character<br />
basis. CONVERT cannot exchange strings of different lengths.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
str.expr1 Specifies the string expression to replace with str.expr2.<br />
str.expr2 Specifies the string expression with which to replace str.expr1.<br />
IN var Specifies the variable in which to replace str.expr1 with str.expr2.<br />
SWAP Parameters<br />
Examples<br />
In the following example, the program segment replaces all occurrences of the string<br />
“AB” with the string “AZ” in the variable VAR. The new string assigned to VAR is<br />
“THE TAZ WAS GRAZBED”.<br />
VAR = "THE TAB WAS GRABBED"<br />
SWAP "AB" WITH "AZ" IN VAR<br />
SWAP 1-891
In the next example, SWAP does not replace a character with a character, but it<br />
replaces a string with a string. The program segment prints HARRY BELAFONTE.<br />
1-892 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
STRING = 'MARION BELAFONTE'<br />
SWAP 'MARION' WITH 'HARRY' IN STRING<br />
PRINT STRING<br />
The following program first creates a string that contains the null value, then calls a<br />
subroutine that converts UniData delimiters and the null value to characters that can<br />
be displayed or printed. Next, the program swaps the null value for another string<br />
(“def”), calls the conversion subroutine again, and prints the string again.<br />
A = @AM:"abc":@VM:@NULL:@VM:"ghi":@AM:"jkl"<br />
B = A<br />
CALL null.swap(B)<br />
PRINT B<br />
SWAP @NULL WITH "def" IN A<br />
B = A<br />
CALL null.swap(B)<br />
PRINT B<br />
The called subroutine is:<br />
SUBROUTINE null.swap(B)<br />
SWAP @NULL WITH "null" IN B<br />
SWAP @AM WITH " " IN B<br />
SWAP @VM WITH " " IN B<br />
SWAP @SM WITH " " IN B<br />
RETURN<br />
This program prints:<br />
:RUN BP null.swap.test<br />
abc null ghi jkl<br />
abc def ghi jkl<br />
Related Command<br />
<strong>UniBasic</strong><br />
CONVERT
SYSTEM<br />
Syntax<br />
SYSTEM(expr)<br />
Description<br />
The <strong>UniBasic</strong> SYSTEM function retrieves certain system-level parameters set by<br />
<strong>UniBasic</strong> statements or by ECL commands such as SETPTR, TERM, and query<br />
statements.<br />
Note: The SYSTEM function is similar to the STATUS function and several of the<br />
@variables featured in Appendix B, “<strong>UniBasic</strong>@variables.” The SYSTEM and<br />
STATUS functions return the same values after execution of <strong>UniBasic</strong> commands and<br />
functions.<br />
Parameters<br />
expr must be a number from 0 through 16. If you specify 0, the value of SYSTEM is<br />
determined by a previously executed <strong>UniBasic</strong> command. If you specify a number<br />
from 1 through 16, UniData returns predefined system parameters as described in the<br />
following table. <strong>UniBasic</strong> returns the original value when expr is invalid.<br />
Parameter Description<br />
1 1 – PRINTER ON or (P) option is specified. Output is printed on the system<br />
printer.<br />
0 – Output is printed to the terminal.<br />
2 Current terminal or page size (width).<br />
3 Current terminal or page length (number of lines on page).<br />
4 Number of lines remaining on current page.<br />
5 Current printer page number.<br />
SYSTEM Parameters<br />
SYSTEM 1-893
Parameter Description<br />
1-894 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
6 Current number of lines printed on the terminal or printer page.<br />
7 Terminal type.<br />
8 Current tape block size.<br />
9 Current CPU millisecond count from the start of the program.<br />
10 1 – The current stack (STON) condition is enabled.<br />
0 – Current stack is inactive.<br />
11 n – A SELECT list is active. n = # of items selected.<br />
0 – No SELECT list is active.<br />
12 Current time in milliseconds (local time).<br />
13 Sleeps one second.<br />
14 Number of characters in the type-ahead buffer. If the number of characters<br />
in the internal buffer exceeds 511 bytes, this parameter returns 511.<br />
15 Returns command options as a character string.<br />
16 Run level, same as @LEVEL.<br />
17 Indicates where UniData transfers control of a <strong>UniBasic</strong> program when the<br />
next RETURN statement executes.<br />
0 – Program has no called subroutine or internal subroutine GOSUB to<br />
return to.<br />
1 – Returning from a CALL.<br />
2 – Returning from a GOSUB.<br />
18-29 Not currently used.<br />
30 Shows the level to which the interrupt key is set. If the value is 0, the<br />
interrupt key is enabled. For all other values, the interrupt key is disabled.<br />
To enable the interrupt key, you must match the number of BREAK OFF<br />
statements in a program with an equal number of BREAK ON statements<br />
to bring the value of SYSTEM(30) to 0.<br />
31 Returns the value of $UDTHOME.<br />
32 Returns current BASICTYPE.<br />
SYSTEM Parameters (continued)
Parameter Description<br />
33 Returns the implementation of UniData that is currently running, such as<br />
UNIX or a Windows platform.<br />
34 Not currently used.<br />
35 The language.<br />
36 Shows the current setting for DATE.FORMAT:<br />
0 – Date format is MM/DD/YY.<br />
1 – Date format is DD/MM/YY.<br />
37 The character used to separate thousands.<br />
38 The character used as the decimal point.<br />
39 The character used for the dollar sign.<br />
40 Returns the name of the program being run.<br />
41 Returns the UniData product serial number.<br />
42 Returns the ASCII value of @RM.<br />
43 Returns the ASCII value of the print control character. (Default print<br />
control character is 192.)<br />
44 Returns the ASCII value of @NULL.<br />
45 Returns the version, including patch number, of UniData currently running.<br />
If it is different from the version number stored in the VOC file, an asterisk<br />
is appended to the version number.<br />
The operating system-level updatevoc command updates the VOC file from<br />
the latest installation or patch.<br />
48 Returns the name of the COMO file automatically created by a PHANTOM<br />
process. This function is available to the process the PHANTOM process<br />
spawned, not to the parent process.<br />
49 Returns the calling stack for the <strong>UniBasic</strong> program at runtime. The calling<br />
stack is stored in a dynamic array with each line represented as a separate<br />
field. Each field is separated into three values (the sequence number, the<br />
object name, and the line number), and the values are separated by value<br />
marks.<br />
SYSTEM Parameters (continued)<br />
SYSTEM 1-895
Parameter Description<br />
1-896 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
50 The <strong>UniBasic</strong> SYSTEM(50) function returns a list of files open in <strong>UniBasic</strong><br />
as a dynamic array. The first field is multivalued, and contains the following<br />
information:<br />
Value 1 – The maximum number of files that can be opened system-wide.<br />
Value 2 – The current number of hashed files open in <strong>UniBasic</strong>.<br />
Value 3 – The current number of dynamic hashed files open in <strong>UniBasic</strong>.<br />
Value 4 – The current number of recoverable hashed files open in <strong>UniBasic</strong>.<br />
Value 5 – The current number of sequential and OS-level files open in<br />
<strong>UniBasic</strong>.<br />
Value 6 – The current number of index files open in <strong>UniBasic</strong>.<br />
Value 7 – The current number of temporarily closed files in <strong>UniBasic</strong>.<br />
51 Returns information about device licensing. If you are not using device<br />
licensing, SYSTEM(51) returns a null string.<br />
52 Returns the entire command stack for the <strong>UniBasic</strong> program at runtime. The<br />
command stack is stored in a dynamic array. <strong>Commands</strong> are separated by<br />
attribute marks (@FM).<br />
512<br />
(Windows<br />
platforms<br />
only)<br />
In a UDTelnet session, returns the IP address. In a console session, returns<br />
the word “Console”.<br />
513 Returns the current UniData version and build number.<br />
514 Returns the number of UniData users currently logged in. SYSTEM(514)<br />
does not include phantoms.<br />
515<br />
(Windows<br />
NT or<br />
Windows<br />
2000 only)<br />
516<br />
(Windows<br />
only)<br />
Returns the localized name of the Administrators group. The group name<br />
differs based on the localized version of Windows.<br />
Note - SYSTEM(515) lets UniData SQL create privilege table records for<br />
items owned by the Administrators group, even if the Windows version is<br />
not an English-language version.<br />
Returns 1 if the user is a member of the local Administrators group.<br />
Otherwise, returns 0.<br />
9010 Returns the type of database. This function returns UD if the database is<br />
UniData, or UV if the database is UniVerse. If the database is the UniData<br />
Personal Edition, the function returns UD.PE.<br />
SYSTEM Parameters (continued)
Example<br />
In the following example, the program segment turns on the printer if data is currently<br />
being sent to the display terminal:<br />
IS.ON = SYSTEM(1)<br />
IF IS.ON = 0 THEN<br />
PRINT 'TURNING THE PRINTER ON'<br />
PRINTER ON<br />
END<br />
SYSTEM 1-897
TAN<br />
Syntax<br />
TAN(num.expr)<br />
Description<br />
The <strong>UniBasic</strong> TAN function returns the trigonometric tangent of a numeric<br />
expression, num.expr.<br />
Example<br />
In the following example, the program statement prints 0.2679, the tangent of the<br />
argument 15:<br />
PRINT TAN(15)<br />
Related <strong>Commands</strong><br />
ACOS, ASIN, ATAN, COS, SIN<br />
1-871 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
TIME<br />
Syntax<br />
TIME( )<br />
Description<br />
The <strong>UniBasic</strong> TIME function returns the time of day in internal format, expressed as<br />
the number of seconds elapsed since midnight.<br />
Note: The TIME function has no arguments.<br />
Examples<br />
In the following example, the program statement prints the time of day in internal<br />
format. If the time is 1:01 A.M., UniData prints the value 3660, the number of<br />
seconds since midnight in internal format.<br />
PRINT TIME()<br />
In the next example, the TIME function is used in conjunction with the OCONV<br />
function for conversion to external format:<br />
PRINT OCONV(TIME(),"MT")<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DATE, ICONV Date (D), OCONV Date (D), TIMEDATE<br />
TIME 1-872
TIMEDATE<br />
Syntax<br />
TIMEDATE( )<br />
Description<br />
The <strong>UniBasic</strong> TIMEDATE function returns a string representation of the current<br />
time and date in the following external format:<br />
hh:mm:ss dd mmm yyyy<br />
Example<br />
In the following example, the program statement assigns the string representation of<br />
the current time and date to the variable TSTRING. If the current time and date were<br />
November 1, 1999, at 11:45 A.M., TSTRING would be “11:45:00 01 NOV 1999”.<br />
TSTRING = TIMEDATE()<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DATE, ICONV Date (D), OCONV Date (D), TIME<br />
1-873 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
TRANSACTION ABORT<br />
Syntax<br />
TRANSACTION ABORT<br />
Description<br />
The <strong>UniBasic</strong> TRANSACTION ABORT command cancels the active transaction.<br />
UniData discards the pending writes. As a result, other users never know that the<br />
transaction was in progress, and none of the updates associated with the transaction<br />
take place.<br />
A transaction can abort due to any of the following conditions, in addition to the<br />
execution of a TRANSACTION ABORT statement:<br />
A program finishes before a transaction commit is issued (STOP or END).<br />
A program chains to another program.<br />
An error terminates the program before a transaction commit is issued.<br />
A user breaks out of the program before a transaction commit is issued. This<br />
can be controlled programmatically by disabling the interrupt key during a<br />
transaction.<br />
The user is forced to log out or the user process is killed, which terminates<br />
a program before a transaction commit is issued.<br />
UniData handles the above abort conditions in the same way it does the TRANS-<br />
ACTION ABORT statement, by canceling the transaction.<br />
Tip: You should be aware of these various abort conditions and control the resulting<br />
action from within the program where possible and appropriate. For example, write<br />
statements that fail execute the ON ERROR clause if it exists. Otherwise the program<br />
aborts and the transaction also aborts.<br />
TRANSACTION ABORT 1-874
Example<br />
In the following example, the transaction process aborts if var is 0:<br />
1-875 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
TRANSACTION START<br />
THEN PRINT "Transaction started."<br />
ELSE PRINT "Transaction start failed, STATUS = ":STATUS(): STOP<br />
READU var FROM file.var, record1<br />
var += 2<br />
IF var = 0 THEN TRANSACTION ABORT; GOTO ERR:<br />
WRITE var TO file.var, record1<br />
TRANSACTION COMMIT<br />
THEN PRINT "Transaction committed."<br />
ELSE PRINT "Transaction Aborted, STATUS = ":STATUS(); STOP<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
TRANSACTION COMMIT, TRANSACTION START
TRANSACTION COMMIT<br />
Syntax<br />
TRANSACTION COMMIT {THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> TRANSACTION COMMIT command concludes the active transaction.<br />
UniData writes all pending writes to the appropriate files. You must specify a<br />
THEN clause or an ELSE clause. You can specify both clauses.<br />
UniData performs the following steps during a transaction commit:<br />
Disables the interrupt key.<br />
Writes all updates.<br />
Releases all record locks locked inside the transaction.<br />
Executes the THEN clause if it exists.<br />
Enables the interrupt key.<br />
Warning: When including WRITE statements within a transaction, you must code an<br />
ON ERROR clause that takes appropriate action to notify the user and stop the transaction.<br />
If the transaction is not aborted by the ON ERROR clause, processing<br />
continues, and the transaction will commit inappropriately.<br />
TRANSACTION COMMIT 1-876
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
STATUS Function Return Values<br />
After you execute TRANSACTION COMMIT, the STATUS function returns one of<br />
the values described in the following table.<br />
1-877 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
THEN statements END THEN executes if the commit is successful. END is required to<br />
terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the commit is not successful because no transaction<br />
is active or the record (or ID) does not exist. END is<br />
required to terminate multiline ELSE statements.<br />
UniData performs the following steps when a commit fails:<br />
Aborts the transaction.<br />
Executes the ELSE clause if it exists.<br />
Releases all record locks inside the transaction.<br />
TRANSACTION COMMIT Parameters<br />
Value Description<br />
0 The commit completed successfully.<br />
1 Transaction not started.<br />
3 Transaction cannot commit.<br />
STATUS Function Return Values
Examples<br />
The program segment below is taken from the sample program in Appendix A,<br />
“Sample Program, in Developing <strong>UniBasic</strong> Applications. The segment executes the<br />
<strong>UniBasic</strong> function STATUS if the commit is not successful, but does not abort the<br />
transaction. However, when an error occurs, the transaction will never be committed<br />
and will automatically abort when the program terminates.<br />
TRANSACTION COMMIT ELSE<br />
IF STATUS() = 1 THEN<br />
DISPLAY "The TRANSACTION was not started"<br />
END ELSE<br />
DISPLAY "The TRANSACTION could not be committed."<br />
END<br />
END<br />
In the following example, the TRANSACTION COMMIT command ends the transaction<br />
process and writes the new record to the database. Otherwise, it prints the<br />
return value of the <strong>UniBasic</strong> STATUS function.<br />
TRANSACTION COMMIT<br />
THEN PRINT "Transaction committed."<br />
ELSE PRINT "Transaction aborted, STATUS = ":STATUS(); STOP<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
TRANSACTION ABORT, TRANSACTION START<br />
TRANSACTION COMMIT 1-878
TRANSACTION START<br />
Syntax<br />
TRANSACTION START {THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> TRANSACTION START command initiates a new transaction,<br />
storing all updates until a TRANSACTION COMMIT or TRANSACTION ABORT<br />
statement executes.<br />
Warning: When you include WRITE statements within a transaction, you must code<br />
an ON ERROR clause that takes action to notify the user and take appropriate action,<br />
such as stopping the transaction. If the transaction is not aborted by the ON ERROR<br />
clause, processing continues, and the transaction could commit inappropriately.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-879 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
THEN statements END THEN executes if the TRANSACTION START is successful.<br />
END is required to terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the TRANSACTION START is not<br />
successful, the record or ID does not exist, or a transaction is<br />
already active. END is required to terminate multiline ELSE<br />
statements.<br />
TRANSACTION START Parameters
STATUS Function Return Values<br />
After you execute TRANSACTION START, the STATUS function returns one of the<br />
values described in the following table.<br />
Example<br />
The following program segment displays a message if a transaction is already started<br />
when TRANSACTION START is executed:<br />
TRANSACTION START ELSE<br />
IF STATUS() = 1 THEN<br />
DISPLAY "A Transaction had already been started, NESTED<br />
Transactions"<br />
DISPLAY "are NOT Allowed. (Contact System Administrator)"<br />
INPUT PAUSE,1_<br />
END<br />
END<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
Value Description<br />
0 The transaction was started.<br />
1 The transaction was not started.<br />
STATUS Function Return Values<br />
TRANSACTION COMMIT, TRANSACTION COMMIT<br />
TRANSACTION START 1-880
TRIM<br />
Syntax<br />
TRIM(str.expr[,char[,type]])<br />
Description<br />
The <strong>UniBasic</strong> TRIM function removes all spaces or every occurrence of a specified<br />
character from a string expression. If UniData does not find an occurrence of the<br />
specified character, the string remains unchanged. TRIM removes leading or trailing<br />
occurrences of the specified character from a string, and converts embedded spaces<br />
or occurrences of the specified characters in a string to one space or a specified<br />
character. UniData does not remove single spaces or occurrences of the specified<br />
character embedded in the string.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-881 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
str.expr Specifies a string from which to remove spaces or the specified character.<br />
,char Specifies a character to remove from str.expr. The default is a space.<br />
,type Specifies the type of removal to perform. If char is an empty string, UniData<br />
does not perform the operation.<br />
L – Removes all leading occurrences of char.<br />
T – Removes all trailing occurrences of char.<br />
B – Removes leading and trailing occurrences of char.<br />
A – Removes all occurrences of char.<br />
R – (Default) Removes all leading, trailing, and contiguous occurrences of<br />
char.<br />
TRIM Parameters
Note: IBM recommends that you do not use the TRIM function on dynamic arrays.<br />
For BASICTYPEs M and P, some leading and trailing spaces or occurrences of a<br />
specified character are not removed from elements in a dynamic array. For example,<br />
for BASICTYPE M or P, the following program segment:<br />
P = “**Fred**Smith**”:@VM:”**Jim**Olsen**”<br />
Q = TRIM(P,”*”)<br />
produces the following result (notice the asterisks surrounding the delimiter<br />
character):<br />
Q = Fred*Smith*}*Jim*Olsen<br />
For BASICTYPE R or U, the program segment produces the following result:<br />
Q = Fred*Smith}Jim Olsen<br />
To get this latter result regardless of BASICTYPE, use the TRIMS function.<br />
Examples<br />
In the following example, the program segment removes the leading, trailing, and<br />
extraneous blanks from the variable NAME:<br />
NAME = " Zenith, R. "<br />
NAME = TRIM(NAME)<br />
This results in the following:<br />
NAME = "Zenith, R."<br />
In the next example, the program segment removes the asterisks from the variables<br />
X and Y:<br />
X = TRIM("***NOT***ICE***","*")<br />
Y = TRIM("***NOT***ICE***","*","A")<br />
This results in the following:<br />
X = "NOT*ICE"<br />
Y = "NOTICE"<br />
TRIM 1-882
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
TRIMB, TRIMF, TRIMS<br />
1-883 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
TRIMB<br />
Syntax<br />
TRIMB(str.expr)<br />
Description<br />
The <strong>UniBasic</strong> TRIMB function removes any trailing spaces from a string expression.<br />
If UniData does not find any trailing spaces, the string remains unchanged.<br />
Example<br />
In the following example, the program statement removes the trailing spaces from the<br />
variable NAME. This results in NAME = " Zenith, R.".<br />
NAME = " Zenith, R. "<br />
NAME = TRIMB(NAME)<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
TRIM, TRIMF, TRIMS<br />
TRIMB 1-884
TRIMF<br />
Syntax<br />
TRIMF(str.expr)<br />
Description<br />
The <strong>UniBasic</strong> TRIMF function removes any leading spaces from the string<br />
expression. If UniData does not find any leading spaces, the string remains<br />
unchanged.<br />
Example<br />
In the following example, the program segment removes the leading spaces from the<br />
variable NAME, storing the resulting string. This results in "Zenith, R. ".<br />
NAME= " Zenith, R. "<br />
NAME = TRIMF(NAME)<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
TRIM, TRIMB, TRIMS<br />
1-885 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
TRIMS<br />
Syntax<br />
TRIMS(dyn.array[,char[,type]])<br />
Description<br />
The <strong>UniBasic</strong> TRIMS function removes any spaces from each element of a dynamic<br />
array. If UniData does not find any spaces, the element remains unchanged.<br />
TRIMS removes any leading or trailing spaces from a string and converts any<br />
contiguous spaces in a string to one space. Single blanks between text are not<br />
removed.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
dyn.array Specifies a dynamic array from which to remove spaces or the specified<br />
character.<br />
,char Specifies a character to remove from elements in dyn.array. The default is a<br />
space.<br />
,type Specifies the type of removal to perform. If char is an empty string, UniData<br />
does not perform the operation.<br />
L – Removes all leading occurrences of char.<br />
T – Removes all trailing occurrences of char.<br />
B – Removes leading and trailing occurrences of char.<br />
A – Removes all occurrences of char.<br />
R – (Default) Removes all leading, trailing, and contiguous occurrences of<br />
char.<br />
TRIMS Parameters<br />
TRIMS 1-886
Example<br />
In the following example, the program segment removes any spaces from each<br />
element of the dynamic array ARR1:<br />
1-887 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ARR1 = " Jones ":@AM:" Smith ":@AM:" Johnson "<br />
ARR1 = TRIMS(ARR1)<br />
This results in the following:<br />
ARR1 = Jones}Smith}Johnson<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
TRIM, TRIMB, TRIMF
UDTEXECUTE<br />
Syntax<br />
UDTEXECUTE str.expr [{ASYNC | SYNC} ON connection]<br />
[CAPTURING dyn.array.var] [RETURNING dyn.array.var] [PASSCOM]<br />
Description<br />
The <strong>UniBasic</strong> UDTEXECUTE command executes a command in ECLTYPE U,<br />
regardless of the BASICTYPE used when the program was compiled.<br />
When you compile a program in BASICTYPE P, EXECUTE or PERFORM passes<br />
the string to execute to a nonstandard UniData parser. This parser looks for a specific<br />
sentence structure common to BASICTYPE P systems. Standard UniQuery<br />
sentences might not be handled correctly in this circumstance. Therefore, when you<br />
want to execute a standard UniQuery statement from within a <strong>UniBasic</strong> program that<br />
has been compiled in BASICTYPE P, use the UDTEXECUTE command instead of<br />
EXECUTE or PERFORM.<br />
STACKCOMMON<br />
The ECL STACKCOMMON command makes use of common areas more flexible,<br />
although it requires additional memory. STACKCOMMON settings have the<br />
following effects:<br />
If STACKCOMMON is off when one program executes another, the<br />
contents of unnamed common areas are passed to the executed program and<br />
back to the executing program.<br />
If STACKCOMMON is on when one program executes another program,<br />
the contents of unnamed common areas are not passed to the program you<br />
execute. Instead, they are saved, and the unnamed common areas of the<br />
called program are initialized to 0. When control is passed back to the<br />
calling program, it is restored to its value before the program call. Unnamed<br />
common areas are never passed to a phantom program.<br />
Note: STACKCOMMON defaults to OFF in BASICTYPEs R and U, but is always on<br />
in BASICTYPEs M and P.<br />
UDTEXECUTE 1-889
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
COMMON, EXECUTE, EXECUTESQL, MDPERFORM, PCPERFORM<br />
UniData<br />
STACKCOMMON – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
1-890 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
str.expr Specifies a command to execute.<br />
ASYNC | SYNC UniData no longer supports this parameter, but it remains for syntax<br />
compatibility.<br />
ON connection UniData no longer supports this parameter, but it remains for syntax<br />
compatibility.<br />
CAPTURING,<br />
dyn.array.var<br />
RETURNING,<br />
dyn.array.var<br />
The CAPTURING clause stores the output in a dynamic array<br />
instead of on the display terminal. Each line of the text becomes an<br />
attribute in the array. Output sent to the printer is not affected by this<br />
clause.<br />
The order of CAPTURING and RETURNING is interchangeable.<br />
The RETURNING clause captures error messages resulting from the<br />
command executed with UDTEXECUTE. This variable contains a<br />
string of error message numbers separated by spaces. If the executed<br />
command creates a spooler hold file, UniData also returns the hold<br />
file number in the same variable.<br />
PASSCOM This parameter is provided for backward compatibility for releases<br />
before 3.1.<br />
UDTEXECUTE Parameters
UNASSIGNED<br />
Syntax<br />
UNASSIGNED(var.name)<br />
Description<br />
The <strong>UniBasic</strong> UNASSIGNED function checks a variable in a program to see if it is<br />
currently assigned a value. If the variable is not assigned a value, the function returns<br />
1. Otherwise, it returns 0.<br />
Example<br />
In the following example, the program statement returns 0 if FILENAME1 is<br />
currently assigned a value. It returns 1 if no value is currently assigned.<br />
X = UNASSIGNED(FILENAME1)<br />
UNASSIGNED 1-891
UNLOCK<br />
Syntax<br />
UNLOCK [num.expr]<br />
Description<br />
The <strong>UniBasic</strong> UNLOCK command unlocks predefined computer resources reserved<br />
by the LOCK command. Resource numbers range from 0 through 63. If you do not<br />
specify a resource number, the system releases all locks you have set. If there are no<br />
locked resources at the time of execution, the statement does not have any effect.<br />
The lock is associated with num.expr, not the resource. Therefore, a command that<br />
does not check for locks against the resource number will access the resource even if<br />
it is locked. For example, an installation might assign locks 1 through 4 to four<br />
system printers. When an application needs to reserve printer 1, the application<br />
executes LOCK 1. All other programs must check for locks before accessing the<br />
resource for the lock to be effective.<br />
Resources are not automatically unlocked by the termination of the locking program.<br />
You must use the <strong>UniBasic</strong> UNLOCK or ECL QUIT commands to release them. You<br />
also can release resources by executing the ECL CLEAR.LOCKS command at the<br />
UniData level.<br />
Example<br />
In the following example, the program statement unlocks all computer resources<br />
reserved by the current user:<br />
UNLOCK<br />
1-892 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
LOCK<br />
UniData<br />
CLEAR.LOCKS, LIST.LOCKS, SUPERCLEAR.LOCKS – For information, see the<br />
UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
UNLOCK 1-893
UPCASE<br />
Syntax<br />
UPCASE(string.expr)<br />
Description<br />
The <strong>UniBasic</strong> UPCASE function converts lowercase characters to uppercase.<br />
Nonalphabetic values are not changed. Special characters, including the null value,<br />
are not converted by this function. UPCASE does not support multibyte languages.<br />
Example<br />
In the following example, the program segment converts “be bold!!” to “BE<br />
BOLD!!”:<br />
STRING = 'be bold!!'<br />
PRINT UPCASE(STRING)<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DOWNCASE, ICONV Masked Character (MC), OCONV Masked Character (MC)<br />
1-894 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
WAKE<br />
Syntax<br />
WAKE pid<br />
Description<br />
The <strong>UniBasic</strong> WAKE command activates a UniData process (pid) that has been<br />
paused with either the ECL PAUSE command or the <strong>UniBasic</strong> PAUSE command. If<br />
the specified process has not already been paused, UniData disregards the next<br />
PAUSE issued for the process indicated by pid.<br />
Example<br />
The following program, WAKEUP, lists paused processes, then prompts for the ID of<br />
a process to wake up. Next, the program executes the <strong>UniBasic</strong> WAKE command<br />
against that process, and then executes LIST.PAUSED again to verify that the process<br />
was reactivated.<br />
WAKEUP<br />
EXECUTE "LIST.PAUSED"<br />
PRINT "Enter ID for process to wake ":<br />
INPUT pid<br />
WAKE pid<br />
EXECUTE "LIST.PAUSED"<br />
The following example shows the results of executing the preceding program,<br />
waking up process 10811:<br />
1 :RUN BP WAKEUP<br />
2 Number of Paused Users<br />
3 ~~~~~~~~~~~~~~~~~~~~~~<br />
4 1<br />
5<br />
6 UDTNO USRNBR UID USRNAME USRTYPE TTY LEFTTIME<br />
TOT_TIME<br />
7 1 10811 1283 carolw udt pts/0 - -<br />
8<br />
9 Enter ID for process to wake ?10811<br />
10 Number of Paused Users<br />
11 ~~~~~~~~~~~~~~~~~~~~~~<br />
12 0<br />
WAKE 1-896
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
PAUSE<br />
UniData<br />
LIST.PAUSED, PAUSE, WAKE – For information, see the UniData <strong>Commands</strong><br />
<strong>Reference</strong>.<br />
UniData Paragraph Command<br />
SLEEP – For information, see Using UniData.<br />
1-897 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
WEOF<br />
Syntax<br />
WEOF [UNIT(mu.expr)] {THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> WEOF command writes an EOF (end-of-file) mark to a magnetic tape.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
UNIT(mu.expr) Specifies the conversion code (first digit), and the unit number<br />
(second digit). UniData allows unit numbers from 0 through 9.<br />
The mu.expr is optional, and the default value for UNIT is (00)<br />
for tape unit 0 with no conversion performed (ASCII assumed).<br />
Valid options include the following:<br />
0 – No conversion (ASCII assumed).<br />
1 – EBCDIC conversion.<br />
2 – Invert high bit.<br />
3 – Swap bytes.<br />
THEN statements END THEN executes if command execution is successful. END is<br />
required to terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if command execution is not successful or the<br />
record (or ID) does not exist. END is required to terminate<br />
multiline ELSE statements.<br />
WEOF Parameters<br />
WEOF 1-898
STATUS Function Return Values<br />
After you execute WEOF, the STATUS function returns one of the values described<br />
in the following table.<br />
Example<br />
In the following example, the program statement writes an end-of-file mark to tape<br />
0. If unable to write the end-of-file mark, UniData executes the ELSE clause.<br />
1-899 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
WEOF UNIT(00) ELSE "Unable to write an end-of-file"<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
READT, RESIZET, REWIND, WRITET<br />
UniData<br />
Value Description<br />
0 Successful read.<br />
1 End of file encountered.<br />
2 End of tape encountered.<br />
3 Tape not assigned.<br />
4 Parity error.<br />
5 Unknown hardware error.<br />
6 Other unspecified error.<br />
STATUS Function Return Values<br />
SETTAPE, T.ATT, T.DET – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.
WEOFSEQ<br />
Syntax<br />
WEOFSEQ seq.file.var [ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> WEOFSEQ command writes an end-of-file mark at the record pointer<br />
position in a sequential file, which results in the file being truncated at the current<br />
position.<br />
Tip: Use WEOFSEQ after a series of WRITESEQ operations.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
seq.file.var Specifies a sequential file variable to which to write the end-of-file mark.<br />
ON ERROR<br />
statements<br />
Example<br />
In the following example, the program statement writes an end-of-file mark to the file<br />
TRIAL.RUN at the current pointer position:<br />
WEOFSEQ TRIAL.RUN<br />
Specifies statements to execute if the WEOFSEQ statement fails with a<br />
fatal error because the file is not open, an I/O error occurs, or UniData<br />
cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error occurs, the<br />
program terminates.<br />
WEOFSEQ Parameters<br />
WEOFSEQ 1-900
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLOSESEQ, OPENSEQ, OSCLOSE, OSOPEN, READSEQ, WRITESEQ,<br />
WRITESEQF<br />
1-901 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
WRITE<br />
Syntax<br />
WRITE expr {ON | TO} [file.var,] record.ID.expr [ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> WRITE command writes an expression to an opened file and releases<br />
locks set by the same process.<br />
Note: WRITE updates the record and releases UniData locks regardless of lock<br />
status. To check for and retain record locks, use the WRITEU command. For more<br />
information, see Developing <strong>UniBasic</strong> Applications.<br />
To maintain file integrity, UniData locks records with a nonprogrammable lock<br />
during a write. UniData releases this lock immediately after the WRITE command<br />
executes.<br />
Warning: Do not use <strong>UniBasic</strong> READ and WRITE commands to open or modify<br />
binary data in DIR-type files (for example, BP). Doing so can corrupt data in the file.<br />
Instead, use OSREAD or OSBREAD after executing the <strong>UniBasic</strong> NOCONVERT<br />
command.<br />
Updating Alternate Key Indexes<br />
Remember the following points about alternate key indexes when you code WRITE<br />
statements:<br />
Alternate key indexes that are currently enabled are automatically updated<br />
when you write a record.<br />
If you execute the ECL command DUP.STATUS ON, and then write a<br />
record that creates a duplicate alternate key, WRITE sets the STATUS return<br />
value to 10.<br />
WRITE 1-902
1-903 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
If the NO.DUPS keyword was specified when the alternate key index was<br />
created, <strong>UniBasic</strong> will not write a record that would create a duplicate index<br />
key. Instead, the ON ERROR clause executes (or the program aborts if ON<br />
ERROR is not coded) and the STATUS function returns a value of 10. RFS<br />
does not support NO.DUPS.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
expr Specifies an expression to write to the record.<br />
ON | TO file.var Specifies a file to which to write the expression.<br />
If you do not specify a file.var, UniData writes to the default file. If<br />
no default file is open, a fatal error occurs.<br />
A default file is one for which no file variable is assigned in the OPEN<br />
statement.<br />
record.ID.expr Specifies a record to receive the expression. If the record already<br />
exists, the new expression you specify with expr replaces the existing<br />
information. If the record you specify does not exist, UniData creates<br />
the record.<br />
ON ERROR<br />
statements<br />
Specifies statements to execute in the event of a fatal error condition<br />
(such as the file is not open, an I/O error occurs in the write process,<br />
or the record contains a duplicate alternate index key). If you do not<br />
specify the ON ERROR clause, the program terminates under fatal<br />
error conditions.<br />
When including WRITE statements within a transaction, you must<br />
code an ON ERROR clause that notifies the user and takes appropriate<br />
action, such as stopping the transaction. If the transaction is not<br />
aborted by the ON ERROR clause, processing continues, and the<br />
transaction could commit inappropriately.<br />
WRITE Parameters
STATUS Function Return Values<br />
After you execute WRITE, the STATUS function returns one of the values described<br />
in the following table.<br />
Return<br />
Value Meaning<br />
0 Successful write.<br />
1 System error, such as a damaged file.<br />
2 Constraint violation. In this case, the <strong>UniBasic</strong> trigger subroutine returns a<br />
value of 0 in the parameter execstat, indicating that the WRITE is not<br />
allowed.<br />
3 Trigger execution error or unexpected return from trigger routine (for<br />
example, the trigger subroutine is not cataloged).<br />
10 Non-RFS files – WRITE created a duplicate alternate index key and ECL<br />
DUP.STATUS is on; or WRITE failed because a duplicate value exists in the<br />
index, and NO.DUPS was specified when the index was created.<br />
RFS files – WRITE created a duplicate value in the index, and ECL<br />
DUP.STATUS is on.<br />
STATUS Function Return Values<br />
Examples<br />
The following program segment is taken from the sample program in Appendix A,<br />
“Sample Program, in Developing <strong>UniBasic</strong> Applications. The statements update<br />
records that were previously locked with READU and release locks on the records.<br />
WRITE CLIENT.REC ON CLIENT_FILE,CLIENT_NUMBER<br />
WRITE ORDER.REC ON ORDERS_FILE,ORDER_NUMBER<br />
In the next example, the program statement writes the contents of the variable<br />
OVERSTOCK to the file named in variable FNAME as a record with ID OS:<br />
WRITE OVERSTOCK TO FNAME,"OS"<br />
WRITE 1-904
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLOSE, DELETE, OPEN, READL, READU, READV, READVL, READVU,<br />
WRITEU, WRITEV, WRITEVU<br />
UniData<br />
DUP.STATUS – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
1-905 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
WRITELIST<br />
Syntax<br />
WRITELIST var ON list.name<br />
Description<br />
The <strong>UniBasic</strong> WRITELIST command writes the contents of a variable to a saved<br />
list. The values saved can then be used as item IDs to retrieve the data record.<br />
WRITELIST saves only the first value of the attribute. UniData saves only the first<br />
value in a multivalued or multi-subvalued attribute.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
DELETELIST, FORMLIST, READLIST, SELECT, SELECTINDEX,<br />
SELECTINFO<br />
UniQuery<br />
Parameter Description<br />
var Specifies a variable to place in a saved list.<br />
ON list.name Specifies a saved list to contain the retrieved list.<br />
WRITELIST Parameters<br />
DELETE.LIST, GET.LIST, SELECT, SSELECT, SAVE.LIST – For information, see<br />
the UniQuery <strong>Commands</strong> <strong>Reference</strong>.<br />
WRITELIST 1-906
UniData SQL<br />
SELECT – For information, see the UniData SQL <strong>Commands</strong> <strong>Reference</strong>.<br />
1-907 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
WRITESEQ<br />
Syntax<br />
WRITESEQ expr [APPEND] {ON | TO} seq.file.var [ON ERROR statements]<br />
{THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> WRITESEQ command writes an expression as a record on a<br />
sequential file at the current record pointer position.<br />
Note: Before you use WRITESEQ, you must open the file by using the OSOPEN or<br />
OPENSEQ command.<br />
Tip: Use the READSEQ command to position the record pointer before using<br />
WRITESEQ.<br />
If the file is a named pipe, you cannot use WRITESEQ to write to it. You must use the<br />
OSBWRITE command.<br />
WRITESEQ cannot immediately write a record to disk. UniData stores records in a<br />
buffer until the buffer is full.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
expr Specifies an expression to write as a record.<br />
APPEND Use the APPEND option to start the WRITESEQ process at<br />
the end-of-file mark. When APPEND is included, and no file<br />
exists, UniData creates a new file.<br />
ON | TO seq.file.var Specifies a sequential file to receive the expression.<br />
WRITESEQ Parameters<br />
WRITESEQ 1-908
Parameter Description<br />
Example<br />
In the following example, the program segment writes the expression<br />
BAD.ACCOUNTS to the file ACCOUNTS. A message displays if the record pointer<br />
is not at the end of the file.<br />
1-909 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ON ERROR statements Specifies statements to execute if the WRITESEQ statement<br />
fails with a fatal error because the file is not open, an I/O error<br />
occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
THEN statements END THEN executes if the WRITESEQ is successful. END is<br />
required to terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the WRITESEQ is not successful or the<br />
record (or ID) does not exist. END is required to terminate<br />
multiline ELSE statements.<br />
WRITESEQ BAD.ACCOUNTS TO ACCOUNTS<br />
ELSE PRINT "NOT AT END-OF-FILE"<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
WRITESEQ Parameters (continued)<br />
CLOSESEQ, OPENSEQ, OSBREAD, OSBWRITE, OSCLOSE, OSDELETE,<br />
OSOPEN, READSEQ, WEOFSEQ, WRITESEQF
WRITESEQF<br />
Syntax<br />
WRITESEQF expr [APPEND] {ON | TO} seq.file.var [ON ERROR statements]<br />
{THEN statements [END] | ELSE statements [END]}<br />
Description<br />
The <strong>UniBasic</strong> WRITESEQF command writes an expression as a record on a<br />
sequential file from a current record pointer position and forces UniData to immediately<br />
write the data to the disk.<br />
Note: Before you use WRITESEQF, you must open the file by using the OSOPEN or<br />
OPENSEQ command.<br />
Tip: Use the READSEQ command to position the record pointer before using<br />
WRITESEQF.<br />
If the file is a named pipe, you cannot use WRITESEQF to write to it. You must use<br />
the OSBWRITE command.<br />
Use the READSEQ command to position the record pointer before using<br />
WRITESEQF.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
expr Specifies an expression to write as a record.<br />
APPEND Use the APPEND option to start the WRITESEQF process at<br />
the end-of-file mark. If you use the APPEND option in a file<br />
that does not contain data, UniData creates a new file.<br />
ON | TO seq.file.var Specifies a sequential file variable to receive the expression.<br />
WRITESEQF Parameters<br />
WRITESEQF 1-910
Parameter Description<br />
Example<br />
In the following example, the program statement writes the variable CHK.WRITE to<br />
the file PAYROLL. All records currently in the output buffer are written to disk along<br />
with this record.<br />
1-911 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ON ERROR statements Specifies statements to execute if the WRITESEQF statement<br />
fails with a fatal error because the file is not open, an I/O error<br />
occurs, or UniData cannot find the file.<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
If you specify the ON ERROR clause and UniData cannot find<br />
the end-of-file mark, the ELSE clause executes.<br />
THEN statements END THEN executes if the WRITESEQF is successful. END is<br />
required to terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if the WRITESEQF is not successful or the<br />
record (or ID) does not exist. END is required to terminate<br />
multiline ELSE statements.<br />
WRITESEQF CHK.WRITE ON PAYROLL ELSE GOTO 100:<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
WRITESEQF Parameters (continued)<br />
CLOSESEQ, OPENSEQ, OSBREAD, OSBWRITE, OSCLOSE, OSDELETE,<br />
OSOPEN, READSEQ, WEOFSEQ, WRITESEQ
writeSocket<br />
Syntax<br />
writeSocket(socket_handle, socket_data, time_out, blocking_mode,<br />
actual_write_size)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Use the writeSocket function to write data to a socket connection.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
socket_handle The handle to the open socket.<br />
socket_data The data to be written to the socket.<br />
time_out The allowable time (in milliseconds) for blocking. This is<br />
ignored for a non-blocking write.<br />
blocking_mode 0:using current mode<br />
1:blocking<br />
2:non-blocking<br />
actual_write_size The number of characters actually written.<br />
writeSocket Parameters<br />
writeSocket 1-912
The following table describes the return status of each mode.<br />
Mode Return Status<br />
The following table describes the status of each return code.<br />
1-913 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
0 - Blocking The function will return only after all characters in socket_data<br />
are written to the socket.<br />
1 - Non-Blocking The function may return with fewer character written than the<br />
actual length (in the case that the socket is full).<br />
Mode Return Status<br />
Return Code Status<br />
0 Success.<br />
Non-zero See Socket Function Error Return Codes.<br />
writeSocket Return Codes
WRITET<br />
Syntax<br />
WRITET [UNIT(mu.expr)] expr {THEN statements [END] | ELSE statements<br />
[END]}<br />
Description<br />
The <strong>UniBasic</strong> WRITET command writes the value of an expression as a record onto<br />
tape.<br />
Note: Before you can use the WRITET command, you must reserve a tape drive with<br />
the ECL T.ATT command. For detailed information about tape commands, see the<br />
UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
UniData uses the ASCII 0 character (CHAR(0)) as a string-end delimiter. Therefore,<br />
you cannot use ASCII 0 in any string variable in <strong>UniBasic</strong>. When a string is read in<br />
a <strong>UniBasic</strong> program, CHAR(0) characters are converted to CHAR(128), and<br />
WRITET converts CHAR(128) back to CHAR(0).<br />
WRITET 1-914
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Multireel Tape Processing<br />
You must use the TAPELEN option for the T.ATT command and specify the tape<br />
length. This command is intended for use with UniData tapes only. For information<br />
about the ECL T.ATT command, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
1-915 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
UNIT(mu.expr) Specifies the conversion code (first digit) and the unit number<br />
(second digit). Unit numbers range from 0 through 9.<br />
The mu.expr is optional and the default value for UNIT is (00)<br />
for tape unit 0 with no conversion performed (ASCII assumed).<br />
Valid options include the following:<br />
0 – No conversion (ASCII assumed).<br />
1 – EBCDIC conversion.<br />
2 – Invert high bit.<br />
3 – Swap bytes.<br />
expr Specifies an expression to write.<br />
THEN statements END THEN executes if command execution is successful. END is<br />
required to terminate multiline THEN statements.<br />
ELSE statements END ELSE executes if command execution is not successful or the<br />
record (or ID) does not exist. END is required to terminate<br />
multiline ELSE statements.<br />
WRITET Parameters
STATUS Function Return Values<br />
After you execute WRITET, the STATUS function returns one of the values<br />
described in the following table.<br />
Example<br />
In the following example, the T.ATT command is executed, and then UniData writes<br />
the variable TAX.RECORD to tape:<br />
PERFORM "T.ATT"<br />
WRITET UNIT (00) TAX.RECORD ELSE PRINT 'TAPE PROBLEM'<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
READT, RESIZET, REWIND, WEOF<br />
UniData<br />
Value Description<br />
0 Successful read.<br />
1 End of file encountered.<br />
2 End of tape encountered.<br />
3 Tape not assigned.<br />
4 Parity error.<br />
5 Unknown hardware error.<br />
6 Other unspecified error.<br />
STATUS Function Return Values<br />
SETTAPE, T.ATT, T.DET – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
WRITET 1-916
WRITEU<br />
Syntax<br />
WRITEU expr {ON | TO} [file.var,] record.ID.expr [ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> WRITEU command writes a record to a file without releasing locks.<br />
WRITEU writes regardless of lock status.<br />
Note: <strong>UniBasic</strong> locks are advisory only. For more information, see Developing<br />
<strong>UniBasic</strong> Applications.<br />
Warning: Do not use <strong>UniBasic</strong> READ and WRITE commands to open or modify<br />
binary data in DIR-type files (for example, BP). Doing so can corrupt data in the file.<br />
Instead, use OSREAD or OSBREAD after executing the <strong>UniBasic</strong> NOCONVERT<br />
command.<br />
Updating Alternate Key Indexes<br />
Remember the following points about alternate key indexes when you code WRITEU<br />
statements:<br />
1-917 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Alternate key indexes that are currently enabled are automatically updated<br />
when you write a record.<br />
If you execute the ECL command DUP.STATUS ON, and then write a<br />
record that creates a duplicate alternate key, WRITEU sets the STATUS<br />
return value to 10.<br />
If the NO.DUPS keyword was specified when the alternate key index was<br />
created, <strong>UniBasic</strong> will not write a record that would create a duplicate index<br />
key. Instead, the ON ERROR clause executes (or the program aborts if ON<br />
ERROR is not coded) and the STATUS function returns a value of 10. RFS<br />
does not support NO.DUPS.
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
expr Specifies an expression to write to the file.<br />
ON | TO file.var, Specifies a file to receive the expression.<br />
If you do not specify a file.var, UniData writes to the default file.<br />
If no default file is open, a fatal WRITEU error occurs.<br />
A default file is one for which no file variable is assigned in the<br />
OPEN statement.<br />
record.ID.expr Specifies a record to receive the expression.<br />
ON ERROR<br />
statements<br />
Specifies statements to execute if the WRITEU statement fails<br />
with a fatal error (such as the file is not open, an I/O error occurs<br />
in the write process, or the record contains a duplicate alternate<br />
index key). If the transaction is not aborted by the ON ERROR<br />
clause, processing continues, and the transaction could commit<br />
inappropriately.<br />
WRITEU Parameters<br />
STATUS Function Return Values<br />
After you execute WRITEU, the STATUS function returns one of the values<br />
described in the following table.<br />
Return Value Description<br />
0 Successful write.<br />
1 System error, such as a damaged file.<br />
STATUS Function Return Values<br />
WRITEU 1-918
Return Value Description<br />
Example<br />
In the following example, the program statement writes the variable IDEA.57 to the<br />
file IDEAS as a record with the ID ‘LAST’. The lock remains in place if the record<br />
was locked before executing WRITEU.<br />
1-919 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
2 Constraint violation. In this case, the <strong>UniBasic</strong> trigger subroutine returns<br />
a value of 0 in the parameter execstat, indicating that the WRITEU is not<br />
allowed.<br />
3 Trigger execution error or unexpected return from trigger routine (for<br />
example, trigger subroutine is not cataloged).<br />
10 Non-RFS files – WRITEU created a duplicate alternate index key and<br />
ECL DUP.STATUS is ON; or WRITEU failed because a duplicate value<br />
exists in the index, and NO.DUPS was specified when the index was<br />
created.<br />
RFS files – WRITEU created a duplicate value in the index, and ECL<br />
DUP.STATUS is ON.<br />
WRITEU IDEA.57 ON IDEAS,'LAST'<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLOSE, DELETE, OPEN, READL, READU, READV, READVL, READVU,<br />
WRITE, WRITEV, WRITEVU<br />
UniData<br />
STATUS Function Return Values<br />
DUP.STATUS – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.
WRITEV<br />
Syntax<br />
WRITEV expr {ON | TO} [file.var,] record.ID.expr, attrib.expr<br />
[ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> WRITEV command updates a specified attribute in a file regardless<br />
of lock status.<br />
Note: The WRITEV command releases locks set by the same process. <strong>UniBasic</strong> locks<br />
are advisory only. For more information, see Developing <strong>UniBasic</strong> Applications..<br />
Updating Alternate Key Indexes<br />
Remember the following points about alternate key indexes when you code WRITEV<br />
statements:<br />
Alternate key indexes that are currently enabled are automatically updated<br />
when you write a record.<br />
If you execute the ECL command DUP.STATUS ON, and then write a<br />
record that creates a duplicate alternate key, WRITEV sets the STATUS<br />
return value to 10.<br />
If the NO.DUPS keyword was specified when the alternate key index was<br />
created, <strong>UniBasic</strong> will not write a record that would create a duplicate index<br />
key. Instead, the ON ERROR clause executes (or the program aborts if ON<br />
ERROR is not coded) and the STATUS function returns a value of 10. RFS<br />
does not support NO.DUPS.<br />
WRITEV 1-920
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-921 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
expr Specifies an expression to write to an attribute of a record.<br />
ON | TO file.var, Specifies a file to receive the expression.<br />
If you do not specify a file.var, UniData writes to the default file.<br />
If no default file is open, a fatal WRITEV error occurs.<br />
A default file is one for which no file variable is assigned in the<br />
OPEN statement.<br />
record.ID.expr Specifies a record to receive the expression.<br />
attrib.expr Specifies an attribute to receive the expression.<br />
ON ERROR<br />
statements<br />
Specifies statements to execute if the WRITEV statement fails<br />
with a fatal error (such as the file is not open, an I/O error occurs<br />
in the write process, or the record contains a duplicate alternate<br />
index key).<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
When including WRITEV statements within a transaction, you<br />
must code an ON ERROR clause that notifies the user and takes<br />
appropriate action, such as stopping the transaction. If the transaction<br />
is not aborted by the ON ERROR clause, processing<br />
continues, and the transaction could commit inappropriately.<br />
WRITEV Parameters
STATUS Function Return Values<br />
After you execute WRITEV, the STATUS function returns one of the values<br />
described in the following table.<br />
Value Description<br />
0 Successful write.<br />
1 System error, such as a damaged file.<br />
2 Constraint violation. In this case, the <strong>UniBasic</strong> trigger subroutine returns a<br />
value of 0 in the parameter execstat, indicating that the WRITEV is not<br />
allowed.<br />
3 Trigger execution error or unexpected return from trigger routine (for<br />
example, trigger subroutine is not cataloged).<br />
10 Non-RFS files – WRITEV created a duplicate alternate index key and ECL<br />
DUP.STATUS is on; or WRITEV failed because a duplicate value exists in<br />
the index and NO.DUPS was specified when the index was created.<br />
RFS files – WRITEV created a duplicate value in the index, and ECL<br />
DUP.STATUS is on.<br />
STATUS Function Return Values<br />
Examples<br />
In the following example, the program statement writes the variable NAME to the<br />
first attribute in the customer record with CLIENT.ID in the file CLIENTS:<br />
WRITEV NAME ON CLIENT,CLIENT.ID,1<br />
WRITEV 1-922
The following example is taken from the sample program in Appendix A, “Sample<br />
Program,” in Developing <strong>UniBasic</strong> Applications. It demonstrates using WRITEV to<br />
write an attribute. Notice that the attribute is read and the record locked. Then<br />
LOCATE is used to determine the position (within the attribute) of the value to be<br />
deleted. After that value is deleted, the attribute is written back to the record.<br />
1-923 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><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 />
CLOSE, DELETE, OPEN, READL, READU, READV, READVL, READVU,<br />
WRITE, WRITEU, WRITEVU<br />
UniData<br />
DUP.STATUS – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.
WRITEVU<br />
Syntax<br />
WRITEVU expr {ON | TO} [file.var,] record.ID.expr, attrib.expr<br />
[ON ERROR statements]<br />
Description<br />
The <strong>UniBasic</strong> WRITEVU command writes an expression to an attribute of a record<br />
regardless of lock status. This command retains locks. As with the WRITEV<br />
statement, the record ID and attribute number are mandatory.<br />
Note: <strong>UniBasic</strong> locks are advisory only. For more information, see Developing<br />
<strong>UniBasic</strong> Applications..<br />
Updating Alternate Key Indexes<br />
Remember the following points about alternate key indexes when you code<br />
WRITEVU statements:<br />
Alternate key indexes that are currently enabled are automatically updated<br />
when you write a record.<br />
If you execute the ECL command DUP.STATUS ON, then write a record<br />
that creates a duplicate alternate key, WRITEVU sets the STATUS return<br />
value to 10.<br />
If the NO.DUPS keyword was specified when the alternate key index was<br />
created, <strong>UniBasic</strong> will not write a record that would create a duplicate index<br />
key. Instead, the ON ERROR clause executes (or the program aborts if ON<br />
ERROR is not coded) and the STATUS function returns a value of 10. RFS<br />
does not support NO.DUPS.<br />
WRITEVU 1-924
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-925 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
expr Specifies an expression to write to an attribute of a record.<br />
ON | TO file.var, Specifies a file to receive the expression.<br />
If you do not specify a file.var, UniData writes to the default file.<br />
If no default file is open, a fatal error occurs.<br />
The default file is one for which no file variable is assigned in<br />
the OPEN statement.<br />
record.ID.expr Specifies a record to receive the expression.<br />
attrib.expr Specifies an attribute to receive the expression.<br />
ON ERROR<br />
statements<br />
Specifies statements to execute if the WRITEVU statement fails<br />
with a fatal error (such as the file is not open, an I/O error occurs<br />
in the write process, or the record contains a duplicate alternate<br />
index key).<br />
If you do not specify the ON ERROR clause and a fatal error<br />
occurs, the program terminates.<br />
When including WRITEVU statements within a transaction, you<br />
must code an ON ERROR clause that notifies the user and takes<br />
appropriate action, such as stopping the transaction. If the<br />
transaction is not aborted by the ON ERROR clause, processing<br />
continues, and the transaction could commit inappropriately.<br />
WRITEVU Parameters
STATUS Function Return Value<br />
After you execute WRITEVU, the STATUS function returns one of the values in the<br />
following table.<br />
Return Value Description<br />
0 Successful write.<br />
1 System error, such as a damaged file.<br />
2 Constraint violation. In this case, the <strong>UniBasic</strong> trigger subroutine returns a<br />
value of 0 in the parameter execstat, indicating that the WRITEVU is not<br />
allowed.<br />
3 Trigger execution error or unexpected return from trigger routine (for<br />
example, trigger subroutine is not cataloged).<br />
10 Non-RFS files – WRITEVU created a duplicate alternate index key and<br />
ECL DUP.STATUS is ON; or WRITEVU failed because a duplicate value<br />
exists in the index, and NO.DUPS was specified when the index was<br />
created.<br />
RFS files – WRITEVU created a duplicate value in the index, and ECL<br />
DUP.STATUS is ON.<br />
STATUS Function Return Values<br />
Related <strong>Commands</strong><br />
<strong>UniBasic</strong><br />
CLOSE, DELETE, OPEN, READL, READU, READV, READVL, READVU,<br />
WRITE, WRITEU, WRITEV<br />
UniData<br />
DUP.STATUS – For information, see the UniData <strong>Commands</strong> <strong>Reference</strong>.<br />
WRITEVU 1-926
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
XDOMAddChild<br />
Syntax<br />
XDOMAddChild(xmlHandle, xpathString, nsMap, nodeHandle,<br />
dupFlag,nodeType)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Finds the xpathString in the context xmlHandle in the DOM structure, and inserts a<br />
node as the last child of the found node. If the inserted node type is<br />
XDOM.ATTR.NODE, this node is inserted as an attribute.<br />
1-928 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
xmlHandle The handle to the context. [IN]<br />
xpathString Relative or absolute xpath string. [IN]<br />
The xpathString parameter uses the in-encoding parameter set in the<br />
system-level or account-level xmlconfig file, the XMLSETOPTIONS<br />
command, or the XMLSetOptions() API.<br />
nsMap The map of namespaces which resolve the prefixes in the xpath string.<br />
Format is “xmlns=default_url xmlns:prefix1=prefix1_url<br />
xmlns:prefix2=prefix2_url”<br />
For example:<br />
“xmlns=http://myproject.mycompany.com<br />
xmlns:a_prefix=a.mycompany.com” [IN]<br />
The nsMap parameter uses the in-encoding parameter set in the systemlevel<br />
or account-level xmlconfig file, the XMLSETOPTIONS<br />
command, or the XMLSetOptions() API.<br />
nodeHandle Handle to a DOM subtree. If nodeHandle points to a DOM document,<br />
all of its children are inserted, in the same order. [IN]<br />
dupFlag XDOM.DUP: Clones nodeHandle, and inserts the duplicate node.<br />
XDOM.NODUP: Inserts the original node. The subtree is also removed<br />
from its original location. [IN]<br />
XDOMAddChild Parameters<br />
XDOMAddChild 1-929
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
1-930 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurrred.<br />
XML.INVALID.HANDLE An invalid DOM handle was returned to the function.<br />
XDOMAddChild Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XDOMAppend<br />
Syntax<br />
XDOMAppend(xmlHandle, xpathString, nsMap, nodeHandle, dupFlag)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Finds the xpathString in the context xmlHandle in the DOM structure, and inserts<br />
nodeHandle into the DOM structure as next sibling of the found node. If the inserted<br />
node type is XDOM.ATTR.NODE, this node is inserted as an attribute.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
xmlHandle The handle to the context. [IN]<br />
xpathString Relative or absolute XPath string. [IN]<br />
The xpathString parameter uses the in-encoding parameter set in the<br />
system-level or account-level xmlconfig file, the XMLSETOPTIONS<br />
command, or the XMLSetOptions() API.<br />
XDOMAppend Parameters<br />
XDOMAppend 1-931
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Parameter Description<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
1-932 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
nsMap The map of namespaces which resolve the prefixes in the xpathString.<br />
Format is “xmlns=default_url xmlns:prefix1=prefix1_url<br />
xmlns:prefix2=prefix2_url”<br />
For example:<br />
“xmlns=http://myproject.mycompany.com<br />
xmlns:a_prefix=a.mycompany.com”<br />
[IN]<br />
The nsMap parameter uses the in-encoding parameter set in the systemlevel<br />
or account-level xmlconfig file, the XMLSETOPTIONS<br />
command, or the XMLSetOptions() API.<br />
nodeHandle Handle to a DOM subtree. If nodeHandle points to a DOM document,<br />
all of its children are inserted, in the same order. [IN]<br />
dupFlag XDOM.DUP: Clones nodeHandle, and insert the duplicate node.<br />
XDOM.NODUP: Inserts the original node. The subtree is also removed<br />
from its original location.<br />
[IN]<br />
XDOMAppend Parameters (continued)<br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurrred.<br />
XML.INVALID.HANDLE An invalid DOM handle was returned to the function.<br />
XDOMAppend Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XDOMClone<br />
Syntax<br />
XDOMClone(xmlHandle, newXmlHandle, depth)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Duplicates the DOM subtree specified by xmlHandle to a new subtree specified by<br />
newXmlHandle. The duplicate node has no parent (parentNode returns null.).<br />
Cloning an element copies all attributes and their values, including those generated<br />
by the XML processor, to represent defaulted attributes, but this method does not<br />
copy any text it contains unless it is a deep clone, since the text is contained in a child<br />
Text node. Cloning any other type of node simply returns a copy of this node.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
xmlHandle Handle to the DOM subtree. [IN]<br />
newXmlHandle Handle to the new DOM subtree. [IN]<br />
depth XDOM.FALSE: Clone only the node itself.<br />
XDOM.TRUE: Recursively clone the subtree under the specified node.<br />
[IN]<br />
XDOMClone Parameters<br />
XDOMClone 1-933
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
1-934 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurrred.<br />
XML.INVALID.HANDLE An invalid DOM handle was returned to the function.<br />
XDOMClone Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XDOMClose<br />
Syntax<br />
XDOMClose(domHandle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMClose frees the DOM structure.<br />
Parameters<br />
The following table describes the parameter of the syntax.<br />
Parameter Description<br />
domHandle Handle to the DOM structure. [IN]<br />
XDOMClose Parameter<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
Return Code Description<br />
XML.SUCCESS Function completed successfully.<br />
XML.ERROR An error occurred.<br />
XML.INVALID.HANDLE Invalid DOM handle passed to the function.<br />
XDOMClose Return Codes<br />
XDOMClose 1-935
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
XDOMCreateNode<br />
Syntax<br />
XDOMCreateNode(xmlHandle, nodeName, nodeValue, nodeType, nodeHandle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you must<br />
compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMCreateNode creates a new node in the DOM structure.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameters Description<br />
1-936 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
xmlHandle A handle to the DOM structure. This handle acts as the context<br />
when resolving the namespace_uri from the prefix or resolving<br />
the prefix from the namespace_uri.<br />
[IN]<br />
nodeName The name of the node to be created. [IN]<br />
The name can be in any of the following formats:<br />
Local_name<br />
prefix: local_name:namespace_uri<br />
prefix:local_name<br />
:local_name:namespace_uri<br />
The nodeName parameter uses the in-encoding parameter set in<br />
the system-level or account-level xmlconfig file, the XMLSE-<br />
TOPTIONS command, or the XMLSetOptions() API.<br />
XDOMCreateNode Parameters
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Parameters Description<br />
nodeValue The string to hold the node value. [IN]<br />
The nodeValue parameter uses the in-encoding parameter set in<br />
the system-level or account-level xmlconfig file, the XMLSE-<br />
TOPTIONS command, or the XMLSetOptions() API.<br />
nodeType The type of the node to be created. Valid values are:<br />
XDOM.ELEMENT.NODE<br />
XDOM.ATTR.NODE<br />
XDOM.TEXT.NODE<br />
XDOM.CDATA.NODE<br />
XDOM.ENTITY.REF.NODE<br />
XDOM.ENTITY.NODE<br />
XDOM.PROC.INST.NODE<br />
XDOM.COMMENT.NODE<br />
XDOM.DOC.NODE<br />
XDOM.DOC.TYPE.NODE<br />
XDOM.DOC.FRAG.NODE<br />
XDEOM.NOTATION.NODE<br />
XDOM.XML.DECL.NODE<br />
UniData uses this argument, along with direction and childIndex,<br />
to get the right type node. For example, if direction is<br />
XDOM.PREV.SIBLING, and nodeType is<br />
XDOM.ELEMENT.NODE, UniData finds the element node that<br />
is the first previous sibling of nodeHandle. If direction is<br />
XDOM.CHILD, childIndex is XDOM.FIRST.CHILD, and<br />
nodeType is XDOM.ELEMENT.NODE, UniData finds the<br />
element node that is the first element child of nodeHandle. If the<br />
direction is XDOM.CHILD, childIndex is 2, and nodeType is<br />
XDOM.ELEMENT.NODE, UniData finds the element node that<br />
is the second element child of nodeHandle.<br />
When the direction is<br />
XDOM.NEXT.SIBLING.WITH.SAME.NAME,<br />
XDOM.PREV.SIBLING.WITH.SAME.NAME, or<br />
XDOM.PARENT, this argument is not used. [IN]<br />
nodeHandle A handle to the node to be created in the DOM structure.<br />
[IN]<br />
XDOMCreateNode Parameters (continued)<br />
XDOMCreateNode 1-937
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Return Codes<br />
The return code indicates success or failure. The following table describes each<br />
return code.<br />
Return Code Description<br />
1-938 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
XML.SUCCESS Function completed successfully.<br />
XML.ERROR An error occurred.<br />
XDOMCreateNode Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XDOMCreateRoot<br />
Syntax<br />
XDOMCreateRoot(domHandle[,xmlOptions])<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMCreateRoot creates a new DOM structure with root only. You can use the<br />
result handle in other functions where a DOM handle or node handle is needed. The<br />
default declaration for the XML document created by this function is as follows:<br />
<br />
XDOMCreateRoot 1-939
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Parameters<br />
The following table describes the parameter of the syntax.<br />
Parameter Description<br />
1-940 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
domHandle Handle to the opened DOM structure. [OUT]<br />
xmlOptions A string specifying the key/value pairs for the encoding, standalone,<br />
and version options to be declared in the XML document<br />
created by this function. [IN]<br />
The string can be entered in either of the following formats:<br />
"version=1.0 encoding=ISO-8859-1<br />
standalone=yes"<br />
or<br />
’version="1.0" encoding="iso-8859-1"<br />
standalone="no"’<br />
The encoding, standalone, and version options are the same as<br />
those in the xmlconfig file and accept the same values. Keys and<br />
values are case-insensitive.<br />
Valid encoding settings can be found at<br />
http://www.iana.org/assignments/character-sets<br />
XDOMCreateRoot Parameter
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
Return Code Description<br />
XML.SUCCESS Function completed successfully.<br />
XML.ERROR An error occurred.<br />
If an error is encountered in xmlOptions, XMLGetError()<br />
returns one of the following error codes:<br />
38 Invalid XML config key: ‘key_name’<br />
39 Invalid XML config value: ‘value_string’<br />
40 Invalid XML config format: ‘name_value_string’<br />
XDOMCreateRoot Return Codes<br />
XDOMCreateRoot 1-941
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
XDOMEvaluate<br />
Syntax<br />
XDOMEvaluate(xmlHandle, xpathString, nsMap, aValue)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMEvaluate returns the value of the XPathString in the context xmlHandle in the<br />
DOM structure.<br />
1-942 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
xmlHandle Handle to the context. [IN]<br />
xpathString Relative or absolute XPath string. [IN]<br />
The xpathString parameter uses the in-encoding parameter set in the<br />
system-level or account-level xmlconfig file, the XMLSETOPTIONS<br />
command, or the XMLSetOptions() API.<br />
nsMap The map of namespaces which resolves the prefixes in the xpathString.<br />
Format is “xmlns=default_url xmlns:prefix1=prefix1_url<br />
xmlns:prefix2=prefix2_url”<br />
For example:<br />
“xmlns=http://myproject.mycompany.com<br />
xmlns:a_prefix=a.mycompany.com”<br />
[IN]<br />
The nsMap parameter uses the in-encoding parameter set in the systemlevel<br />
or account-level xmlconfig file, the XMLSETOPTIONS<br />
command, or the XMLSetOptions() API.<br />
aValue The value of xpathString. [OUT]<br />
The aValue parameter uses the out-encoding parameter set in the systemlevel<br />
or account-level xmlconfig file, the XMLSETOPTIONS<br />
command, or the XMLSetOptions() API.<br />
XDOMEvaluate Parameters<br />
XDOMEvaluate 1-943
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
1-944 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurred.<br />
XML.INVALID.HANDLE An invalid DOM handle was returned to the function.<br />
XDOMEvaluate Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XDOMGetAttribute<br />
Syntax<br />
XDOMGetAttribute(nodeHandle, attrName, nodeHandle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMGetAttribute gets the node's attribute node, whose attribute name is attrName.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
nodeHandle Handle to the DOM node. [IN]<br />
attrName Attribute name. [IN]<br />
The attrName parameter uses the in-encoding parameter set in<br />
the system-level or account-level xmlconfig file, the XMLSE-<br />
TOPTIONS command, or the XMLSetOptions() API.<br />
nodeHandle Handle to the found attribute node. [OUT]<br />
XDOMGetAttribute Parameters<br />
XDOMGetAttribute 1-945
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
1-946 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurrred.<br />
XML.INVALID.HANDLE An invalid DOM handle was returned to the function.<br />
XDOMGetAttribute Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XDOMGetNodeName<br />
Syntax<br />
XDOMGetNodeName(nodeHandle, nodeName)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMGetNodeName gets the node name.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
nodeHandle Handle to the DOM node. [IN]<br />
nodeName String to store the node name. [OUT]<br />
The nodeName parameter uses the out-encoding parameter set in the<br />
system-level or account-level xmlconfig file, the XMLSETOPTIONS<br />
command, or the XMLSetOptions() API.<br />
XDOMGetNodeName Parameters<br />
XDOMGetNodeName 1-947
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
1-948 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurrred.<br />
XML.INVALID.HANDLE An invalid DOM handle was returned to the function.<br />
XDOMGetNodeName Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XDOMGetNodeType<br />
Syntax<br />
XDOMGetNodeType(nodeHandle, nodeType)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMGetNodeType gets the node type.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Return Codes<br />
Parameter Description<br />
nodeHandle The handle to the DOM node. [IN]<br />
nodeType An integer to store the node type. [OUT]<br />
XDOMGetNodeType Parameters<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurrred.<br />
XML.INVALID.HANDLE An invalid DOM handle was returned to the function.<br />
XDOMGetNodeType Return Codes<br />
XDOMGetNodeType 1-949
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
XDOMGetNodeValue<br />
Syntax<br />
XDOMGetNodeValue(nodeHandle, nodeValue)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMGetNodeValue gets the node value.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-950 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
nodeHandle The handle to the DOM node. [IN]<br />
nodeValue The string to hold the node value. [OUT]<br />
The nodeValue parameter uses the out-encoding parameter set in<br />
the system-level or account-level xmlconfig file, the XMLSE-<br />
TOPTIONS command, or the XMLSetOptions() API.<br />
XDOMGetNodeValue Parameters
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurrred.<br />
XML.INVALID.HANDLE An invalid DOM handle was returned to the function.<br />
XDOMGetNodeValue Return Codes<br />
XDOMGetNodeValue 1-951
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
XDOMGetOwnerDocument<br />
Syntax<br />
XDOMGetOwnerDocument(nodeHandle, domHandle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMGetOwnerDocument gets the DOM handle to which the nodeHandle belongs.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
1-952 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
nodeHandle Handle to the DOM node. [IN]<br />
domHandle Handle to the DOM structure. [OUT]<br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurrred.<br />
XML.INVALID.HANDLE An invalid DOM handle was returned to the function.<br />
XDOMGetOwnerDocument Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XDOMGetUserData<br />
Syntax<br />
XDOMGetUserData(nodeHandle, userData)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMGetUserData gets the user data associated with the node.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
nodeHandle The handle to the DOM node. [IN]<br />
userData String to hold the user data. [OUT]<br />
XDOMGetUserData Parameters<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurrred.<br />
XML.INVALID.HANDLE An invalid DOM handle was returned to the function.<br />
XDOMGetUserData Return Codes<br />
XDOMGetUserData 1-953
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
XDOMImportNode<br />
Syntax<br />
XDOMImportNode(xmlHandle, depth, importedNodeHandle, outNodeHandle)<br />
Description<br />
The XDOMImportNode function imports a node from another document into the<br />
current document. The returned node has no parent. The source node is not altered or<br />
removed from the original document.<br />
For all nodes, importing a node creates a node object owned by the document from<br />
which you are importing. The attribute values are identical to the source node's<br />
nodeName and nodeType, as well as attributes related to namespaces (prefix,<br />
localName, and namespaceURI).<br />
UniData attempts to mirror the behavior expected if a fragment of the XML source<br />
was copied from one document to another by copying additional information, as<br />
appropriate, to the nodeType. UniData recognizes that the two documents may have<br />
different DTDs. The following describes the specifics for each type of node:<br />
ATTRIBUTE_NODE<br />
UniData sets the ownerElement attribute to null and the specified flag to true on the<br />
generated DOMAttr. UniData recursively imports the descendants of the source<br />
DOMAttr and reassembles the resulting nodes to form a corresponding subtree.<br />
Note: The depth parameter has no effect on DOMAttr nodes. These nodes always<br />
carry their children with them when imported.<br />
DOCUMENT_FRAGMENT_NODE<br />
If the value of the depth option is true, UniData recursively imports the descendants<br />
of the source element and reassembles the resulting nodes to form the corresponding<br />
subtree. If the value of the depth option is false, UniData generates an empty<br />
DOMDocumentFragment.<br />
1-954 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
DOCUMENT_NODE<br />
You cannot import DOMDocument nodes.<br />
DOCUMENT_TYPE_NODE<br />
You cannot import DOMDocumentType nodes.<br />
ELEMENT_NODE<br />
UniData imports specified attribute nodes of the source document, and attaches the<br />
generated DOMAttr nodes to the generated DOMElement. UniData does not copy<br />
default attributes, although they are assigned if the document to which you are<br />
importing defines default attributes for this element name. If the value of the<br />
importNode depth parameter is true, UniData recursively imports the descendants of<br />
the source element and reassembles the resulting nodes to form the corresponding<br />
subtree.<br />
ENTITY_NODE<br />
You can import DOMEntity nodes, but in the current release of the DOM, the<br />
DOMDocumentType is read only. When you import and ENTITY_NODE, UniData<br />
copies the publicId, systemId, and notationName attributes. If the value of the depth<br />
parameter is true, UniData recursively imports the descendants of the source<br />
DOMEntity and reassembles the resulting node to form the corresponding subtree.<br />
ENTITY_REFERENCE_NODE<br />
If you import this type of node, UniData only copies the DOMEntity<strong>Reference</strong> itself,<br />
even if the value of the depth parameter is true. This is because the source and destination<br />
documents may have defined the entity differently. If the document you are<br />
importing provides a definition for this entity name, UniData assigns that value.<br />
NOTATION_NODE<br />
You can import DOMNotation nodes, but in the current release of the DOM, the<br />
DOMDocumentType is read only. When you import a NOTATION_NODE, UniData<br />
copies the publicId and systemId attributes. The depth parament has no effect on<br />
DOMNotation nodes, since they do not have children.<br />
XDOMGetUserData 1-955
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
PROCESSING_INSTRUCTION_NODE<br />
UniData copies the target and data values from the source node to the current<br />
document.<br />
TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE<br />
With these types of nodes, inheriting from DOMCharacterData, UniData copies the<br />
data and length attributes from the source node to the current document.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-956 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
xmlHandle The target XML document to which you are importing. [IN]<br />
depth XDOM.FALSE - import only the node itself.<br />
XDOM.TRUE - recursively import the subtree under the node<br />
specified by importedNodeHandle.<br />
This parameter has no effect on DOMAttr,<br />
DOMEntity<strong>Reference</strong>, and DOMNotation nodes. [IN]<br />
importedNodeHandle The handle to the node you are importing. [IN]<br />
newXMLHandle The handle to the new node. [IN]<br />
XDOMImportNode Parameters
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Return Status<br />
The following table describes the return status for XDOMImportNode:<br />
Status Description<br />
XML.SUCCESS The import was successful.<br />
XML.ERROR An error occurred during import.<br />
XML.INVALID.HANDLE The xmlHandle or importedNodeHandle is not a valid XML<br />
handle.<br />
XDOMImportNode Return Status<br />
XDOMGetUserData 1-957
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
XDOMInsert<br />
Syntax<br />
XDOMInsert (xmlHandle, xpathString, nsMap, nodeHandle, dupFlag)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMInsert finds the xpathString in the context xmlHandle in the DOM structure,<br />
and inserts nodeHandle into the DOM structure as the previous sibling of the found<br />
node. If the inserted node type is XDOM.ATTR.NODE, this node is inserted as an<br />
attribute.<br />
1-958 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong>
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
xmlHandle The handle to the context. [IN]<br />
xpathString Relative or absolute XPath string. [IN]<br />
The xpathString parameter uses the in-encoding parameter set in the<br />
system-level or account-level xmlconfig file, the XMLSETOPTIONS<br />
command, or the XMLSetOptions() API.<br />
nsMap The map of namespaces which resolves the prefixes in the<br />
xpathString.<br />
Format is “xmlns=default_url xmlns:prefix1=prefix1_url<br />
xmlns:prefix2=prefix2_url”<br />
For example:<br />
“xmlns=http://myproject.mycompany.com<br />
xmlns:a_prefix=a.mycompany.com”<br />
[IN]<br />
The nsMap parameter uses the in-encoding parameter set in the<br />
system-level or account-level xmlconfig file, the XMLSETOPTIONS<br />
command, or the XMLSetOptions() API.<br />
nodeHandle The handle to a DOM subtree. If nodeHandle points to a DOM<br />
document, all of its children are inserted, in the same order. [IN]<br />
dupFlag XDOM.DUP: Clones nodeHandle, and inserts the duplicate node.<br />
XDOM.NODUP: Inserts the original node. The subtree is also<br />
removed from its original location.<br />
XDOMInsert Parameters<br />
XDOMInsert 1-959
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
1-960 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurrred.<br />
XML.INVALID.HANDLE An invalid DOM handle was returned to the function.<br />
XDOMInsert Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XDOMLocate<br />
Syntax<br />
XDOMLocate(xmlHandle, xpathString, nsMap, nodeHandle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMLocate finds a starting point for relative XPath searching in context<br />
xmlHandle in the DOM structure. The xpathString should specify only one node;<br />
otherwise, this function will return an error.<br />
XDOMLocate 1-961
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
1-962 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
xmlHandle A handle to the DOM structure. [IN]<br />
xpathString A string to specify the starting point. [IN]<br />
The xpathString parameter uses the in-encoding parameter set in<br />
the system-level or account-level xmlconfig file, the XMLSE-<br />
TOPTIONS command, or the XMLSetOptions() API.<br />
nsMAP The map of namespaces which resolve the prefixes in the xpath-<br />
String. The format is:<br />
“xmlns=default_url xmlns:prefix1=prefix1_url<br />
xmlns:prefix2=prefix2_url<br />
For example:<br />
“xmlns=”http://myproject.mycompany.com<br />
xmlns:a_prefix=a.mycompany.com<br />
[IN]<br />
The nsMap parameter uses the in-encoding parameter set in the<br />
system-level or account-level xmlconfig file, the XMLSETOP-<br />
TIONS command, or the XMLSetOptions() API.<br />
nodeHandle Handle to the found node. [OUT]<br />
XDOMLocate Parameters<br />
Return Code Description<br />
XML.SUCCESS Function completed successfully.<br />
XML.ERROR An error occurred.<br />
XML.INVALID.HANDLE An invalid handle was returned to the function.<br />
XDOMLocate Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Note: In this document, xmlHandle is a generic type, it can be domHandle or<br />
nodeHandle. DomHandle stands for a whole document, while nodeHandle stands for<br />
a subtree. DomHandle is also a nodeHandle.<br />
XDOMLocate 1-963
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
XDOMLocateNode<br />
Syntax<br />
XDOMLocateNode(nodeHandle, direction, childIndex, nodeType,<br />
newNodeHandle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMLocateNode traverses from nodeHandle and gets the next node according to<br />
direction and childIndex.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-964 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
nodeHandle The handle to the starting node. [IN]<br />
direction Direction to traverse. Valid values are:<br />
XDOM.PREV.SIBLING<br />
XDOM.NEXT.SIBLING<br />
XDOM.NEXT.SIBLING.WITH.SAME.NAME<br />
XDOM.PREV.SIBLING.WITH.SAME.NAME<br />
XDOM.PARENT<br />
XDOM.CHILD<br />
[IN]<br />
XDOMLocateNode Parameters
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Parameter Description<br />
childIndex The index in the child array. Valid values are:<br />
XDOM.FIRST.CHILD<br />
XDOM.LAST.CHILD<br />
Positive Integer<br />
[IN]<br />
nodeType The typeof node to be located. Valid values are:<br />
XDOM.NONE<br />
XDOM.ELEMENT.NODE<br />
XDOM.ATTR.NODE<br />
XDOM.TEXT.NODE<br />
XDOM.CDATA.NODE<br />
XDOM.ENTITY.REF.NODE<br />
XDOM.ENTITY.NODE<br />
XDOM.PROC.INST.NODE<br />
XDOM.COMMENT.NODE<br />
XDOM.DOC.NODE<br />
XDOM.DOC.TYPE.NODE<br />
XDOM.DOC.FRAG.NODE<br />
XDEOM.NOTATION.NODE<br />
XDOM.XML.DECL.NODE<br />
If nodeType is not XDOM.NONE, UniData uses this argument,<br />
along with direction and childIndex, to get the right typed node.<br />
For example, if direction is XDOM.PREV.SIBLING, and<br />
nodeType is XDOM.ELEMENT.NODE, UniData finds the<br />
element node which is the first previous sibling of nodeHandle.<br />
If direction is XDOM.CHILD, childIndex is<br />
XDOM.FIRST.CHILD, and nodeType is<br />
XDOM.ELEMENT.NODE, UniData finds the element node<br />
which is the first element child of nodeHandle. If the direction is<br />
XDOM.CHILD, childIndex is 2, and nodeType is<br />
XDOM.ELEMENT.NODE, UniData finds the element node<br />
which is the second element child of nodeHandle.<br />
When the direction is<br />
XDOM.NEXT.SIBLING.WITH.SAME.NAME,<br />
XDOM.PREV.SIBLING.WITH.SAME.NAME, or<br />
XDOM.PARENT, this argument is not used. [IN]<br />
newNodeHandle Handle to the found node. [OUT]<br />
XDOMLocateNode Parameters (continued)<br />
XDOMLocateNode 1-965
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
1-966 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurred.<br />
XM.INVALID.HANDLE An invalid handle was returned to the function.<br />
XDOMLocateNode Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XDOMOpen<br />
Syntax<br />
XDOMOpen(xmlDocument, docLocation, domHandle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMOpen reads an XML document and creates a DOM structure. If the DTD is<br />
included in the document, UniData validates the document. The XML document can<br />
be from a string, or from a file, depending on the docLocation flag.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
xmlDocument The XML document. [IN]<br />
docLocation A flag to specify whether xmlDocument is a string holding the XML<br />
document, or it is a file containing the XML document. Valid values are:<br />
XML.FROM.FILE<br />
XML.FROM.STRING<br />
[IN]<br />
domHandle Handle to the opened DOM structure. [OUT]<br />
XDOMOpen Parameters<br />
XDOMOpen 1-967
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
1-968 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Code Description<br />
XML.SUCCESS Function completed successfully.<br />
XML.ERROR An error occurred.<br />
XML.INVALID.HANDLE Invalid DOM handle passed to the function.<br />
XDOMOpen Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XDOMRemove<br />
Syntax<br />
XDOMRemove(xmlHandle, xpathString, nsMap, attrName, nodeHandle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMRemove finds the xpathString in the context xmlHandle in the DOM<br />
structure, then removes the found node or its attribute with name attrName.<br />
XDOMRemove 1-969
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-970 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
xmlHandle Handle to the context. [IN]<br />
xpathString Relative or absolute xpath string. [IN]<br />
The xpathString parameter uses the in-encoding parameter set in the<br />
system-level or account-level xmlconfig file, the XMLSETOPTIONS<br />
command, or the XMLSetOptions() API.<br />
nsMap The map of namespaces which resolve the prefixes in the xpathString.<br />
Format is “xmlns=default_url xmlns:prefix1_url<br />
xmlns:prefix2=prefix2_url”<br />
For example:<br />
“xmlns=http://myproject.mycompany.com<br />
xmlns:a_prefix=a.mycompany.com”<br />
[IN]<br />
The nsMap parameter uses the in-encoding parameter set in the<br />
system-level or account-level xmlconfig file, the XMLSETOPTIONS<br />
command, or the XMLSetOptions() API.<br />
attrName The attribute name. [IN]<br />
The attrName parameter uses the in-encoding parameter set in the<br />
system-level or account-level xmlconfig file, the XMLSETOPTIONS<br />
command, or the XMLSetOptions() API.<br />
nodeHandle The removed node, if nodeHandle is not NULL. [OUT]<br />
XDOMRemove Parameters
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurrred.<br />
XML.INVALID.HANDLE An invalid DOM handle was returned to the function.<br />
XDOMRemove Return Codes<br />
XDOMRemove 1-971
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
XDOMReplace<br />
Syntax<br />
XDOMReplace(xmlHandle, xpathString, nsMap, nodeHandle, dupFlag)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMReplace finds the xpathString in the context xmlHandle in the DOM structure,<br />
and replaces the found node with nodeHandle.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-972 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
xmlHandle The handle to the context. [IN]<br />
xpathString Relative or absolute XPath string. [IN]<br />
The xpathString parameter uses the in-encoding parameter set in the<br />
system-level or account-level xmlconfig file, the<br />
XMLSETOPTIONS command, or the XMLSetOptions() API.<br />
XDOMReplace Parameters
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Parameter Description<br />
nsMap The map of namespaces which resolve the prefixes in the<br />
xpathString.<br />
Format is “xmlns=default_url xmlns:prefix1=prefix1_url<br />
xmlns:prefix2=prefix2_url”<br />
For example:<br />
“xmlns=http://myproject.mycompany.com<br />
xmlns:a_prefix=a.mycompany.com” [IN]<br />
The nsMap parameter uses the in-encoding parameter set in the<br />
system-level or account-level xmlconfig file, the<br />
XMLSETOPTIONS command, or the XMLSetOptions() API.<br />
nodeHandle Handle to a DOM subtree. If nodeHandle points to a DOM document,<br />
the found node is replaced by all of nodeHandle children, which are<br />
inserted in the same order. [IN]<br />
dupFlag XDOM.DUP: Clones nodeHandle, and replaces it with the duplicate<br />
node.<br />
XDOM.NODUP: Replaces with the original node. The subtree is also<br />
removed from its original location. [IN]<br />
Return Codes<br />
XDOMReplace Parameters (continued)<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurrred.<br />
XML.INVALID.HANDLE An invalid DOM handle was returned to the function.<br />
XDOMReplace Return Codes<br />
XDOMReplace 1-973
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
XDOMSetNodeValue<br />
Syntax<br />
XDOMSetNodeValue(nodeHandle, nodeValue)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMSetNodeValue sets the node value.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-974 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
nodeHandle The handle to the DOM node. [IN]<br />
nodeValue String to hold the node value. [IN]<br />
The nodeValue parameter uses the in-encoding parameter set in<br />
the system-level or account-level xmlconfig file, the XMLSE-<br />
TOPTIONS command, or the XMLSetOptions() API.<br />
XDOMSetNodeValue Parameters
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurrred.<br />
XML.INVALID.HANDLE An invalid DOM handle was returned to the function.<br />
XDOMSetNodeValue Return Codes<br />
XDOMSetNodeValue 1-975
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
XDOMSetUserData<br />
Syntax<br />
XDOMSetUserData(nodeHandle, userData)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMSetUserData sets the user data associated with the node.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
1-976 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Parameter Description<br />
nodeHandle Handle to the DOM node. [IN]<br />
userData String to hold the user data. [IN]<br />
XDOMSetUserData Parameters<br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurrred.<br />
XML.INVALID.HANDLE An invalid DOM handle was returned to the function.<br />
XDOMSetUserData Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XDOMTransform<br />
Syntax<br />
XDOMTransform(domHandle, styleSheet, ssLocation, outHandle[, outFormat])<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMTransform transforms the input DOM structure using the style sheet specified<br />
by styleSheetFile to output the DOM structure, file, or string.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
domHandle Handle to the DOM structure. [IN]<br />
styleSheet Handle to the context [IN]<br />
XDOMTransform Parameters<br />
XDOMTransform 1-977
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Parameter Description<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
1-978 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ssLocation A flag to specify whether styleSheet contains style sheet itself, or is just<br />
the style sheet file name. Value values are:<br />
XML.FROM.FILE (default)<br />
XML.FROM.STRING<br />
[IN]<br />
outHandle Handle to the resulting DOM structure, file, or string. [OUT]<br />
outFormat Specifies one of the following values as the output format for the DOM<br />
structure:<br />
XML.TO.DOM – Transforms the input DOM structure using the<br />
style sheet specified by styleSheet, and outputs the resulting<br />
document into a DOM structure.<br />
XML.TO.FILE – Transforms the input DOM structure using the style<br />
sheet specified by styleSheet, and outputs the resulting document into<br />
a file.<br />
XML.TO.STRING – Transforms the input DOM structure using the<br />
style sheet specified by styleSheet, and outputs the resulting<br />
document into a string.<br />
XDOMTransform Parameters (continued)<br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurrred.<br />
XML.INVALID.HANDLE An invalid DOM handle was returned to the function.<br />
XDOMTransform Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XDOMValidate<br />
Syntax<br />
XDOMValidate(xmlDocument, docLocation,, noNsSchema, noNsSchemaLocation[,<br />
NsSchemas])<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMValidata validates the DOM document using an external nonamespace<br />
schema specified by noNsSchema and, optionally, external namespace schemas<br />
specified by NsSchemas.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
xmlDocument The name of the XML document. [IN]<br />
docLocation A flag to specify whether xmlDocument is the document itself,<br />
or the document file name. Valid values are:<br />
XML.FROM.FILE (default)<br />
XML.FROM.STRING<br />
XML.FROM.DOM<br />
[IN]<br />
XDOMValidate Parameters<br />
XDOMValidate 1-979
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Parameter Description<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
1-980 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
noNsSchema The external no-namespace schema file. [IN]<br />
noNsSchemaLocation A flag to specify whether noNsSchema is the schema itself, or<br />
the schema file name. Valid values are:<br />
XML.FROM.FILE (default)<br />
XML.FROM.STRING<br />
[IN]<br />
NsSchemas The external namespace schema files. [IN]<br />
XDOMValidate Parameters (continued)<br />
Return Code Description<br />
XML.SUCCESS Function completed successfully.<br />
XML.ERROR An error occurred.<br />
XML.INVALID.HANDLE An invalid DOM handle was passed to the function.<br />
XDOMValidate Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XDOMValidateDom<br />
Syntax<br />
XDOMValidateDom(domHandle, noNsSchema, noNsSchemaLocation[,<br />
NsSchemas])<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you must<br />
compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMValidateDom validates the DOM document using an external no-namespace<br />
schema specified by noNsSchema and, optionally, external namespace schemas<br />
specified by NsSchemas.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
domHandle Handle to the DOM structure. [IN]<br />
noNsSchema The external no-namespace schema file. [IN]<br />
noNsSchemaLocation A flag to specify whether noNsSchema is the schema itself, or<br />
the schema file name. Valid values are:<br />
XML.FROM.FILE (default)<br />
XML.FROM.STRING<br />
[IN]<br />
NsSchemas The external namespace schema files. [IN]<br />
XDOMValidateDom Parameters<br />
XDOMValidateDom 1-981
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Return Codes<br />
The return code indicates success or failure. The following table describes each<br />
return code.<br />
1-982 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Code Description<br />
XML.SUCCESS Function completed successfully.<br />
XML.ERROR An error occurred.<br />
XML.INVALID.HANDLE An invalid DOM handle was passed to the function.<br />
XDOMValidateDom Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XDOMWrite<br />
Syntax<br />
XDOMWrite(domHandle, xmlDocument, docLocation[, xmlOptions])<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XDOMWrite writes the DOM structure to xmlDocument. xmlDocument can be a<br />
string or a file, depending on the value of the docLocation flag.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
domHandle Handle to the opened DOM structure. [IN]<br />
XDOMWrite Parameters<br />
XDOMWrite 1-983
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Parameter Description<br />
1-984 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
xmlDocument The XML document [OUT]<br />
docLocation A flag to specify whether xmlDocument is an output string which<br />
shoujld hold the XML document, or it is a file where the XML<br />
document should be written. Valid values are:<br />
XML.TO.FILE<br />
XML.TO.STRING<br />
[IN]<br />
xmlOptions A string specifying the key/value pairs of the XML options to be used<br />
in the XML document written by this function. [IN]<br />
The string can be entered in either of the following formats:<br />
"encoding=ISO-8859-1 standalone=yes newline=CR-LF"<br />
or<br />
‘encoding="iso-8859-1" standalone="no"’<br />
The XML options are the same as those in the xmlconfig file and accept<br />
the same values. Keys and values are case-insensitive.<br />
Valid encoding settings can be found at http://www.iana.org/assignments/character-sets<br />
XDOMWrite Parameters (continued)
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
Return Code Description<br />
XML.SUCCESS Function completed successfully.<br />
XML.ERROR An error occurred.<br />
If an error is encountered in xmlOptions,<br />
XMLGetError() returns one of the following<br />
error codes:<br />
38 Invalid XML config key: ’key_name’<br />
39 Invalid XML config value: ’value_string’<br />
40 Invalid XML config format:<br />
’name_value_string’<br />
XML.INVALID.HANDLE Invalid DOM handle passed to the function.<br />
XDOMWrite Return Codes<br />
XDOMWrite 1-985
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
XLATE<br />
Syntax<br />
XLATE(filename, rec.id.expr, attrib.expr, "code")<br />
Description<br />
The <strong>UniBasic</strong> XLATE function returns the contents of an attribute, and takes<br />
additional action if the record does not exist or the attribute is empty.<br />
This function performs the same action as the TRANS virtual attribute function.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-986 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
filename Specifies the name of a file from which to return the contents of an<br />
attribute. file.expr must be the name of a valid UniData file, not the value<br />
of a file variable, even if the same file was opened within the program.<br />
rec.id.expr Specifies a record ID in file.expr.<br />
attrib.expr Specifies a valid attribute in file.expr.<br />
"code" Enter a code specifying action to be taken if the record does not exist or<br />
the attribute is empty:<br />
C – Substitutes the id.expr for the value of the function.<br />
V – Returns an empty string and prints an error message.<br />
X – Returns an empty string.<br />
XLATE Parameters
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Related Command<br />
UniData<br />
TRANS – For information, see Using UniData.<br />
XLATE 1-987
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
XMAPAppendRec<br />
Syntax<br />
XMAPAppendRec(XMAPhandle, file_name, record)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The XMAPAppendRec function formats the specified record from the UniData file<br />
as a U2XMAP dataset record and appends it to the U2XMAP dataset.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
1-988 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
XMAPhandle The handle to the U2XMAP dataset.<br />
The XMAPhandle parameter uses the in-encoding parameter set<br />
in the system-level or account-level xmlconfig file, the XMLSE-<br />
TOPTIONS command, or the XMLSetOptions() API for the<br />
input record value.<br />
file_name The name of the UniData file that is being mapped in the<br />
U2 XMAP dataset<br />
record The data record formatted according to the dictionary<br />
record of the UniData file.<br />
XMAPAppendRec Parameters
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Return Values<br />
The following table describes the return values of the XMAPAppendRec function.<br />
Return Value Description<br />
XML_SUCCESS The XML document was opened successfully.<br />
XML_ERROR An error occurred opening the XML document.<br />
XML_INVALID_HANDLE The XMAP dataset was invalid.<br />
XMAPAppendRec Return Values<br />
XLATE 1-989
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
XMAPClose<br />
Syntax<br />
XMAPClose(XMAPhandle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The XMAPClose function closes the U2XMAP dataset handle and frees all related<br />
structures and memory.<br />
Parameter<br />
The following table describes the parameter of the syntax.<br />
Parameter Description<br />
Return Values<br />
The following table describes the return values from the XMAPClose function.<br />
1-990 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
XMAPhandle The handle to the U2XMAP dataset.<br />
XMAPClose Parameter<br />
Return Value Description<br />
XML_SUCCESS The XML document was closed successfully.<br />
XML_ERROR An error occurred closing the XML document.<br />
XML_INVALID_HANDLE The XMAP dataset was invalid.<br />
XMAPClose Return Values
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XMAPCreate<br />
Syntax<br />
XMAPCreate(u2xmapping_rules, mapping_flag, XMAPhandle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The XMAPCreate function creates an empty XML document for transferring data<br />
from the UniData database to XML according the mapping rules you define.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
u2xmapping_rules The name of the U2XMAP file, or the <strong>UniBasic</strong> variable<br />
containing the XML to Database mapping rules.<br />
mapping_flag A flag indicating if the mapping file is the U2XMAP file itself<br />
or a string located within the <strong>UniBasic</strong> program. Valid values<br />
are:<br />
XMAP.FROM.FILE - the mapping rules are contained in a<br />
U2XMAP file.<br />
XMAP.FROM.STRING - u2xmapping_rules is the name of<br />
the variable containing the mapping rules.<br />
XMAPhandle The handle to the XMAP dataset.<br />
XMAPCreate Parameters<br />
XMAPCreate 1-991
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
The following table describes the return values for the XMAPCreate function.<br />
1-992 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Value Description<br />
XML_SUCCESS The XML document was opened successfully.<br />
XML_ERROR An error occurred opening the XML document.<br />
XML_INVALID_HANDLE The XMAP dataset was invalid.<br />
XMAPCreate Return Values
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XMAPOpen<br />
Syntax<br />
XMAPOpen(xml_document, doc_flag, u2xmapping_rules, u2xmap_flag,<br />
XMAPhandle)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The XMAPOpen function opens an XML document as a U2XMAP data set.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
xml_document The name of the XML document.<br />
doc_flag A flag defining the type of xml_document. Valid values are:<br />
XML.FROM.DOM - xml_document is a DOM handle.<br />
XML.FROM.FILE - xml_document is a file name.<br />
XML.FROM.STRING -xml_document is the name of<br />
variable containing the XML document.<br />
XMAPOpen Parameters<br />
XMAPOpen 1-993
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Parameter Description<br />
Return Values<br />
The following table describes the return values for the XMAPOpen function.<br />
1-994 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
u2xmapping_rules The name of the U2XMAP file, or the <strong>UniBasic</strong> variable<br />
containing the XML to Database mapping rules.<br />
u2xmap_flag A flag indicating if the mapping file is the U2XMAP file itself<br />
or a string located within the <strong>UniBasic</strong> program. Valid values<br />
are:<br />
XMAP.FROM.FILE - the mapping rules are contained in a<br />
U2XMAP file.<br />
XMAP.FROM.STRING - u2xmap_flag is the name of the<br />
variable containing the mapping rules.<br />
XMAPhandle The handle to the XMAP dataset.<br />
This API registers the current in-encoding and out-encoding<br />
parameters in the XMAPhandle. These parameters are used<br />
throughout the life of the XMAPhandle.<br />
XMAPOpen Parameters (continued)<br />
Return Value Description<br />
XML_SUCCESS The XML document was opened successfully.<br />
XML_ERROR An error occurred opening the XML document.<br />
XMAPOpen Return Values
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XMAPReadNext<br />
Syntax<br />
XMAPReadNext(XMAPhandle, file_name, record)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The XMAPReadNext function retrieves the next record from the U2XMAP dataset<br />
and formats it as a record of the UniData file that is being mapped.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
XMAPhandle The U2XMAP dataset handle.<br />
The XMAPhandle parameter uses the out-encoding parameter set in the<br />
system-level or account-level xmlconfig file, the XMLSETOPTIONS<br />
command, or the XMLSetOptions() API for the record value.<br />
file_name The name of the UniData file that is being mapped in the U2XMAP<br />
dataset.<br />
record The data record formatted according to the dictionary record of the file.<br />
XMAPReadNext Parameters<br />
XMAPReadNext 1-995
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Return Values<br />
The following table describes the return values for the XMAPReadNext function.<br />
1-996 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Return Value Description<br />
XML_SUCCESS The XMAPReadNext was executed successfully.<br />
XML_ERROR Error in executing XMAPReadNext.<br />
XML_INVALID_HANDLE U2 XMAP dataset handle was invalid.<br />
XML_EOF The end of the U2XMAP dataset has been reached.<br />
XMAPReadNext Return Values
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XMAPToXMLDoc<br />
Syntax<br />
XMAPToXMLDoc(XMAPhandle, xmlfile, doc_flag[, xmlOptions])<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The XMAPToXMLDoc function generates an XML document from the data in the<br />
U2XMAP dataset using the mapping rules you define. The XML document can be<br />
either an XML DOM handle or an XML document. UniData writes the data to a file<br />
or a <strong>UniBasic</strong> variable.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
XMAPhandle The handle to the U2XMAP dataset.<br />
XMAPToXMLDoc Parameters<br />
XMAPToXMLDoc 1-997
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Parameter Description<br />
1-998 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
xmlfile The name of the XML file, or the name of a <strong>UniBasic</strong> variable to hold the<br />
XML document.<br />
doc_flag Indicates where to write the XML document. Valid values are:<br />
XML.TO.DOM - Writes the XML document to an XML DOM handle.<br />
XML.TO.FILE - Writes the XML document to a file.<br />
XML.TO.STRING - Writes the XML document to a <strong>UniBasic</strong> variable.<br />
xmlOptions A string specifying the key/value pairs of the XML options to be used in the<br />
XML document generated by this function. [IN]<br />
The string can be entered in either of the following formats:<br />
"encoding=ISO-8859-1 standalone=yes newline=CR-LF"<br />
or<br />
‘encoding="iso-8859-1" standalone="no"’<br />
The XML options are the same as those in the xmlconfig file and accept the<br />
same values. Keys and values are case-insensitive.<br />
Valid encoding settings can be found at http://www.iana.org/assignments/character-sets<br />
XMAPToXMLDoc Parameters (continued)
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Return Values<br />
The following table describes the return values of the XMAPToXMLDoc function.<br />
Return Value Description<br />
XML_SUCCESS The XML document was opened successfully.<br />
XML_ERROR An error occurred opening the XML document.<br />
If an error is encountered in xmlOptions, XMLGetError()<br />
returns one of the following error codes:<br />
38 Invalid XML config key: ‘key_name’<br />
39 Invalid XML config value: ‘value_string’<br />
40 Invalid XML config format: ‘name_value_string’<br />
XML_INVALID_HANDLE The XMAP dataset was invalid.<br />
XMAPToXMLDoc Return Values<br />
XMAPToXMLDoc 1-999
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
XMLError<br />
Syntax<br />
XMLError(errmsg)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
Use the XMLError function to get the last error message.<br />
Errmsg is the error message string, or one of the following return values:<br />
1-1000 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
XML.SUCCESS Success<br />
XML.ERROR Failure
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XMLExecute<br />
Syntax<br />
XMLExecute(cmd, options, xmlvar, xsdvar)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
The XMLExecute function enables you to create an XML document using the<br />
UniQuery LIST statement or the UniData SQL SELECT statement from a <strong>UniBasic</strong><br />
program.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
cmd Holds the text string of the UniQuery LIST statement or the UniData SQL<br />
SELECT statement. [IN]<br />
options Each XML-related option is separated by a field mark (@FM). If the<br />
option requires a value, the values are contained in the same field,<br />
separated by value marks (@VM).<br />
WITHDTD Creates a DTD and binds it with the XML<br />
document. By default, UniData creates an XML<br />
schema. However, if you include WITHDTD in<br />
your UniQuery or UniData SQL statement,<br />
UniData does not create an XML schema, but<br />
only produces the DTD.<br />
ELEMENTS The XML output is in element-centric format.<br />
XMLExecute Parameters<br />
XMLExecute 1-1001
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Parameter Description<br />
1-1002 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
‘XMLMAPPING’:<br />
@VM:’mapping_file_<br />
name’<br />
‘SCHEMA’:@VM:<br />
’type’<br />
Specifies the mapping file containing transformation<br />
rules for display. This file must exist in<br />
the _XML_ directory.<br />
The default schema format is ref type schema.<br />
You can use the SCHEMA attribute to define a<br />
different schema format.<br />
HIDEMV, HIDEMS Normally, when UniData processes multivalued<br />
or multi-subvalued fields, UniData adds another<br />
level of elements to produce multiple levels of<br />
nesting. You have the option of disabling this<br />
additional level by adding the HIDEMV and<br />
HIDEMS attributes. When these options are on,<br />
the generated XML document and the<br />
associated DTD or XML schema have fewer<br />
levels of nesting.<br />
HIDEROOT Allows you to specify to only create a segment<br />
of an XML document, for example, using the<br />
SAMPLE keyword and other conditional<br />
clauses. If you specify HIDEROOT, UniData<br />
only creates the record portion of the XML<br />
document, it does not create a DTD or XML<br />
schema.<br />
‘RECORD’:@VM:<br />
’newrecords’<br />
‘ROOT’:@VM:<br />
’newroot’<br />
The default record name is FILENAME_record.<br />
The record attribute in the ROOT element<br />
changes the record name.<br />
The default root element name in an XML<br />
document is ROOT. You can change the name of<br />
the root element as shown in the following<br />
example:<br />
root=”root_element_name”<br />
XMLExecute Parameters (continued)
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
Parameter Description<br />
Example<br />
TARGETNAM-<br />
ESPACE:@FM:’name<br />
spaceURL’<br />
COLLAPSEMV,<br />
COLLAPSEMS<br />
The following example illustrates the XMLExecute function:<br />
UniData displays the targetnamespace attribute<br />
in the XMLSchema as<br />
targetNamespace, and uses the URL you specify<br />
to define schemaLocation. If you define the<br />
targetnamespace and other explicit namespace<br />
definitions, UniData checks if the explicitly<br />
defined namespace has the same URL and the<br />
targetnamespace. If it does, UniData uses the<br />
namespace name to qualify the schema element,<br />
and the XML document element name.<br />
Normally, when UniData processes multivalued<br />
or multi-subvalued fields, UniData adds another<br />
level of elements to produce multiple levels of<br />
nesting. You have the option of disabling this<br />
additional level by adding the COLLAPSEMV<br />
and COLLAPSE MS attributes. When these<br />
options are on, the generated XML document<br />
and the associated DTD or XML Schema have<br />
fewer levels of nesting.<br />
XmlVar The name of the variable to which to write the generated XML document<br />
[OUT]<br />
XsdVar The name of the variable in which to store the XML Schema if one is<br />
generated along with the XML document. [OUT]<br />
XMLExecute Parameters (continued)<br />
CMD="SELECT SEMESTER,COURSE_NBR FROM STUDENT;"<br />
OPTIONS := "COLLAPSEMS"<br />
OPTIONS := @FM:"HIDEROOT"<br />
OPTIONS := @FM:"root":@VM:"mystudent"<br />
OPTIONS :=@FM:"record":@VM:"myrecord"<br />
OPTIONS :=@FM:"targetnamespace":@VM:"http://www.ibm.com"<br />
OPTIONS := @FM:"elementformdefault"<br />
STATUS = XMLEXECUTE(CMD,OPTIONS,XMLVAR,XSDVAR)<br />
PRINT XSDVAR<br />
PRINT XMLVAR<br />
XMLExecute 1-1003
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
XMLGetError<br />
Syntax<br />
XMLGetError(errorCode, errorMessage)<br />
Note: This function is case-sensitive. If you want it to be case-insensitive, you<br />
must compile your programs using the BASIC command with the -i option.<br />
Description<br />
XMLGetError gets the error code and error message after the previous XML API<br />
failed.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Return Codes<br />
The return code indicating success or failure. The following table describes the value<br />
of each return code.<br />
1-1004 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Parameter Description<br />
errorCode The error code. [OUT]<br />
errorMessage The error message. [OUT]<br />
XMLGetError Parameters<br />
Return Code Description<br />
XML.SUCCESS The function completed successfully.<br />
XML.ERROR An error occurrred.<br />
XDOMGetError Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XMLGetOptions<br />
Syntax<br />
XMLGetOptions(outOptions[, delimiterString])<br />
Description<br />
Use this function in <strong>UniBasic</strong> programs to return the values for encoding and other<br />
XML options in effect in the current UniData session.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
outOptions A variable used to retrieve the XML options key/value pairs in<br />
effect in the current UniData session. [OUT]<br />
delimiterString Optional. Specifies the string to be used to separate the key/value<br />
pairs returned by the command. By default, delimiterString is a<br />
space. [IN]<br />
XMLGetOptions Parameters<br />
Examples<br />
The following example shows the format for entering delimiterString as the string<br />
used to separate the key/value pairs returned by the function. Key/value pairs can be<br />
separated by a space or by any string, such as , as shown in this example:<br />
(xmlOptions, "")<br />
encoding=defaultin-encoding=UTF-8version=1.1standalone=no<br />
out-xml-declaration=trueout-format-pretty-print=falseoutnormalize-characters=trueout-split-cdata-sections=trueoutvalidation=falseout-expand-entity-references=falseoutwhitespace-in-element-content=trueout-discard-defaultcontent=trueout-format-canonical=trueout-write-bom=false<br />
XMLGetOptions 1-1005
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
If you enter the XMLGetOptions function with no delimiterString, the key/value<br />
pairs are separated by a space, as shown in the next example:<br />
XMLGetOptions(xmlOptions)<br />
1-1006 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
encoding=default in-encoding=UTF-8 version=1.1 standalone=no outxml-declaration=true<br />
out-format-pretty-print=false out-normalizecharacters=true<br />
out-split-cdata-sections=true out-validation=false<br />
out-expand-entity-references=false out-whitespace-in-elementcontent=true<br />
out-discard-default-content=true out-formatcanonical=true<br />
out-write-bom=false<br />
Return Codes<br />
The return code indicates the status on completion of this function. The following<br />
table describes each return code.<br />
Return Code Description<br />
XML.SUCCESS Function completed successfully.<br />
XMLGetOptions Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XMLGetOptionValue<br />
Syntax<br />
XMLGetOptionValue(optionName, outOptionValue)<br />
Description<br />
Use this function in <strong>UniBasic</strong> programs to return the value of encoding or any other<br />
XML option in effect in the current UniData session.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
optionName The name of the XML option for which you want to retrieve the<br />
current value. [IN]<br />
The XML options are the same as those in the xmlconfig file.<br />
outOptionValue A variable used to retrieve the value of the specified XML option<br />
in the current UniData session. [OUT]<br />
XMLGetOptionValue Parameters<br />
Example<br />
The following example shows the format for entering the optionName and outOptionValue<br />
variables:<br />
XMLGetOptionValue("encoding", xmlOptionValue)<br />
This function returns the value of the encoding option in the second argument,<br />
xmlOptionValue.<br />
XMLGetOptionValue 1-1007
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Return Codes<br />
The return code indicates success or failure. The following table describes each<br />
return code.<br />
Return Code Description<br />
1-1008 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
XML.SUCCESS Function completed successfully.<br />
XML.ERROR When the return status is XML.ERROR, XMLGetError() returns<br />
the following error code:<br />
38 Invalid XML config key: ‘key_name’<br />
XMLGETOPTIONVALUE Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XMLSetOptions<br />
Syntax<br />
XMLSetOptions("options")<br />
Description<br />
Use this function in <strong>UniBasic</strong> programs to set the encoding parameter and other XML<br />
options in the current UniData session. The settings specified in this API override the<br />
settings in the system-level and account-level xmlconfig files and in ECL commands<br />
during the current session.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
options A string in the format of space-delimited key/value pairs. [IN]<br />
The XML options are the same as those in the xmlconfig file and<br />
accept the same values. Keys and values are case-insensitive.<br />
The XMLSetOptions function also accepts three special strings as<br />
the options parameter.<br />
defaults – Sets all XML options to their default settings in<br />
the current session.<br />
reload – Reloads the current system-level and account-level<br />
xmlconfig files, since they may have changed after you started<br />
your UniData session.<br />
reset – Resets XML options to the original settings that were<br />
loaded when you started the UniData session.<br />
A special string must be entered as the only option.<br />
XMLSetOptions Parameters<br />
XMLSetOptions 1-1009
C:\Program Files\Adobe\FrameMaker8\UniData 7.2\7.2rebranded\BASICREF\BASRX.fm<br />
3/5/10<br />
Examples<br />
The following example shows the format for entering the XML options in this API.<br />
1-1010 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
XMLSetOptions("encoding=iso-8859-1 newline=CR-LF")<br />
The next example shows the format for entering a special string as the options<br />
parameter:<br />
XMLSetOptions("defaults")<br />
Return Codes<br />
The return code indicates success or failure. The following table describes each<br />
return code.<br />
Return Code Description<br />
XML.SUCCESS Function completed successfully.<br />
XML.ERROR When the return status is XML.ERROR, XMLGetError() returns<br />
one of the following error codes:<br />
38 Invalid XML config key: ‘key_name’<br />
39 Invalid XML config value: ‘value_string’<br />
40 Invalid XML config format: ‘name_value_string’<br />
Note: When the return code is XML.ERROR, none of the<br />
XML parameters are changed.<br />
XMLSetOptions Return Codes
C:\Program<br />
Files\Adobe\FrameMaker8\UniData<br />
XMLTODB<br />
Syntax<br />
XMLTODB(xml_document, doc_flag, u2xmapping_rules, u2xmap_ flag, status)<br />
Description<br />
The XMLTODB function populates the UniData database from <strong>UniBasic</strong>. If you<br />
want to transform specific data, use the XMAP API.<br />
Parameters<br />
The following table describes each parameter of the syntax.<br />
Parameter Description<br />
xml_document The name of the XML document.<br />
doc_flag A flag defining the type of xml_document. Valid values are:<br />
XML.FROM.DOM - xml_document is a DOM handle.<br />
XML.FROM.FILE - xml_document is a file name.<br />
XML.FROM.STRING - xml_document is the name of<br />
variable containing the XML document<br />
u2xmapping_rules The mapping rules for the XML document.<br />
u2xmap_flag A flag indicating if the mapping file is the U2XMAP file itself<br />
or a string located within the <strong>UniBasic</strong> program. Valid values<br />
are:<br />
XMAP.FROM.FILE - the mapping rules are contained in a<br />
U2XMAP file.<br />
XMAP.FROM.STRING - u2xmap_flag is the name of the<br />
variable containing the mapping rules.<br />
Status The return status.<br />
XMAPOpen Parameters<br />
XMLTODB 1-1011
ASCII Character<br />
Codes<br />
This appendix describes each ASCII (American Standard Code for<br />
Information Interchange) code.<br />
ASCII Value Character<br />
000 NUL 0<br />
001 SOH 1<br />
002 STX 2<br />
003 ETX 3<br />
004 EOT 4<br />
005 ENQ 5<br />
006 ACK 6<br />
007 BEL 7<br />
008 BS 8<br />
009 HT 9<br />
010 LF A<br />
011 VT B<br />
012 FF C<br />
013 CR D<br />
014 SO E<br />
ASCII Character Codes<br />
Hex<br />
Character<br />
Appendix<br />
A
ASCII Value Character<br />
015 SI F<br />
016 DLE 10<br />
017 DC1 11<br />
018 DC2 12<br />
019 DC3 13<br />
020 DC4 14<br />
021 NAK 15<br />
022 SYN 16<br />
023 ETB 17<br />
024 CAN 18<br />
025 EM 19<br />
026 SUB 1A<br />
027 ESC 1B<br />
028 FS 1C<br />
029 GS 1D<br />
030 RS 1E<br />
031 US 1F<br />
032 (space) 20<br />
033 ! 21<br />
034 " 22<br />
035 # 23<br />
036 $ 24<br />
037 % 25<br />
ASCII Character Codes (continued)<br />
Hex<br />
Character<br />
A-2
A-3 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ASCII Value Character<br />
038 & 26<br />
039 ’ 27<br />
040 ( 28<br />
041 ) 29<br />
042 * 2A<br />
043 + 2B<br />
044 , 2C<br />
045 - 2D<br />
046 . 2E<br />
047 / 2F<br />
048 0 30<br />
049 1 31<br />
050 2 32<br />
051 3 33<br />
052 4 34<br />
053 5 35<br />
054 6 36<br />
055 7 37<br />
056 8 38<br />
057 9 39<br />
058 : 3A<br />
059 ; 3B<br />
060 < 3C<br />
ASCII Character Codes (continued)<br />
Hex<br />
Character
ASCII Value Character<br />
061 = 3D<br />
062 > 3E<br />
063 ? 3F<br />
064 @ 40<br />
065 A 41<br />
066 B 42<br />
067 C 43<br />
068 D 44<br />
069 E 45<br />
070 F 46<br />
071 G 47<br />
072 H 48<br />
073 I 49<br />
074 J 4A<br />
075 K 4B<br />
076 L 4C<br />
077 M 4D<br />
078 N 4E<br />
079 O 4F<br />
080 P 50<br />
081 Q 51<br />
082 R 52<br />
083 S 53<br />
ASCII Character Codes (continued)<br />
Hex<br />
Character<br />
A-4
A-5 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ASCII Value Character<br />
084 T 54<br />
085 U 55<br />
086 V 56<br />
087 W 57<br />
088 X 58<br />
089 Y 59<br />
090 Z 5A<br />
091 [ 5B<br />
092 \ 5C<br />
093 ] 5D<br />
094 ^ 5E<br />
095 _ 5F<br />
096 ‘ 60<br />
097 a 61<br />
098 b 62<br />
099 c 63<br />
100 d 64<br />
101 e 65<br />
102 f 66<br />
103 g 67<br />
104 h 68<br />
105 i 69<br />
106 j 6A<br />
ASCII Character Codes (continued)<br />
Hex<br />
Character
ASCII Value Character<br />
107 k 6B<br />
108 l 6C<br />
109 m 6D<br />
110 n 6E<br />
111 o 6F<br />
112 p 70<br />
113 q 71<br />
114 r 72<br />
115 s 73<br />
116 t 74<br />
117 u 75<br />
118 v 76<br />
119 w 77<br />
120 x 78<br />
121 y 79<br />
122 z 7A<br />
123 { 7B<br />
124 | 7C<br />
125 } 7D<br />
126 ~ 7E<br />
127 DEL 7F<br />
128 Ç 80<br />
129 ü 81<br />
ASCII Character Codes (continued)<br />
Hex<br />
Character<br />
A-6
A-7 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ASCII Value Character<br />
130 é 82<br />
131 â 83<br />
132 ä 84<br />
133 à 85<br />
134 å 86<br />
135 ç 87<br />
136 ê 88<br />
137 ë 89<br />
138 è 8A<br />
139 ï 8B<br />
140 î 8C<br />
141 ì 8D<br />
142 Ä 8E<br />
143 Å 8F<br />
144 É 90<br />
145 æ 91<br />
146 Æ 92<br />
147 ô 93<br />
148 ö 94<br />
149 ò 95<br />
150 û 96<br />
151 ù 97<br />
152 ÿ 98<br />
ASCII Character Codes (continued)<br />
Hex<br />
Character
ASCII Value Character<br />
153 Ö 99<br />
154 Ü 9A<br />
155 ¢ 9B<br />
156 £ 9C<br />
157 ¥ 9D<br />
158 ¤ 9E<br />
159 ƒ 9F<br />
160 á A0<br />
161 í A1<br />
162 ó A2<br />
163 ú A3<br />
164 ñ A4<br />
165 Ñ A5<br />
166 ª A6<br />
167 º A7<br />
168 ¿ A8<br />
169 “ A9<br />
170 ” AA<br />
171 ‹ AB<br />
172 › AC<br />
173 ¡¦ AD<br />
174 « AE<br />
175 » AF<br />
ASCII Character Codes (continued)<br />
Hex<br />
Character<br />
A-8
A-9 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ASCII Value Character<br />
176 ã B0<br />
177 õ B1<br />
178 Ø B2<br />
179 ø B3<br />
180 œ B4<br />
181 Œ B5<br />
182 À B6<br />
183 Ã B7<br />
184 Õ B8<br />
185 § B9<br />
186 ‡ BA<br />
187 † BB<br />
188 BC<br />
189 © BD<br />
190 ® BE<br />
191 BF<br />
192 „ C0<br />
193 … C1<br />
194 ‰ C2<br />
195 • C3<br />
196 – C4<br />
197 — C5<br />
198 ° C6<br />
ASCII Character Codes (continued)<br />
Hex<br />
Character
ASCII Value Character<br />
199 Á C7<br />
200 Â C8<br />
201 È C9<br />
202 Ê CA<br />
203 Ë CB<br />
204 Ì CC<br />
205 Í CD<br />
206 Î CE<br />
207 Ï CF<br />
208 Ò D0<br />
209 Ó D1<br />
210 Ô D2<br />
211 nonprinting D3<br />
212 nonprinting D4<br />
213 Ù D5<br />
214 Ú D6<br />
215 Û D7<br />
216 Ÿ D8<br />
217 ß D9<br />
218 nonprinting DA<br />
219 nonprinting DB<br />
220 nonprinting DC<br />
221 nonprinting DD<br />
ASCII Character Codes (continued)<br />
Hex<br />
Character<br />
A-10
A-11 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
ASCII Value Character<br />
222 nonprinting DE<br />
223 nonprinting DF<br />
224 nonprinting E0<br />
225 nonprinting E1<br />
226 nonprinting E2<br />
227 nonprinting E3<br />
228 nonprinting E4<br />
229 nonprinting E5<br />
230 nonprinting E6<br />
231 nonprinting E7<br />
232 nonprinting E8<br />
233 nonprinting E9<br />
234 nonprinting EA<br />
235 nonprinting EB<br />
236 nonprinting EC<br />
237 nonprinting ED<br />
238 nonprinting EE<br />
239 nonprinting EF<br />
240 nonprinting F0<br />
241 nonprinting F1<br />
242 nonprinting F2<br />
243 nonprinting F3<br />
244 nonprinting F4<br />
ASCII Character Codes (continued)<br />
Hex<br />
Character
ASCII Value Character<br />
245 nonprinting F5<br />
246 nonprinting F6<br />
247 nonprinting F7<br />
248 nonprinting F8<br />
249 nonprinting F9<br />
250 nonprinting FA<br />
251 text mark FB<br />
252 subvalue<br />
mark<br />
FC<br />
253 value mark FD<br />
254 attribute mark FE<br />
255 record mark FF<br />
ASCII Character Codes (continued)<br />
Hex<br />
Character<br />
A-12
<strong>UniBasic</strong>@variables<br />
This appendix lists the @variables available in <strong>UniBasic</strong>, the delimiter<br />
@variables, and the codes returned by @SYSTEM.RETURN.CODE.<br />
Appendix<br />
B
@variables<br />
The following table describes the valid @variables.<br />
@variable Description<br />
@ACCOUNT Returns the operating system path where you first entered<br />
UniData. Note that the value of @ACCOUNT does not change<br />
when a LOGTO statement is executed.<br />
@AM Inserts an attribute mark at compile time.<br />
For information about other system delimiter @ variables, see<br />
“Delimiter @variables” in this appendix.<br />
@COMMAND Last UniData command executed. Changes the value for each<br />
statement executed at the UniData ECL prompt ( : ) and in the<br />
<strong>UniBasic</strong> EXECUTE statement.<br />
@CONV Used with CALCULATE and the braces {} function. Returns<br />
the conversion code from a dictionary item.<br />
@CRTHIGH Height of the CRT screen.<br />
@CRTWIDE Width of the CRT screen.<br />
@DATA DATA statements used in conjunction with INPUT statements<br />
are stored in a data stack or input queue. This stack is accessible<br />
in the @DATA variable. Data elements are delimited by ASCII<br />
013 (CR). @DATA is a READ ONLY variable.<br />
@DATE System date, in internal format, when the program began<br />
executing.<br />
@DAY Two-digit day of the month.<br />
@DICT Current dictionary (must perform an assignment).<br />
@FORMAT Used with CALCULATE and the braces {} function. Returns<br />
the format code from a dictionary item.<br />
@GID For UNIX, returns the group ID assigned to a user. For<br />
Windows NT or Windows 2000, returns a string that contains<br />
all the group names (separated by value marks) to which the<br />
user belongs.<br />
@variables<br />
B-2
B-3 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
@variable Description<br />
@HEADER Used with CALCULATE and the braces {} function. Returns<br />
the column heading from a dictionary item.<br />
@ID Current record ID.<br />
@LASTVERB Stores the last executed command.<br />
@LEVEL Current PERFORM or EXECUTE level.<br />
@LOGNAME Returns the user’s login name.<br />
@LPTRHIGH Page length (height) of the system line printer.<br />
@LPTRWIDE Page width of the system line printer.<br />
@MONTH Two-digit representation of the current month.<br />
@PARASENTENCE The last paragraph or sentence entered. It retains the name and<br />
parameters of the current executing paragraph. If no paragraph<br />
is being executed, an empty string is returned. If another<br />
paragraph is called within the first paragraph executed, the<br />
returned value is of the called paragraph until control is<br />
returned to the calling paragraph.<br />
@PATH Current operating system path for the directory where the user<br />
resides. The value of @PATH changes with the LOGTO<br />
command.<br />
@RECORD Current record (must be assigned).<br />
@RECUR0<br />
@RECUR1<br />
@RECUR2<br />
@RECUR3<br />
@RECUR4<br />
Recursive user defined. @RECUR# variables are reset at the<br />
ECL prompt.<br />
@RM Inserts a record mark at compile time.<br />
For information about other system delimiter @ variables, see<br />
“Delimiter @variables” in this appendix.<br />
@variables (continued)
@variable Description<br />
@SENTENCE The statement that invoked the current <strong>UniBasic</strong> program in<br />
progress. Reflects the last command entered at the ECL prompt<br />
or in a paragraph or sentence executed by a <strong>UniBasic</strong> program.<br />
Each <strong>UniBasic</strong> EXECUTE and CHAIN statement also resets<br />
@SENTENCE.<br />
@SM Inserts a subvalue mark (same as @SVM) at compile time.<br />
For information about other delimiter variables, see “Delimiter<br />
@variables” in this appendix.<br />
@SVM Inserts a subvalue mark (same as @SM) at compile time.<br />
For information about other system delimiter @ variables, see<br />
“Delimiter @variables” in this appendix.<br />
@SYS.BELL Enables or disables a user’s terminal bell.<br />
@SYSTEM.RETURN.<br />
CODE<br />
Returns a value indicating a condition or error after the<br />
execution of an ECL command. For most commands, 0<br />
indicates the command was completed correctly, and -1<br />
indicates that the command was not completed correctly.<br />
For more information, see “@SYSTEM.RETURN.CODE<br />
Values” in this appendix.<br />
@TIME The time (in internal format) when the first program in the call<br />
string program.<br />
@TM Inserts a text mark at compile time. The text mark has no direct<br />
effect, but can be used by <strong>UniBasic</strong> programs.<br />
For information about other system delimiter @ variables, see<br />
“Delimiter @variables” in this appendix.<br />
@TRANSACTION Returns 1 if there is a transaction occurring, and returns 0 if<br />
there is no transaction occurring.<br />
@TTY Returns the terminal port name, such as tty01, tty1a, or console.<br />
@UDTNO Returns an integer between 1 and the maximum number of<br />
users allowed on the system. Numbers are assigned sequentially<br />
based on the sequence of entry into UniData. Phantom<br />
processes are counted.<br />
@UID The operating system user ID number for the user.<br />
@variables (continued)<br />
B-4
@USER0<br />
@USER1<br />
@USER2<br />
@USER3<br />
@USER4<br />
B-5 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
@variable Description<br />
User-defined. @USER# variables retain their value throughout<br />
a user session unless the values are explicitly changed.<br />
@USERNO Current udt process ID number.<br />
@USER.RETURN.CO<br />
DE<br />
User-defined.<br />
@USER.TYPE Returns the type of process currently running. <strong>UniBasic</strong> has<br />
three types of processes:<br />
0 – Normal terminal processes.<br />
1 – Background (phantom) processes.<br />
2 – Redirected standard input.<br />
@VM Inserts a value mark at compile time.<br />
For information about other delimiter @variables, see<br />
“Delimiter @variables” in this appendix.<br />
@WHO Retrieves your current directory. For example, if you are in<br />
UNIX directory /u/ud/AP, the value of @WHO is AP.<br />
@YEAR Two-digit representation of the year.<br />
@variables (continued)
Delimiter @variables<br />
The following @variables are replaced by the compiler with dynamic arrays delimiters.<br />
Use the same @variables to place delimiters in UniData hashed files.<br />
@variable Description<br />
@AM Attribute mark<br />
@VM Value mark<br />
@SM Subvalue mark<br />
@RM Record mark<br />
@TM Text mark<br />
@SVM Subvalue mark (same as @SM)<br />
Delimiter @variables<br />
B-6
B-7 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
@SYSTEM.RETURN.CODE Values<br />
@SYSTEM.RETURN.CODE returns various values based on the last command<br />
executed. @SYSTEM.RETURN.CODE is available in <strong>UniBasic</strong>, and is set by many<br />
commands, both <strong>UniBasic</strong> and ECL.<br />
ECL @SYSTEM.RETURN.CODE Values<br />
The following table describes the possible @SYSTEM.RETURN.CODE values for<br />
various ECL commands.<br />
Command Success Return Value Error Return Value<br />
BSELECT The number of items in the<br />
select list.<br />
BUILD.INDEX The number of indexes built. -1<br />
COMPILE.DICT 0 -1<br />
CREATE.INDEX The number of indexes created. -1<br />
DELETE.INDEX The number of indexes deleted. -1<br />
ESEARCH The number of items in the<br />
select list.<br />
FORM.LIST The number of items in the<br />
select list.<br />
GET.LIST The number of items in the<br />
select list.<br />
LIST The number of items listed. -1<br />
LIST.INDEX The number of indexes listed. -1<br />
LIST.ITEM The number of items listed. -1<br />
LIST.LABEL The number of items listed. -1<br />
ECL @SYSTEM.RETURN.CODE Values<br />
-1<br />
-1<br />
-1<br />
-1
Command Success Return Value Error Return Value<br />
LOCK 0 -1 if you specify an<br />
invalid lock number.<br />
-2 if the resource is<br />
locked by another<br />
user.<br />
MERGE.LIST The number of items in the<br />
select list.<br />
MODIFY The number of records<br />
modified.<br />
NSELECT The number of items in the<br />
select list.<br />
QSELECT The number of items in the<br />
select list.<br />
SAVE.LIST The number of items saved. -1<br />
SELECT The number of items in the<br />
select list.<br />
SORT The number of items listed. -1<br />
SORT.ITEM The number of items listed. -1<br />
SORT.LABEL The number of items listed. -1<br />
SSELECT The number of items in the<br />
select list.<br />
STACKCOMMON 1 – On<br />
0 – Off<br />
-1<br />
-1<br />
0<br />
-1<br />
-1<br />
-1<br />
N/A<br />
ECL @SYSTEM.RETURN.CODE Values (continued)<br />
B-8
B-9 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
<strong>UniBasic</strong> @SYSTEM.RETURN.CODE Values<br />
The following table describes the possible @SYSTEM.RETURN.CODE values for<br />
<strong>UniBasic</strong> commands..<br />
Command Success Return Value Error Return Value<br />
GETQUEUE The number of locks waiting to<br />
be released.<br />
GETREADU The number of locks set. -1<br />
INPUT (with FOR or<br />
WAITING clause<br />
included)<br />
INPUT @ (with FOR or<br />
WAITING clause<br />
included)<br />
0 -1 (used if timeout<br />
option is set; INPUT<br />
timed out)<br />
0 -1 (used if timeout<br />
option is set; INPUT<br />
timed out)<br />
PCPERFORM 0 -1<br />
ECL @SYSTEM.RETURN.CODE Values<br />
-1
Operators in <strong>UniBasic</strong><br />
This appendix describes the arithmetic, Boolean, and relational<br />
operators available you can use in <strong>UniBasic</strong>.<br />
Appendix<br />
C
C-2 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Arithmetic Operators<br />
The following table describes the arithmetic operators for <strong>UniBasic</strong>.<br />
Operator Action Example Related Function<br />
+ Unary plus (same as<br />
multiplying by +1).<br />
- Unary minus<br />
(changes to the<br />
opposite sign, same as<br />
multiplying by<br />
-1).<br />
VAR = +VAR ABS<br />
VAR = -VAR NEG<br />
+ Addition. X = VAR1 + VAR2<br />
VAR = VAR + 1<br />
- Subtraction. X = VAR1 - VAR2<br />
VAR = VAR - 1<br />
SADD, SUM<br />
SSUB<br />
* Multiplication. X = VAR1 * VAR2 SMUL<br />
/ Division. QUANTITY =<br />
PRICE/COST<br />
SDIV<br />
** or ^ Exponentiation. X = VAR^2 PWR<br />
:, CAT Concatenation. X = VAR1:VAR2<br />
+= Increments the value<br />
of a variable.<br />
-= Decrements the value<br />
of a variable.<br />
LINES += 1<br />
LINES -= 1<br />
Arithmetic Operators
Operator Action Example Related Function<br />
*= Multiplies the value<br />
to the left of the<br />
operator by the value<br />
to the right of the<br />
operator.<br />
/= Divides the value to<br />
the left of the operator<br />
by the value to the<br />
right of the operator.<br />
:= Concatenates the<br />
value to the left of the<br />
operator by the value<br />
to the right of the<br />
operator.<br />
VAR1 *= VAR2<br />
VAR1 /= VAR2<br />
VAR1 := VAR2<br />
Arithmetic Operators (continued)<br />
Note: You must include the REUSE function to apply arithmetic operations to all<br />
elements of a dynamic array.<br />
C-3
C-4 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Boolean Operators<br />
The following table describes the Boolean operators for <strong>UniBasic</strong>.<br />
Operator Action Example<br />
AND, & When both expressions<br />
are true, the<br />
result is true.<br />
OR, ! When either<br />
expression is true, the<br />
result is true.<br />
NOT Inverts the result of<br />
conditional<br />
statements.<br />
NOTS Inverts the logical<br />
result of each element<br />
of a dynamic array.<br />
IF (X < Y) AND (Y < Z) THEN GOSUB<br />
1000<br />
IF (X < Y) OR (Y < Z) THEN GOSUB<br />
1000<br />
IF (X < Y) AND NOT (Y < z) GOSUB<br />
1000<br />
A = 1:@FM:0:@FM:1:@FM:30<br />
B = NOTS(A)<br />
B contains 0}1}0}0.<br />
Boolean Operators
Relational Operators<br />
The following table describes the relational operators for <strong>UniBasic</strong>.<br />
Operator<br />
Multivalued<br />
Equivalent Description Example<br />
=, EQ EQS Equal to. IF VAR1 = VAR2<br />
THEN GOSUB SUB1<br />
DO UNTIL VAR1 =<br />
VAR2<br />
#, , > Y THEN<br />
GOSUB 1000<br />
>, GT GTS Greater than. IF VAR1 > VAR2<br />
THEN GOSUB SUB1<br />
DO UNTIL VAR1 ><br />
VAR2<br />
=, =>, #= VAR2<br />
THEN GOSUB SUB1<br />
DO UNTIL VAR1<br />
=> VAR2<br />
Reserved Words<br />
This appendix lists the reserved keywords, commands, functions, and<br />
@variables. Do not use any of them for subroutine names or for<br />
<strong>UniBasic</strong> variable names.<br />
Reserved Words<br />
$BASICTYPE $DEFINE<br />
$F $FALSE<br />
$IFDEF $IFNDEF<br />
$INCLUDE $INSERT<br />
$T $TRUE<br />
$UNDEFINE @<br />
@ACCOUNT @COMMAND<br />
@CONV @CRTHIGH<br />
@CRTWIDE @DATA<br />
@DATE @DAY<br />
@DICT @FALSE<br />
@FORMAT @GID<br />
@HEADER @ID<br />
@LASTVERB @LEVEL<br />
@LOGNAME @LPTRHIGH<br />
Reserved Words<br />
Appendix<br />
D
Reserved Words<br />
@LPTRWIDE @MONTH<br />
@NULL @PARASENTENCE<br />
@PATH @PROCTYPE<br />
@RECORD @RECUR0<br />
@RECUR1 @RECUR2<br />
@RECUR3 @RECUR4<br />
@SENTENCE @SYS.BELL<br />
@SYSTEM.RETURN.CO<br />
DE<br />
@TIME<br />
@TRANSACTION @TRUE<br />
@TTY @TUPLE<br />
@UDTNO @UID<br />
@USER.RETURN.CODE @USER.TYPE<br />
@USER0 @USER1<br />
@USER2 @USER3<br />
@USER4 @USERNO<br />
@WHO @YEAR<br />
ABORT ABS<br />
ABSOLUTE ACOS<br />
ALPHA AND<br />
APPEND AS<br />
ASCII ASIN<br />
ASSIGN ASYNC<br />
AT ATAN<br />
Reserved Words (continued)<br />
D-2
D-3 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Reserved Words<br />
BEFORE BEGIN<br />
BITAND BITNOT<br />
BITOR BITXOR<br />
BPIOCP BPIOCPN<br />
BREAK BUFFER.KEYS<br />
BY BYTELEN<br />
CALCULATE CALL<br />
CALLC CALLING<br />
CAPTURING CASE<br />
CAT CATS<br />
CHAIN CHANGE<br />
CHAR CHARLEN<br />
CHARS CHECKSUM<br />
CLEAR CLEARCOM<br />
CLEARCOMMON CLEARDATA<br />
CLEARFILE CLEARINPUT<br />
CLEARSELECT CLEARSQL<br />
CLOSE CLOSESEQ<br />
COL1 COL2<br />
COM COMMIT<br />
COMMON COMPILE.DICT.ITEM<br />
CONNECT CONTINUE<br />
CONVERT COS<br />
COUNT COUNTS<br />
Reserved Words (continued)
Reserved Words<br />
CRT CURRENT<br />
DATA DATE<br />
DCOUNT DEBUG<br />
DECLARE DEFFUN<br />
DEL DELETE<br />
DELETELIST DELETEU<br />
DIM DIMENSION<br />
DIR DISCONNECT<br />
DISPLAY DISPLAYWIDTH<br />
DO DOWNCASE<br />
DQUOTE DROUND<br />
DTX EBCDIC<br />
ECHO ELSE<br />
END ENTER<br />
EQ EQS<br />
EQU EQUATE<br />
EXECUTE EXECUTESQL<br />
EXIT EXP<br />
EXTRACT FIELD<br />
FIELDS FIELDSTORE<br />
FILEINFO FILELOCK<br />
FILEUNLOCK FIND<br />
FINDSTR FIRST_ALT_KEY<br />
FLUSH FMT<br />
Reserved Words (continued)<br />
D-4
D-5 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Reserved Words<br />
FMTS FOOTING<br />
FOR FORMLIST<br />
FROM FUNCTION<br />
GARBAGECOLLECT GE<br />
GES GET<br />
GETCOLUMNDATA GETCOLUMNNAME<br />
GETENV GETERRMSG<br />
GETLIST GETMSG<br />
GETNEXTTUPLE GETPTR<br />
GETPU GETQUEUE<br />
GETREADU GETUSERGROUP<br />
GETUSERID GETUSERNAME<br />
GETX GO<br />
GOSUB GOTO<br />
GROUP GROUPSTORE<br />
GT GTS<br />
HASH HEADING<br />
HELP HUSH<br />
ICONV ICONVS<br />
IF IN<br />
INCLUDE INDEX<br />
INDEXS INDICES<br />
INMAT INPUT<br />
INPUTCLEAR INPUTERR<br />
Reserved Words (continued)
Reserved Words<br />
INPUTIF INPUTNULL<br />
INPUTTRAP INS<br />
INSERT INT<br />
ISMB ISNV<br />
ISNVS ISOLATION<br />
ITYPE JRNL_STATUS<br />
LAST_ALT_KEY LE<br />
LEN LENGTH<br />
LENS LES<br />
LINEMARK LN<br />
LOCATE LOCK<br />
LOCKED LOOP<br />
LOWER LT<br />
LTS MAT<br />
MATBUILD MATCH<br />
MATCHES MATCHFIELD<br />
MATPARSE MATREAD<br />
MATREADL MATREADU<br />
MATWRITE MATWRITEU<br />
MAXIMUM MBLEN<br />
MDPERFORM MINIMUM<br />
MOD NE<br />
NEG NES<br />
NEXT NOCONVERT<br />
Reserved Words (continued)<br />
D-6
D-7 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Reserved Words<br />
NODELAY NOT<br />
NOTS NULL<br />
NULLVAL_ALT_KEY NUM<br />
NUMS OCONV<br />
OCONVS OFF<br />
ON OPEN<br />
OPENSEQ OR<br />
OSBREAD OSBWRITE<br />
OSCLOSE OSDELETE<br />
OSOPEN OSREAD<br />
OSWRITE PAGE<br />
PASSCOM PASSCOMMON<br />
PASSLIST PAUSE<br />
PCPERFORM PERFORM<br />
PRECISION PREVIOUS<br />
PRINT PRINTER<br />
PRINTERR PRIOR<br />
PROCREAD PROCWRITE<br />
PROGRAM PROMPT<br />
PWR QUOTE<br />
RAISE READ<br />
READBCK READBCKL<br />
READBCKU READFWD<br />
READFWDL READFWDU<br />
Reserved Words (continued)
Reserved Words<br />
READL READLIST<br />
READNEXT READNEXTTUPLE<br />
READONLY READSEQ<br />
READT READU<br />
READV READVL<br />
READVU READWRITE<br />
READXBCK READXFWD<br />
RECORDLOCKED RECORDLOCKL<br />
RECORDLOCKU RELATIVE<br />
RELEASE REM<br />
REMOVE REPEAT<br />
REPLACE RESIZET<br />
RETURN RETURNING<br />
REUSE REWIND<br />
RND RNDSEED<br />
RQM RTNLIST<br />
SADD SCMP<br />
SDIV SELECT<br />
SELECTINDEX SELECTINFO<br />
SEND SENDX<br />
SEQ SEQS<br />
SETINDEX SETMARK<br />
SETROW SETTABLE<br />
SETTING SIN<br />
Reserved Words (continued)<br />
D-8
D-9 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Reserved Words<br />
SLEEP SMUL<br />
SOUNDEX SPACE<br />
SPACES SPLICE<br />
SQRT SQUOTE<br />
SSUB STATUS<br />
STEP STOP<br />
STR STRS<br />
SUBROUTINE SUBSTRINGS<br />
SUM SWAP<br />
SYNC SYSTEM<br />
TAN THEN<br />
TIME TIMEDATE<br />
TIMEOUT TO<br />
TRANSACTION TRIM<br />
TRIMB TRIMF<br />
TRIMS UDTEXECUTE<br />
UNASSIGNED UNFILTERED<br />
UNLOCK UNTIL<br />
UPCASE USE<br />
USING VALIDATE.KEY<br />
VERB WAIT<br />
WAITING WAKE<br />
WEOF WEOFSEQ<br />
WHILE WITH<br />
Reserved Words (continued)
Reserved Words<br />
WRITE WRITELIST<br />
WRITEONLY WRITESEQ<br />
WRITESEQF WRITET<br />
WRITEU WRITEV<br />
WRITEVU XLATE<br />
XTD<br />
Reserved Words (continued)<br />
D-10
<strong>Commands</strong> Affected<br />
by BASICTYPEs and<br />
UDT.OPTIONS<br />
This appendix lists the <strong>UniBasic</strong> commands and functions that behave<br />
differently or have different syntax depending on the BASICTYPE or<br />
UDT.OPTIONS you have set at the time you compile the program. For<br />
detailed information about how BASICTYPEs or UDT.OPTIONS<br />
affect a particular command or function, see the documentation for that<br />
command or function in this manual. For descriptions of BASIC-<br />
TYPEs, see the <strong>UniBasic</strong> $BASICTYPE command in this manual. For<br />
more detailed information about UDT.OPTIONS, see the<br />
UDT.OPTIONS <strong>Commands</strong> <strong>Reference</strong>.<br />
Appendix<br />
E
Command or<br />
Function<br />
The BASICTYPE Setting<br />
Determines... UDT.OPTIONS<br />
$INCLUDE Whether you can use INCLUDE for<br />
the $INCLUDE command.<br />
[] Whether the [] (square brackets)<br />
function can entirely remove parts or<br />
all of a substring.<br />
ABORT Whether you can specify multiple<br />
messages to display when the<br />
program aborts. The BASICTYPE<br />
setting also determines whether you<br />
can specify a message ID that<br />
evaluates to a key in the UniData<br />
error message file.<br />
CALLC N/A 88<br />
N/A<br />
N/A<br />
CHAIN N/A 6, 11, 27, 40, 54<br />
CLEAR Whether the CLEAR command can<br />
set all variables in unnamed common<br />
areas to 0.<br />
COMMON Whether zero elements are<br />
maintained in arrays. The<br />
BASICTYPE setting also determines<br />
whether you can use the PASSCOM<br />
option.<br />
COUNT Whether the COUNT function can<br />
find overlapping character substrings<br />
in a string.<br />
COUNTS Whether the COUNTS function can<br />
find overlapping character substrings<br />
in an array of strings.<br />
8<br />
N/A<br />
N/A<br />
N/A<br />
N/A<br />
CRT N/A 5, 46<br />
DATA N/A 11, 27<br />
DEBUG N/A 14<br />
<strong>Commands</strong> and Functions Affected by BASICTYPEs and UDT.OPTIONS<br />
E-2
Command or<br />
Function<br />
E-3 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
The BASICTYPE Setting<br />
Determines... UDT.OPTIONS<br />
DISPLAY N/A 5, 46<br />
DIM Whether excess data (including<br />
delimiters) resulting from redimensioning<br />
an array can be placed in<br />
position 0,0 of the dimensioned<br />
array.<br />
EBCDIC Whether ASCII data is converted to<br />
EBCDIC before it is written to tape.<br />
ECHO N/A 99<br />
ENTER N/A 78<br />
EXECUTE Whether commands are parsed by<br />
using the standard UniData parser or<br />
the P-type parser.<br />
EXECUTESQL N/A 35<br />
FLUSH N/A 46<br />
FMT How the data is formatted (in cases<br />
for which the BASICTYPE setting<br />
can produce different results).<br />
N/A<br />
N/A<br />
11, 27, 35, 46, 93, 105<br />
N/A<br />
FOOTING N/A 34, 64<br />
HEADING N/A 32, 34<br />
ICONV Whether the ICONV function returns<br />
an empty string if UDT.OPTIONS 56<br />
is on and the input value or<br />
conversion code is invalid.<br />
ICONVS Whether the ICONVS function<br />
returns an empty string if<br />
UDT.OPTIONS 56 is on and the<br />
input value or conversion code is<br />
invalid.<br />
IN N/A 46<br />
56 (for ICONV D,<br />
also 60 and 82; for<br />
ICONV MC, also 62)<br />
<strong>Commands</strong> and Functions Affected by BASICTYPEs and UDT.OPTIONS<br />
56
Command or<br />
Function<br />
The BASICTYPE Setting<br />
Determines... UDT.OPTIONS<br />
INPUT N/A 12, 18, 46, 65, 83<br />
INPUT @ N/A 101<br />
LOCATE The number of array elements you<br />
can include in a search and the search<br />
driven by those elements.<br />
MATPARSE Whether excess data (including<br />
delimiters) resulting from executing<br />
the MATPARSE command can be<br />
placed in position 0,0 of the dimensioned<br />
array.<br />
MATREAD Whether excess data (including<br />
delimiters) resulting from executing<br />
the MATREAD command can be<br />
placed in position 0,0 of the dimensioned<br />
array.<br />
MATREADL Whether excess data (including<br />
delimiters) resulting from executing<br />
the MATREADL command can be<br />
placed in position 0,0 of the dimensioned<br />
array.<br />
MATREADU Whether excess data (including<br />
delimiters) resulting from executing<br />
the MATREADU command can be<br />
placed in position 0,0 of the dimensioned<br />
array.<br />
MDPERFORM N/A 35<br />
OCONV Whether the OCONV function<br />
returns an empty string if<br />
UDT.OPTIONS 56 is on and the<br />
input value or conversion code is<br />
invalid.<br />
85<br />
N/A<br />
N/A<br />
N/A<br />
N/A<br />
56 (for OCONV D,<br />
also 4 and 29; for<br />
OCONV MD, also 13<br />
and 63)<br />
<strong>Commands</strong> and Functions Affected by BASICTYPEs and UDT.OPTIONS<br />
E-4
Command or<br />
Function<br />
E-5 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
The BASICTYPE Setting<br />
Determines... UDT.OPTIONS<br />
OCONVS Whether the OCONVS function<br />
returns an empty string if<br />
UDT.OPTIONS 56 is on and the<br />
input value or conversion code is<br />
invalid.<br />
ON/GOSUB Whether UniData bypasses the<br />
GOSUB clause and executes the next<br />
program statement (contingent on<br />
whether the expression in the<br />
ON/GOSUB command is nonnumeric<br />
or less than 1).<br />
ON/GOTO Whether UniData bypasses the<br />
GOTO clause and executes the next<br />
program statement (contingent on<br />
whether the expression in the<br />
ON/GOTO command is nonnumeric<br />
or less than 1).<br />
PCPERFORM N/A 35<br />
PERFORM Whether commands are parsed by<br />
using the standard UniData parser or<br />
the P-type parser.<br />
56<br />
N/A<br />
N/A<br />
PRINT N/A 5, 46<br />
PROCREAD N/A 75, 102<br />
PROCWRITE N/A 75<br />
11, 27, 35, 46, 93, 105<br />
<strong>Commands</strong> and Functions Affected by BASICTYPEs and UDT.OPTIONS
Command or<br />
Function<br />
The BASICTYPE Setting<br />
Determines... UDT.OPTIONS<br />
READLIST Whether you should use the<br />
READLIST or READSELECT<br />
command to assign values in an<br />
active select list to a dynamic array.<br />
The BASICTYPE setting also determines<br />
whether you can assign values<br />
in a select list, based on an account<br />
other than the current one, to a<br />
dynamic array. It also determines<br />
whether you can use the SETTING<br />
clause to set the number of elements<br />
in the select list to a variable.<br />
READNEXT Whether you can assign the next<br />
record ID from an active select list,<br />
based on an account other than the<br />
current one, to a variable. It also<br />
determines whether you can use the<br />
SETTING clause to set the number of<br />
elements in the select list to a<br />
variable.<br />
RECORDLOCKED N/A 35<br />
RELEASE N/A 78<br />
SELECT Whether you can specify a numbered<br />
select list (0–9) in the SELECT<br />
command.<br />
SELECTINFO What the -1 SELECTINFO function<br />
return value means.<br />
SLEEP N/A 46<br />
STOP Whether you can specify multiple<br />
messages to display when the<br />
program stops. The BASICTYPE<br />
setting also determines whether you<br />
can specify a message ID that<br />
evaluates to a key in the UniData<br />
error message file.<br />
N/A<br />
23, 71<br />
N/A<br />
N/A<br />
8, 46<br />
<strong>Commands</strong> and Functions Affected by BASICTYPEs and UDT.OPTIONS<br />
E-6
Command or<br />
Function<br />
E-7 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
The BASICTYPE Setting<br />
Determines... UDT.OPTIONS<br />
SYSTEM N/A 100<br />
TRIM Whether all leading and trailing<br />
spaces or occurrences of a specified<br />
character are removed from each<br />
element in a dynamic array. For a<br />
simple string expression, any<br />
BASICTYPE setting produces the<br />
same result.<br />
UDTEXECUTE N/A 35<br />
N/A<br />
<strong>Commands</strong> and Functions Affected by BASICTYPEs and UDT.OPTIONS
<strong>Commands</strong> That Set<br />
STATUS() Return<br />
Values<br />
This appendix lists the <strong>UniBasic</strong> commands and functions that set<br />
STATUS function return values and describes each value.<br />
Appendix<br />
F
F-2 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Command or<br />
Function STATUS() Return Values<br />
FILELOCK 0 – File locked successfully.<br />
usernum – If the file was already locked, and if the LOCKED<br />
clause was included in the FILELOCK statement, STATUS()<br />
returns the user number of the process that locked the file.<br />
FMT 0 – Successful completion.<br />
1 – String expression is invalid or exceeds the allowable string<br />
size.<br />
2 – Conversion code is invalid.<br />
GETPTR 0 – Successful completion.<br />
1 – No more rows exist.<br />
2 – Other error.<br />
ICONV 0 – Successful conversion.<br />
1 – Invalid input data.<br />
2 – Invalid conversion specification.<br />
3 – Invalid date for “D” conversion code only.<br />
5 – Null value if null value handling is turned on.<br />
ICONV D 0 – Successful conversion of a valid date.<br />
1 – Invalid input date.<br />
2 – Invalid conversion specification.<br />
3 – Date was converted correctly, but month and day were<br />
inverted in input value.<br />
ICONVS 0 – Successful conversion.<br />
1 – Invalid input data.<br />
2 – Invalid conversion specification.<br />
3 – Invalid date for “D” conversion code only.<br />
5 – Null value if null value handling is turned on.<br />
<strong>Commands</strong> and Functions That Set STATUS() Return Values
Command or<br />
Function STATUS() Return Values<br />
MATWRITE 0 – The record was locked before MATWRITE executed. You<br />
are in danger of simultaneously updating a record being updated<br />
by another user.<br />
-2 – The record was not locked before MATWRITE executed.<br />
MATWRITEU 0 – The record was locked before MATWRITEU executed. You<br />
are in danger of simultaneously updating a record being updated<br />
by another user.<br />
-2 – The record was not locked before MATWRITEU executed.<br />
OCONV D 0 – Successful conversion of a valid date.<br />
1 – The input date was invalid.<br />
2 – The conversion code was invalid.<br />
OPENSEQ 0 – The record does not exist.<br />
1 – The file you specify is not a sequential-access file.<br />
2 – The file does not exist.<br />
3 – The READONLY clause was included in the command<br />
statement and the record does not exist.<br />
4 – An unknown error occurred (such as having too many files<br />
open or permission problems).<br />
OSBREAD 0 – The read was successful.<br />
1 – The file name is invalid.<br />
2 – Access is denied by the operating system.<br />
3 – The file does not exist.<br />
4 – An unknown error occurred.<br />
OSBWRITE 0 – The write was successful.<br />
1 – The file name is invalid.<br />
2 – You do not have permission to access the file.<br />
4 – The file does not exist.<br />
OSCLOSE 0 – The file has closed successfully.<br />
5 – The file did not close.<br />
<strong>Commands</strong> and Functions That Set STATUS() Return Values (continued)<br />
F-3
F-4 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Command or<br />
Function STATUS() Return Values<br />
OSDELETE 0 – The file was deleted.<br />
1 – The directory name is invalid.<br />
2 – UniData cannot access the file (such as user does not have<br />
permission).<br />
4 – The file does not exist.<br />
READ 0 – Successful read.<br />
2 – A read error occurred.<br />
READBCK 0 – Successful read.<br />
10 – <strong>UniBasic</strong> found and read a duplicate alternate index key<br />
value, and ECL DUP.STATUS is on.<br />
READBCKL 0 – Successful read.<br />
10 – <strong>UniBasic</strong> found and read a duplicate alternate index key<br />
value, and ECL DUP.STATUS is on.<br />
READBCKU 0 – Successful read.<br />
10 – <strong>UniBasic</strong> found and read a duplicate alternate index key<br />
value, and ECL DUP.STATUS is on.<br />
READFWD 0 – Successful read.<br />
10 – <strong>UniBasic</strong> found and read a duplicate alternate index key<br />
value, and ECL DUP.STATUS is on.<br />
READFWDL 0 – Successful read.<br />
10 – <strong>UniBasic</strong> found and read a duplicate alternate index key<br />
value, and ECL DUP.STATUS is on.<br />
READFWDU 0 – Successful read.<br />
10 – <strong>UniBasic</strong> found and read a duplicate alternate index key<br />
value, and ECL DUP.STATUS is on.<br />
READL 0 – Successful read.<br />
1 – UniData was unable to read the record.<br />
n – The record is locked. The user number of the user who<br />
locked the record.<br />
<strong>Commands</strong> and Functions That Set STATUS() Return Values (continued)
Command or<br />
Function STATUS() Return Values<br />
READT 0 – Successful read.<br />
1 – End of file encountered.<br />
2 – End of tape encountered.<br />
3 – Tape not assigned.<br />
4 – Parity error.<br />
5 – Unknown hardware error.<br />
6 – Other unspecified error.<br />
READU 0 – Successful read.<br />
1 – UniData was unable to read the record.<br />
n – The record is locked. The user number of the user who<br />
locked the file is returned in n.<br />
RECORDLOCKED n – The record is locked. The user number of the user who owns<br />
the lock is returned in n.<br />
0 – The record is not locked.<br />
-1 – The file is NFA. Currently, RECORDLOCKED does not<br />
support NFA files.<br />
-2 – Invalid file type. file.var can contain the null value.<br />
-3 – System error: unknown user.<br />
SELECTINDEX 0 – The select list is loaded with alternate key values or record<br />
IDs for the specified file.<br />
1 – No alternate index key exists for this attribute using the name<br />
specified. The select list is empty.<br />
SETINDEX 0 – The alternate key specified exists.<br />
1 – Error.<br />
2 – The alternate key specified does not exist.<br />
<strong>Commands</strong> and Functions That Set STATUS() Return Values (continued)<br />
F-5
SUBROUTINE (Update<br />
Trigger)<br />
SUBROUTINE (Delete<br />
Trigger)<br />
TRANSACTION<br />
COMMIT<br />
TRANSACTION<br />
START<br />
F-6 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Command or<br />
Function STATUS() Return Values<br />
0 – No error.<br />
1 – System error, such as a damaged file.<br />
2 – Constraint violation. In this case, the <strong>UniBasic</strong> trigger<br />
subroutine returns a value of 0 in the parameter execstat,<br />
indicating that the update or delete is not allowed.<br />
3 – Trigger execution error or unexpected return from trigger<br />
routine (for example, the trigger subroutine is not cataloged).<br />
0 – No error.<br />
1 – System error, such as a damaged file.<br />
2 – Constraint violation. In this case, the <strong>UniBasic</strong> trigger<br />
subroutine returns a value of 0 in the parameter execstat,<br />
indicating that the update or delete is not allowed.<br />
3 – Trigger execution error or unexpected return from trigger<br />
routine (for example, the trigger subroutine is not cataloged).<br />
0 – The commit completed successfully.<br />
1 – Transaction not started.<br />
3 – Transaction cannot commit.<br />
0 – The transaction was started.<br />
1 – The transaction was not started.<br />
WEOF 0 – Successful read.<br />
1 – End of file encountered.<br />
2 – End of tape encountered.<br />
3 – Tape not assigned.<br />
4 – Parity error.<br />
5 – Unknown hardware error.<br />
6 – Other unspecified error.<br />
<strong>Commands</strong> and Functions That Set STATUS() Return Values (continued)
Command or<br />
Function STATUS() Return Values<br />
WRITE 0 – Successful write.<br />
1 – System error, such as a damaged file.<br />
2 – Constraint violation. In this case, the <strong>UniBasic</strong> trigger<br />
subroutine returns a value of 0 in the parameter execstat,<br />
indicating that the WRITE is not allowed.<br />
3 – Trigger execution error or unexpected return from trigger<br />
routine (for example, the trigger subroutine is not cataloged).<br />
10 – Non-RFS files: WRITE created a duplicate alternate index<br />
key and ECL DUP.STATUS is on; or WRITE failed because a<br />
duplicate value exists in the index, and NO.DUPS was specified<br />
when the index was created. RFS files: WRITE created a<br />
duplicate value in the index, and ECL DUP.STATUS is on.<br />
WRITET 0 – Successful read.<br />
1 – End of file encountered.<br />
2 – End of tape encountered.<br />
3 – Tape not assigned.<br />
4 – Parity error.<br />
5 – Unknown hardware error.<br />
6 – Other unspecified error.<br />
<strong>Commands</strong> and Functions That Set STATUS() Return Values (continued)<br />
F-7
F-8 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />
Command or<br />
Function STATUS() Return Values<br />
WRITEU 0 – Successful write.<br />
1 – System error, such as a damaged file.<br />
2 – Constraint violation. In this case, the <strong>UniBasic</strong> trigger<br />
subroutine returns a value of 0 in the parameter execstat,<br />
indicating that the WRITEU is not allowed.<br />
3 – Trigger execution error or unexpected return from trigger<br />
routine (for example, trigger subroutine is not cataloged).<br />
10 – Non-RFS files: WRITEU created a duplicate alternate<br />
index key and ECL DUP.STATUS is ON; or WRITEU failed<br />
because a duplicate value exists in the index, and NO.DUPS was<br />
specified when the index was created. RFS files: WRITEU<br />
created a duplicate value in the index, and ECL DUP.STATUS is<br />
ON.<br />
WRITEV 0 – Successful write.<br />
1 – System error, such as a damaged file.<br />
2 – Constraint violation. In this case, the <strong>UniBasic</strong> trigger<br />
subroutine returns a value of 0 in the parameter execstat,<br />
indicating that the WRITEV is not allowed.<br />
3 – Trigger execution error or unexpected return from trigger<br />
routine (for example, trigger subroutine is not cataloged).<br />
10 – Non-RFS files: WRITEV created a duplicate alternate<br />
index key and ECL DUP.STATUS is on; or WRITEV failed<br />
because a duplicate value exists in the index and NO.DUPS was<br />
specified when the index was created. RFS files: WRITEV<br />
created a duplicate value in the index, and ECL DUP.STATUS is<br />
on.<br />
<strong>Commands</strong> and Functions That Set STATUS() Return Values (continued)
Command or<br />
Function STATUS() Return Values<br />
WRITEVU 0 – Successful write.<br />
1 – System error, such as a damaged file.<br />
2 – Constraint violation. In this case, the <strong>UniBasic</strong> trigger<br />
subroutine returns a value of 0 in the parameter execstat,<br />
indicating that the WRITE VU is not allowed.<br />
3 – Trigger execution error or unexpected return from trigger<br />
routine (for example, trigger subroutine is not cataloged).<br />
10 – Non-RFS files: WRITEVU created a duplicate alternate<br />
index key and ECL DUP.STATUS is ON; or WRITEVU failed<br />
because a duplicate value exists in the index, and NO.DUPS was<br />
specified when the index was created. RFS files: WRITEVU<br />
created a duplicate value in the index, and ECL DUP.STATUS is<br />
ON.<br />
<strong>Commands</strong> and Functions That Set STATUS() Return Values (continued)<br />
F-9