+ All Categories

Basic

Date post: 22-Nov-2014
Category:
Upload: nat72
View: 231 times
Download: 1 times
Share this document with a friend
1350
/productinfo/alldoc/UNIVERSE10/basic/Front January 9, 2002 2:18 pm Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta UniVerse BASIC Version 10.0 December, 2001 Part No. 000-8744
Transcript

/productinfo/alldoc/UNIVERSE10/basic/Front January 9, 2002 2:18 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

UniVerse

BASIC

Version 10.0 December, 2001 Part No. 000-8744

/productinfo/alldoc/UNIVERSE10/basic/Front January 9, 2002 2:18 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta BetaIBM Corporation 555 Bailey Avenue San Jose, CA 95141 Licensed Materials Property of IBM Copyright International Business Machines Corporation 2001. All rights reserved. AIX, DB2, DB2 Universal Database, Distributed Relational Database Architecture, NUMA-Q, OS/2, OS/390, and OS/400, IBM Informix, C-ISAM, Foundation.2000 , IBM Informix 4GL, IBM Informix DataBlade module, Client SDK, Cloudscape, Cloudsync, IBM Informix Connect, IBM Informix Driver for JDBC, Dynamic Connect, IBM Informix Dynamic Scalable Architecture (DSA), IBM Informix Dynamic Server, IBM Informix Enterprise Gateway Manager (Enterprise Gateway Manager), IBM Informix Extended Parallel Server, i.Financial Services, J/Foundation, MaxConnect, Object Translator, Red Brick Decision Server, IBM Informix SE, IBM Informix SQL, InformiXML, RedBack, SystemBuilder, U2, UniData, UniVerse, wIntegrate are trademarks or registered trademarks of International Business Machines Corporation. Java and all Java-based trademarks and logos are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. Windows, Windows NT, and Excel are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. UNIX is a registered trademark in the United States and other countries licensed exclusively through X/Open Company Limited. Other company, product, and service names used in this publication may be trademarks or service marks of others.

Documentation Team: Claire Gustafson, Kenny Brunel US GOVERNMENT USERS RESTRICTED RIGHTS Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

ii

UniVerse BASIC

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

Table of Contents

Table of Contents

PrefaceOrganization of This Manual Documentation Conventions UniVerse Documentation . Related Documentation . . API Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 22 24 26 27

Chapter 1

Introduction to UniVerse BASICBASIC Terminology . . . . . . Subroutines . . . . . . . . . Source Syntax . . . . . . . . Statement Types . . . . . . . Statement Labels . . . . . . . Spaces or Tabs . . . . . . . . Newlines and Sequential File I/O . Special Characters . . . . . . . Storing Programs . . . . . . . Editing Programs . . . . . . . Editing Programs in UniVerse. . . Editing Programs Outside UniVerse Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-4 1-6 1-7 1-8 1-10 1-11 1-12 1-13 1-15 1-16 1-16 1-16 1-17

Chapter 2

Data Types, Variables, and OperatorsTypes of Data . . . . . . Character String Data . . . Numeric Data . . . . . . Unknown Data: The Null Value Constants. . . . . . . . Variables . . . . . . . . Array Variables. . . . . . File Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4 2-4 2-5 2-6 2-8 2-9 2-10 2-14

/productinfo/alldoc/UNIVERSE10/basic/BasicTOC.fm (bookTOC.template) January 9, 2002 2:13 pm

/productinfo/alldoc/UNIVERSE10/basic/BasicTOC.fm (bookTOC.template) January 9, 2002 2:13 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

Select List Variables . . . Expressions. . . . . . Format Expressions . . . Operators . . . . . . Arithmetic Operators . . String Operators . . . . Relational Operators . . Pattern Matching Operators IF Operator . . . . . . Logical Operators . . . Assignment Operators . . Dynamic Array Operations

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

2-14 2-15 2-15 2-17 2-17 2-19 2-22 2-23 2-24 2-24 2-26 2-27

Chapter 3

Compiling BASIC ProgramsThe BASIC Command . . . . . . . Compiling Programs in the Background . BASIC Options . . . . . . . . . Compiler Directives . . . . . . . . Including Other Programs . . . . . Dening and Removing Identiers . . Specifying Flavor Compatibility . . . Conditional Compilation . . . . . . Warnings and Error Messages . . . . Successful Compilation . . . . . . The RUN Command . . . . . . . Cataloging a BASIC Program . . . . Catalog Space . . . . . . . . . . The CATALOG Command . . . . . Deleting Cataloged Programs . . . . Catalog Shared Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 3-4 3-4 3-9 3-9 3-10 3-10 3-11 3-14 3-15 3-16 3-17 3-17 3-18 3-19 3-21

Chapter 4

Locks, Transactions, and Isolation LevelsLocks . . . . . . . . . . . . . . . . . . . . . Shared Record Lock . . . . . . . . . . . . . . . . Update Record Lock. . . . . . . . . . . . . . . . Shared File Lock . . . . . . . . . . . . . . . . . Intent File Lock . . . . . . . . . . . . . . . . . Exclusive File Lock . . . . . . . . . . . . . . . . Deadlocks . . . . . . . . . . . . . . . . . . . Transactions . . . . . . . . . . . . . . . . . . 4-4 4-5 4-6 4-7 4-8 4-9 4-9 4-10

iv

UniVerse BASIC

/productinfo/alldoc/UNIVERSE10/basic/BasicTOC.fm (bookTOC.template) January 9, 2002 2:13 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

Active Transactions . . . . . . . . . Transactions and Locks . . . . . . . . Transactions and Isolation Levels . . . . Using Transactions in BASIC . . . . . . @Variables . . . . . . . . . . . . Transaction Restrictions . . . . . . . . Isolation Levels . . . . . . . . . . . Isolation Level Types . . . . . . . . . Data Anomalies. . . . . . . . . . . Using the ISOMODE Congurable Parameter Isolation Levels and Locks . . . . . . . Example . . . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

4-10 4-12 4-13 4-13 4-14 4-15 4-16 4-16 4-17 4-18 4-19 4-21

Chapter 5

Debugging ToolsRAID . . . . . . . . . . . . . . Invoking RAID from the Command Processor Invoking RAID from a BASIC Program . . Invoking RAID Using the Break Key . . . Referencing Variables Through RAID . . . RAID Commands . . . . . . . . . . VLIST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-4 5-4 5-5 5-6 5-6 5-8 5-19

Chapter 6

Using CallHTTPConguring the Default HTTP Settings . Getting the Current HTTP Default Settings Creating an HTTP Request . . . . . . Creating a Secure HTTP Request . . . . Setting Additional Headers for a Request . Adding a Parameter to the Request . . . Submitting a Request . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4 6-7 6-8 6-11 6-13 6-15 6-17

Chapter 7

Using SSL with the CallHTTP and Socket InterfacesOverview of SSL Technology . . . . . . . . . . . . Setup and Conguration for SSL . . . . . . . . . . . SSL Security Programmatic Interfaces for UniData and UniVerse Creating A Security Context . . . . . . . . . . . . Saving a Security Context . . . . . . . . . . . . . Loading a Security Context . . . . . . . . . . . . . Showing a Security Context . . . . . . . . . . . . Adding a Certicate . . . . . . . . . . . . . . . 7-4 7-5 7-6 7-7 7-9 7-11 7-13 7-14 v

Table of Contents

/productinfo/alldoc/UNIVERSE10/basic/BasicTOC.fm (bookTOC.template) January 9, 2002 2:13 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

Adding an Authentication Rule . . . Setting a Cipher Suite . . . . . . Getting A Cipher Suite . . . . . . Setting a Private Key . . . . . . Setting Client Authentication Mode . Setting the Authentication Depth . . Generating a Key Pair . . . . . . Creating a Certicate Request . . . Creating a Certicate . . . . . . Setting a Random Seed . . . . . . Analyzing a Certicate . . . . . . Encoding and Cryptographic Functions Encoding Data. . . . . . . . . Encrypting Data . . . . . . . . Generating a Message Digest . . . Generating a Digital Signature . . . Additional Reading . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . .

7-17 7-19 7-27 7-29 7-32 7-33 7-35 7-38 7-42 7-44 7-46 7-47 7-48 7-50 7-56 7-58 7-61

Chapter 8

Using the Socket InterfaceSocket Function Error Return Codes . . . . . . . . . . Getting a Socket Error Message . . . . . . . . . . . . Opening a Socket. . . . . . . . . . . . . . . . . Opening a Secure Socket . . . . . . . . . . . . . . Closing a Socket . . . . . . . . . . . . . . . . . Getting Information From a Socket . . . . . . . . . . Reading From a Socket . . . . . . . . . . . . . . . Writing to a Socket . . . . . . . . . . . . . . . . Setting the Value for a Socket Option . . . . . . . . . . Getting the Value of a Socket Option . . . . . . . . . . Initializing a Server Side Socket Connection . . . . . . . Initializing a Secure Server Side Socket Connection . . . . . Accepting an Incoming Connection Attempt on the Server Side Protocol Logging . . . . . . . . . . . . . . . . . Socket API Example 1 . . . . . . . . . . . . . . . 8-4 8-9 8-10 8-11 8-13 8-14 8-16 8-18 8-20 8-22 8-25 8-26 8-28 8-30 8-32

Chapter 9

Creating XML DocumentsXML for IBM UniVerse . . . . . . . . What is XML? . . . . . . . . . . . Document Type Denitions . . . . . . The Document Object Model (DOM) . . . Well-Formed and Valid XML Documents . Creating an XML Document from RetrieVe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-3 9-3 9-3 9-4 9-4 9-5

vi

UniVerse BASIC

/productinfo/alldoc/UNIVERSE10/basic/BasicTOC.fm (bookTOC.template) January 9, 2002 2:13 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

Create the &XML& File . . . . . . . . . . . . Mapping Modes . . . . . . . . . . . . . . Creating a Mapping File . . . . . . . . . . . . How Data is Mapped . . . . . . . . . . . . . Mapping Example . . . . . . . . . . . . . . Creating an XML Document . . . . . . . . . . Examples . . . . . . . . . . . . . . . . . Creating an XML Document with UniVerse SQL . . . Create the &XML& File . . . . . . . . . . . . Processing Rules for UniVerse SQL SELECT Statements . XML Limitations in UniVerse SQL . . . . . . . . Examples . . . . . . . . . . . . . . . . .

. . . . . . . . . . . .

. . . . . . . . . . . .

9-5 9-5 9-7 9-11 9-13 9-14 9-15 9-26 9-26 9-28 9-29 9-29

Chapter 10

Receiving XML DocumentsReceiving an XML Document through UniVerse BASIC . Dening Extraction Rules . . . . . . . . . . . Dening the XPath . . . . . . . . . . . . . Extracting XML Data through UniVerse BASIC . . . . Displaying an XML Document through RetrieVe . . . Displaying an XML Document through UniVerse SQL . . . . . . . . . . . . . 10-3 10-3 10-5 10-13 10-18 10-22

Chapter 11

BASIC Statements and Functions! statement . . . . . #INCLUDE statement . $* statement . . . . . $CHAIN statement . . $COPYRIGHT statement $DEFINE statement . . $EJECT statement . . . $IFDEF statement . . . $IFNDEF statement . . $INCLUDE statement . $INSERT statement . . $MAP statement . . . $OPTIONS statement . . $PAGE statement . . . $UNDEFINE statement . * statement . . . . . < > operator . . . . . @ function . . . . . [ ] operator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-14 11-16 11-18 11-20 11-21 11-22 11-24 11-25 11-26 11-27 11-29 11-31 11-32 11-42 11-43 11-45 11-47 11-48 11-71

Table of Contents vii

/productinfo/alldoc/UNIVERSE10/basic/BasicTOC.fm (bookTOC.template) January 9, 2002 2:13 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

ABORT statement . . . . . . ABS function . . . . . . . . ABSS function . . . . . . . . acceptConnection function . . . ACOS function . . . . . . . addAuthenticationRule function . addCerticate function . . . . . addRequestParameter function . . ADDS function . . . . . . . ALPHA function . . . . . . . analyzeCerticate function . . . ANDS function . . . . . . . ASCII function . . . . . . . ASIN function . . . . . . . . ASSIGNED function . . . . . assignment statements . . . . . ATAN function . . . . . . . AUTHORIZATION statement . . AUXMAP statement . . . . . BEGIN CASE statement . . . . BEGIN TRANSACTION statement BITAND function. . . . . . . BITNOT function. . . . . . . BITOR function . . . . . . . BITREST function . . . . . . BITSET function . . . . . . . BITTEST function . . . . . . BITXOR function . . . . . . . BREAK statement . . . . . . BSCAN statement . . . . . . BYTE function . . . . . . . . BYTELEN function . . . . . . BYTETYPE function . . . . . . BYTEVAL function . . . . . . CALL statement . . . . . . . CASE statements . . . . . . . CATS function. . . . . . . . CENTURY.PIVOT function . . . CHAIN command . . . . . . CHANGE function . . . . . . CHAR function . . . . . . . CHARS function . . . . . . . viii UniVerse BASIC

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11-74 11-76 11-77 11-78 11-80 11-81 11-83 11-86 11-88 11-89 11-90 11-91 11-92 11-93 11-94 11-95 11-97 11-98 11-100 11-101 11-102 11-104 11-105 11-106 11-107 11-108 11-109 11-110 11-111 11-113 11-116 11-117 11-118 11-119 11-120 11-124 11-127 11-128 11-130 11-131 11-132 11-133

/productinfo/alldoc/UNIVERSE10/basic/BasicTOC.fm (bookTOC.template) January 9, 2002 2:13 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

CHECKSUM function . . . CLEAR statement . . . . . CLEARDATA statement . . . CLEARFILE statement . . . CLEARPROMPTS statement . CLEARSELECT statement . . CLOSE statement . . . . . CLOSESEQ statement . . . closeSocket function . . . . CloseXMLData function . . . COL1 function . . . . . . COL2 function . . . . . . COMMIT statement . . . . COMMON statement. . . . COMPARE function . . . . CONVERT function . . . . CONVERT statement . . . . COS function . . . . . . COSH function . . . . . . COUNT function . . . . . COUNTS function . . . . . CREATE statement . . . . createCertication function . . createCertRequest function . . createRequest function . . . createSecureRequest function . createSecurityContext function CRT statement . . . . . . DATA statement . . . . . DATE function . . . . . . DCOUNT function . . . . DEBUG statement . . . . . DEFFUN statement . . . . DEL statement . . . . . . DELETE function . . . . . DELETE statements . . . . DELETELIST statement . . . DESCRINFO function . . . DIMENSION statement . . . DISPLAY statement . . . . DIV function . . . . . . . DIVS function . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11-135 11-136 11-137 11-138 11-141 11-142 11-144 11-146 11-148 11-149 11-150 11-151 11-153 11-155 11-157 11-159 11-161 11-162 11-163 11-164 11-166 11-168 11-170 11-172 11-176 11-179 11-181 11-183 11-185 11-187 11-188 11-190 11-192 11-194 11-196 11-198 11-202 11-203 11-205 11-208 11-209 11-210

Table of Contents ix

/productinfo/alldoc/UNIVERSE10/basic/BasicTOC.fm (bookTOC.template) January 9, 2002 2:13 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

DOWNCASE function . . . . DQUOTE function . . . . . DTX function . . . . . . . EBCDIC function . . . . . . ECHO statement . . . . . . ENCODE function . . . . . ENCRYPT function . . . . . DIGEST function . . . . . . END statement . . . . . . END CASE statement . . . . END TRANSACTION statement ENTER statement . . . . . EOF(ARG.) function. . . . . EQS function . . . . . . . EQUATE statement . . . . . EREPLACE function . . . . ERRMSG statement . . . . . EXCHANGE function . . . . EXECUTE statement . . . . EXIT statement . . . . . . EXP function . . . . . . . EXTRACT function . . . . . FADD function . . . . . . FDIV function . . . . . . . FFIX function . . . . . . . FFLT function . . . . . . . FIELD function . . . . . . FIELDS function . . . . . . FIELDSTORE function . . . . FILEINFO function . . . . . FILELOCK statement . . . . FILEUNLOCK statement . . . FIND statement . . . . . . FINDSTR statement . . . . . FIX function . . . . . . . FLUSH statement . . . . . FMT function . . . . . . . FMTDP function . . . . . . FMTS function . . . . . . FMTSDP function . . . . . FMUL function . . . . . . FOLD function . . . . . . x UniVerse BASIC

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11-211 11-212 11-213 11-214 11-215 11-216 11-218 11-224 11-226 11-228 11-229 11-230 11-231 11-232 11-233 11-235 11-236 11-238 11-240 11-243 11-244 11-245 11-248 11-249 11-250 11-251 11-252 11-254 11-256 11-258 11-265 11-268 11-270 11-271 11-272 11-274 11-275 11-281 11-283 11-284 11-286 11-287

/productinfo/alldoc/UNIVERSE10/basic/BasicTOC.fm (bookTOC.template) January 9, 2002 2:13 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

FOLDDP function . . . . . FOOTING statement . . . . FOR statement . . . . . . FORMLIST statement. . . . FSUB function . . . . . . FUNCTION statement . . . generateKey function . . . . GES function. . . . . . . GET statements . . . . . . getCipherSuite function . . . getSocketErrorMessage function getSocketOptions function . . GETX statement . . . . . GET(ARG.) statement . . . getHTTPDefault function . . GETLIST statement . . . . GETLOCALE function . . . GETREM function . . . . . getSocketInformation function GOSUB statement . . . . . GOTO statement . . . . . GROUP function . . . . . GROUPSTORE statement . . GTS function. . . . . . . HEADING statement . . . . HUSH statement . . . . . ICHECK function . . . . . ICONV function . . . . . ICONVS function . . . . . IF statement . . . . . . . IFS function . . . . . . . ILPROMPT function . . . . INCLUDE statement . . . . INDEX function . . . . . INDEXS function . . . . . INDICES function . . . . . initSecureServerSocket function initServerSocket function . . INMAT function . . . . . INPUT statement . . . . . INPUTCLEAR statement . . INPUTDISP statement . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11-289 11-290 11-295 11-299 11-300 11-301 11-303 11-306 11-307 11-312 11-314 11-315 11-317 11-318 11-320 11-321 11-323 11-325 11-326 11-328 11-330 11-331 11-333 11-335 11-336 11-342 11-344 11-347 11-350 11-352 11-355 11-356 11-359 11-361 11-363 11-364 11-369 11-371 11-372 11-374 11-379 11-380

Table of Contents xi

/productinfo/alldoc/UNIVERSE10/basic/BasicTOC.fm (bookTOC.template) January 9, 2002 2:13 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

INPUTD statement . . . . . . . . . . . INPUTERR statement . . . . . . . . . . INPUTIF statement . . . . . . . . . . . INPUTNULL statement . . . . . . . . . INPUTTRAP statement . . . . . . . . . INS statement . . . . . . . . . . . . . INSERT function . . . . . . . . . . . . INT function . . . . . . . . . . . . . ISNULL function . . . . . . . . . . . . ISNULLS function . . . . . . . . . . . ITYPE function . . . . . . . . . . . . KEYEDIT statement . . . . . . . . . . . KEYEXIT statement . . . . . . . . . . . KEYIN function . . . . . . . . . . . . KEYTRAP statement . . . . . . . . . . LEFT function . . . . . . . . . . . . . LEN function . . . . . . . . . . . . . LENDP function . . . . . . . . . . . . LENS function. . . . . . . . . . . . . LENSDP function . . . . . . . . . . . LES function . . . . . . . . . . . . . LET statement . . . . . . . . . . . . . LN function . . . . . . . . . . . . . loadSecurityContext function . . . . . . . LOCALEINFO function . . . . . . . . . LOCATE statement (IDEAL and REALITY Syntax) LOCATE statement (INFORMATION Syntax) . . LOCATE statement (PICK Syntax) . . . . . . LOCK statement . . . . . . . . . . . . LOOP statement . . . . . . . . . . . . LOWER function . . . . . . . . . . . . LTS function . . . . . . . . . . . . . MAT statement . . . . . . . . . . . . MATBUILD statement . . . . . . . . . . MATCH operator . . . . . . . . . . . MATCHFIELD function . . . . . . . . . MATPARSE statement . . . . . . . . . . MATREAD statements . . . . . . . . . . MATREADL statement. . . . . . . . . . MATREADU statement . . . . . . . . . MATWRITE statements . . . . . . . . . MATWRITEU statement . . . . . . . . . xii UniVerse BASIC

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11-381 11-382 11-383 11-384 11-385 11-386 11-390 11-394 11-395 11-396 11-397 11-399 11-407 11-409 11-410 11-412 11-413 11-414 11-415 11-416 11-418 11-419 11-420 11-421 11-423 11-425 11-429 11-433 11-437 11-439 11-442 11-444 11-445 11-447 11-449 11-451 11-453 11-456 11-461 11-462 11-463 11-467

/productinfo/alldoc/UNIVERSE10/basic/BasicTOC.fm (bookTOC.template) January 9, 2002 2:13 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

MAXIMUM function . . . MINIMUM function . . . MOD function . . . . . MODS function . . . . . MULS function . . . . . NAP statement . . . . . NEG function . . . . . NEGS function . . . . . NES function . . . . . NEXT statement . . . . NOBUF statement . . . . NOT function . . . . . NOTS function . . . . . NULL statement . . . . NUM function . . . . . NUMS function . . . . . OCONV function . . . . OCONVS function . . . . ON statement . . . . . OPEN statement . . . . OPENCHECK statement . OPENDEV statement . . . OPENPATH statement . . OPENSEQ statement . . . openSecureSocket function . openSocket function . . . OpenXMLData function . . ORS function . . . . . PAGE statement . . . . PERFORM statement . . . PRECISION statement . . PrepareXML function. . . PRINT statement . . . . PRINTER statement . . . PRINTERR statement. . . PROCREAD statement . . PROCWRITE statement . . PROGRAM statement . . PROMPT statement . . . protocolLogging function . PWR function . . . . . QUOTE function . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11-468 11-469 11-470 11-471 11-472 11-473 11-474 11-475 11-476 11-477 11-478 11-479 11-480 11-481 11-482 11-483 11-484 11-487 11-489 11-492 11-496 11-498 11-501 11-504 11-510 11-512 11-513 11-515 11-516 11-517 11-519 11-521 11-522 11-524 11-526 11-529 11-530 11-531 11-532 11-534 11-536 11-537 xiii

Table of Contents

/productinfo/alldoc/UNIVERSE10/basic/BasicTOC.fm (bookTOC.template) January 9, 2002 2:13 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

RAISE function . . . . . RANDOMIZE statement . . READ statements. . . . . READBLK statement . . . READL statement . . . . READLIST statement . . . READNEXT statement . . . READSEQ statement . . . readSocket function . . . . READT statement . . . . READU statement . . . . READV statement . . . . READVL statement . . . . READVU statement . . . . ReadXMLData function . . REAL function . . . . . RECORDLOCK statements . RECORDLOCKED function . RELEASE statement. . . . ReleaseXML . . . . . . REM function . . . . . . REM statement . . . . . REMOVE function . . . . REMOVE statement . . . . REPEAT statement . . . . REPLACE function . . . . RETURN statement . . . . RETURN (value) statement . REUSE function . . . . . REVREMOVE statement . . REWIND statement . . . . RIGHT function . . . . . RND function . . . . . . ROLLBACK statement . . . RPC.CALL function . . . . RPC.CONNECT function . . RPC.DISCONNECT function saveSecurityContext. . . . SADD function . . . . . SCMP function . . . . . SDIV function . . . . . . SEEK statement . . . . . xiv UniVerse BASIC

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11-538 11-540 11-541 11-547 11-549 11-550 11-552 11-554 11-557 11-559 11-561 11-562 11-563 11-564 11-565 11-567 11-568 11-572 11-575 11-577 11-578 11-579 11-581 11-584 11-587 11-588 11-592 11-594 11-595 11-597 11-599 11-600 11-601 11-602 11-604 11-606 11-608 11-610 11-612 11-613 11-614 11-615

/productinfo/alldoc/UNIVERSE10/basic/BasicTOC.fm (bookTOC.template) January 9, 2002 2:13 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

SEEK(ARG.) statement . . . . . . . . . . . SELECT statements . . . . . . . . . . . . SELECTE statement . . . . . . . . . . . . SELECTINDEX statement . . . . . . . . . . SELECTINFO function . . . . . . . . . . . SEND statement . . . . . . . . . . . . . SENTENCE function . . . . . . . . . . . . SEQ function. . . . . . . . . . . . . . . SEQS function . . . . . . . . . . . . . . setAuthenticationDepth function. . . . . . . . setCipherSuite function . . . . . . . . . . . setClientAuthentication function . . . . . . . . setPrivateKey function . . . . . . . . . . . setRandomSeed function . . . . . . . . . . SET TRANSACTION ISOLATION LEVEL statement . setHTTPDefault function . . . . . . . . . . setRequestHeader function . . . . . . . . . . SETLOCALE function . . . . . . . . . . . SETREM statement . . . . . . . . . . . . setSocketOptions function . . . . . . . . . . showSecurityContext function . . . . . . . . SIGNATURE function . . . . . . . . . . . SIN function . . . . . . . . . . . . . . . SINH function . . . . . . . . . . . . . . SLEEP statement . . . . . . . . . . . . . SMUL function . . . . . . . . . . . . . . SOUNDEX function . . . . . . . . . . . . SPACE function. . . . . . . . . . . . . . SPACES function . . . . . . . . . . . . . SPLICE function . . . . . . . . . . . . . SQRT function . . . . . . . . . . . . . . SQUOTE function . . . . . . . . . . . . . SSELECT statement . . . . . . . . . . . . SSUB function . . . . . . . . . . . . . . STATUS function . . . . . . . . . . . . . STATUS statement . . . . . . . . . . . . . STOP statement. . . . . . . . . . . . . . STORAGE statement . . . . . . . . . . . . STR function . . . . . . . . . . . . . . . STRS function . . . . . . . . . . . . . . submitRequest function . . . . . . . . . . . SUBR function . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11-617 11-619 11-623 11-624 11-626 11-628 11-630 11-631 11-633 11-634 11-636 11-644 11-645 11-648 11-650 11-652 11-655 11-657 11-660 11-662 11-664 11-666 11-669 11-670 11-671 11-672 11-673 11-674 11-675 11-676 11-677 11-678 11-679 11-683 11-684 11-692 11-697 11-699 11-700 11-701 11-702 11-705

Table of Contents xv

/productinfo/alldoc/UNIVERSE10/basic/BasicTOC.fm (bookTOC.template) January 9, 2002 2:13 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

SUBROUTINE statement . . . . . SUBS function . . . . . . . . . SUBSTRINGS function . . . . . . SUM function . . . . . . . . . SUMMATION function . . . . . SWAP statement . . . . . . . . SYSTEM function . . . . . . . TABSTOP statement. . . . . . . TAN function . . . . . . . . . TANH function . . . . . . . . TERMINFO function . . . . . . TIME function . . . . . . . . . TIMEDATE function . . . . . . TIMEOUT statement . . . . . . TPARM function . . . . . . . . TPRINT statement . . . . . . . TRANS function . . . . . . . . transaction statements . . . . . . TRANSACTION ABORT statement . TRANSACTION COMMIT statement TRANSACTION START statement . TRIM function. . . . . . . . . TRIMB function . . . . . . . . TRIMBS function . . . . . . . . TRIMF function . . . . . . . . TRIMFS function . . . . . . . . TRIMS function . . . . . . . . TTYCTL statement . . . . . . . TTYGET statement . . . . . . . TTYSET statement . . . . . . . UNASSIGNED function . . . . . UNICHAR function . . . . . . . UNICHARS function . . . . . . UNISEQ function. . . . . . . . UNISEQS function . . . . . . . UNLOCK statement. . . . . . . UPCASE function . . . . . . . UPRINT statement . . . . . . . WEOF statement . . . . . . . . WEOFSEQ statement . . . . . . WRITE statements . . . . . . . WRITEBLK statement . . . . . . xvi UniVerse BASIC

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

11-707 11-708 11-709 11-710 11-712 11-713 11-714 11-719 11-720 11-721 11-722 11-748 11-749 11-751 11-753 11-758 11-760 11-762 11-763 11-765 11-766 11-767 11-769 11-770 11-771 11-772 11-773 11-774 11-776 11-784 11-787 11-788 11-789 11-790 11-791 11-792 11-793 11-794 11-796 11-797 11-799 11-806

/productinfo/alldoc/UNIVERSE10/basic/BasicTOC.fm (bookTOC.template) January 9, 2002 2:13 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

WRITELIST statement WRITESEQ statement WRITESEQF statement writeSocket function . WRITET statement . WRITEU statement . WRITEV statement . WRITEVU statement . XLATE function. . . XMLError function . XTD function . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

. . . . . . . . . . .

11-808 11-809 11-812 11-815 11-817 11-819 11-820 11-821 11-822 11-824 11-825

Appendix A Appendix B Appendix C

Quick ReferenceCompiler Directives . . . . . . . . . . . . . . . A-2

ASCII and Hex Equivalents Correlative and Conversion CodesA code: Algebraic Functions . . . . . . . . BB and BX codes: Bit Conversion . . . . . . . C code: Concatenation . . . . . . . . . . D code: Date Conversion . . . . . . . . . DI code: International Date Conversion . . . . ECS code: Extended Character Set Conversion . . F code: Mathematical Functions . . . . . . . G code: Group Extraction . . . . . . . . . L code: Length Function . . . . . . . . . . MC Codes: Masked Character Conversion . . . MD code: Masked Decimal Conversion . . . . ML and MR codes: Formatting Numbers . . . . MP code: Packed Decimal Converstion . . . . MT code: Time Conversion . . . . . . . . . MX, MO, MB, and MU0C codes: Radix Conversion MY code: ASCII Conversion . . . . . . . . NL code: Arabic Numeral Conversion . . . . . NLSmapname code: NLS Map Conversion . . . NR code: Roman Numeral Conversion. . . . . P code: Pattern Matching . . . . . . . . . Q code: Exponential Notation . . . . . . . . R code: Range Function . . . . . . . . . . S (Soundex) code . . . . . . . . . . . . S (substitution) code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . C-4 C-10 C-12 C-14 C-21 C-22 C-23 C-28 C-29 C-30 C-33 C-37 C-42 C-43 C-45 C-47 C-48 C-49 C-50 C-51 C-52 C-54 C-55 C-56 xvii

Table of Contents

/productinfo/alldoc/UNIVERSE10/basic/BasicTOC.fm (bookTOC.template) January 9, 2002 2:13 pm

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

T code: Text Extraction . . . . . . . . . . . . . . . Tle code: File Translation . . . . . . . . . . . . . TI code: International Time Conversion . . . . . . . . .

C-57 C-58 C-60

Appendix D Appendix E Appendix F

BASIC Reserved Words @Variables BASIC Subroutines! ASYNC subroutine. . . . . !EDIT.INPUT subroutine . . . !ERRNO subroutine . . . . . !FCMP subroutine . . . . . !GET.KEY subroutine . . . . !GET.PARTNUM subroutine . . !GET.PATHNAME subroutine . !GETPU subroutine . . . . . Equate Names for Return Code . !GET.USER.COUNTS subroutine !GET.USERS subroutine . . . !INLINE.PROMPTS subroutine . !INTS subroutine . . . . . . !MAKE.PATHNAME subroutine !MATCHES subroutine. . . . !MESSAGE subroutine . . . . !PACK.FNKEYS subroutine . . !REPORT.ERROR subroutine. . !SET.PTR subroutine . . . . !SETPU subroutine . . . . . !TIMDAT subroutine . . . . !USER.TYPE subroutine . . . !VOC.PATHNAME subroutine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . F-4 F-6 F-15 F-16 F-17 F-20 F-23 F-24 F-27 F-29 F-30 F-32 F-35 F-36 F-38 F-40 F-42 F-48 F-50 F-52 F-56 F-58 F-60

xviii UniVerse BASIC

/productinfo/alldoc/UNIVERSE10/bas ic/Preface

PrefaceThis manual describes the UniVerse BASIC programming language. It is for experienced programmers and includes explanations of all BASIC statements and functions supported by UniVerse as well as information regarding the use of BASIC with UniVerse in the UNIX and Windows NT environments. If you have never used BASIC, read Introduction to UniVerse BASIC and Data Types, Variables, and Operators before you begin. Before using any statement or function, thoroughly read its description in Using the Socket Interface. If you have previously used a BASIC programming language, you can skim through the rst two chapters to determine the difference that may exist between UniVerse BASIC and the BASIC you have used in the past.

19

/productinfo/alldoc/UNIVERSE10/basic/Preface 1/9/02

Organization of This ManualThis manual contains the following: Chapter 1, Introduction to UniVerse BASIC, covers information you should know before you begin to use BASIC, such as initial procedures, terminology, and features that are unique to this implementation of BASIC. Chapter 2, Data Types, Variables, and Operators, describes types of data, such as constants and variables, and types of operators. Chapter 3, Compiling BASIC Programs, describes the UniVerse BASIC compiler. The discussion includes instructions on how to run the compiler, compiling options, warnings and error messages, and other related commands. Chapter 4, Locks, Transactions, and Isolation Levels, describes how to use locks, transaction processing, and isolation levels to prevent data loss and other data conicts. Chapter 5, Debugging Tools, describes the tools available for debugging UniVerse BASIC programs. Included is an interactive debugger, RAID, and the program listing command, VLIST. Chapter 6, Using CallHTTP, describes how to interact with a web server from UniVerse BASIC through standard HTTP protocol. Chapter 7, Using SSL with the CallHTTP and Socket Interfaces, describes how to set up and congure SSL for use with the CallHTTP and Socket interfaces. Chapter 8, Using the Socket Interface, describes how to interact with an application running on another machine via the socket interface. Chapter 9, Creating XML Documents, describes how to create an XML document through UniVerse BASIC. Chapter 10, Receiving XML Documents, describes how to access XML documents you receive through UniVerse BASIC. Chapter 11, BASIC Statements and Functions, contains statements and functions in alphabetical order. At the top of each page is the syntax for the statement or function, followed by a detailed description of its use, often including references to other statements or functions that can be used with it or are helpful to know about.20 UniVerse Basic

/productinfo/alldoc/UNIVERSE10/bas ic/Preface

Examples illustrate the application of the statement or function in a program. Appendix A, Quick Reference, is a quick reference for BASIC statements and functions grouped according to use. Appendix B, ASCII and Hex Equivalents, is a table of ASCII character codes and equivalents and hexadecimal equivalents. Appendix C, Correlative and Conversion Codes, describes the syntax and use of correlative and conversion codes. Appendix D, BASIC Reserved Words, lists UniVerse BASIC reserved words. Appendix E, @Variables, is a quick reference for UniVerse BASIC @variables. Appendix F, BASIC Subroutines, describes subroutines you can call from UniVerse BASIC programs.

21

/productinfo/alldoc/UNIVERSE10/basic/Preface 1/9/02

Documentation ConventionsThis manual uses the following conventions:Convention Bold Usage In syntax, bold indicates commands, function names, and options. In text, bold indicates keys to press, function names, menu selections, and MS-DOS commands. In syntax, uppercase indicates UniVerse commands, keywords, and options; BASIC statements and functions; and SQL statements and keywords. In text, uppercase also indicates UniVerse identiers such as lenames, account names, schema names, and Windows NT lenames and pathnames. In syntax, italic indicates information that you supply. In text, italic also indicates UNIX commands and options, lenames, and pathnames. Courier indicates examples of source code and system output. In examples, courier bold indicates characters that the user types or keys the user presses (for example, ). Brackets enclose optional items. Do not type the brackets unless indicated. Braces enclose nonoptional items from which you must select at least one. Do not type the braces. A vertical bar separating items indicates that you can choose only one item. Do not type the vertical bar. Three periods indicate that more of the same type of item can optionally follow. A right arrow between menu options indicates you should choose each option in sequence. For example, Choose File Exit means you should choose File from the menu bar, then choose Exit from the File pull-down menu. Documentation Conventions 22 UniVerse Basic

UPPERCASE

Italic

Courier Courier Bold

[] {}itemA | itemB ...

/productinfo/alldoc/UNIVERSE10/bas ic/Preface

ConventionI

Usage Item mark. For example, the item mark ( I ) in the following string delimits elements 1 and 2, and elements 3 and 4: 1I2F3I4V5 Field mark. For example, the eld mark ( F ) in the following string delimits elements FLD1 and VAL1: FLD1FVAL1VSUBV1SSUBV2 Value mark. For example, the value mark ( V ) in the following string delimits elements VAL1 and SUBV1: FLD1FVAL1VSUBV1SSUBV2 Subvalue mark. For example, the subvalue mark ( S ) in the following string delimits elements SUBV1 and SUBV2: FLD1FVAL1VSUBV1SSUBV2 Text mark. For example, the text mark ( T ) in the following string delimits elements 4 and 5: 1F2S3V4T5 Documentation Conventions (Continued)

F

V

S

T

The following conventions are also used:s s

Syntax denitions and examples are indented for ease in reading. All punctuation marks included in the syntaxfor example, commas, parentheses, or quotation marksare required unless otherwise indicated. Syntax lines that do not t on one line in this manual are continued on subsequent lines. The continuation lines are indented. When entering syntax, type the entire syntax entry, including the continuation lines, on the same input line.

s

23

/productinfo/alldoc/UNIVERSE10/basic/Preface 1/9/02

UniVerse DocumentationUniVerse documentation includes the following: UniVerse BASIC: Contains comprehensive information about the UniVerse BASIC language. It includes reference pages for all BASIC statements and functions. It is for experienced programmers. UniVerse BASIC SQL Client Interface Guide: Describes how to use the BASIC SQL Client Interface (BCI), an interface to UniVerse and nonUniVerse databases from UniVerse BASIC. The BASIC SQL Client Interface uses ODBC-like function calls to execute SQL statements on local or remote database servers such as UniVerse, ORACLE, SYBASE, or INFORMIX. This book is for experienced SQL programmers. Administering UniVerse: Describes tasks performed by UniVerse administrators, such as starting up and shutting down the system, system conguration and maintenance, system security, maintaining and transferring UniVerse accounts, maintaining peripherals, backing up and restoring les, and managing le and record locks, and network services. This book includes descriptions of how to use the UniVerse Admin program on a Windows client and how to use shell commands on UNIX systems to administer UniVerse. UniVerse Transaction Logging and Recovery: Describes the UniVerse transaction logging subsystem, including both transaction and warmstart logging and recovery. This book is for system administrators. UniVerse System Description: Provides detailed and advanced information about UniVerse features and capabilities for experienced users. This book describes how to use UniVerse commands, work in a UniVerse environment, create a UniVerse database, and maintain UniVerse les. UniVerse User Reference: Contains reference pages for all UniVerse commands, keywords, and user records, allowing experienced users to refer to syntax details quickly. Guide to RetrieVe: Describes RetrieVe, the UniVerse query language that lets users select, sort, process, and display data in UniVerse les. This book is for users who are familiar with UniVerse. Guide to ProVerb: Describes ProVerb, a UniVerse processor used by application developers to execute prestored procedures called procs. This book describes tasks such as relational data testing, arithmetic24 UniVerse Basic

/productinfo/alldoc/UNIVERSE10/bas ic/Preface

processing, and transfers to subroutines. It also includes reference pages for all ProVerb commands. Guide to the UniVerse Editor: Describes in detail how to use the Editor, allowing users to modify UniVerse les or programs. This book also includes reference pages for all UniVerse Editor commands. UniVerse NLS Guide: Describes how to use and manage UniVerses National Language Support (NLS). This book is for users, programmers, and administrators. UniVerse SQL Administration for DBAs: Describes administrative tasks typically performed by DBAs, such as maintaining database integrity and security, and creating and modifying databases. This book is for database administrators (DBAs) who are familiar with UniVerse. UniVerse SQL User Guide: Describes how to use SQL functionality in UniVerse applications. This book is for application developers who are familiar with UniVerse. UniVerse SQL Reference: Contains reference pages for all SQL statements and keywords, allowing experienced SQL users to refer to syntax details quickly. It includes the complete UniVerse SQL grammar in Backus Naur Form (BNF). UniVerse Master Index: A comprehensive index for UniVerse documentation. UniVerse Quick Reference: A quick reference to all UniVerse commands and keywords. It also summarizes UniVerse SQL statements and keywords, all elements of the UniVerse BASIC language, Editor commands, ProVerb commands, le types, le dictionaries, and user exits.

25

/productinfo/alldoc/UNIVERSE10/basic/Preface 1/9/02

Related DocumentationThe following documentation is also available: UniVerse GCI Guide: Describes how to use the General Calling Interface (GCI) to call subroutines written in C, C++, or FORTRAN from BASIC programs. This book is for experienced programmers who are familiar with UniVerse. UniVerse ODBC Guide: Describes how to install and congure a UniVerse ODBC server on a UniVerse host system. It also describes how to use UniVerse ODBC Cong and how to install, congure, and use UniVerse ODBC drivers on client systems. This book is for experienced UniVerse developers who are familiar with SQL and ODBC. UV/NET II Guide: Describes UV/Net II, the UniVerse transparent database networking facility that lets users access UniVerse les on remote systems. This book is for experienced UniVerse administrators. UniVerse Guide for Pick Users: Describes UniVerse for new UniVerse users familiar with Pick-based systems. Moving to UniVerse from PI/open: Describes how to prepare the PI/open environment before converting PI/open applications to run under UniVerse. This book includes step-by-step procedures for converting INFO/BASIC programs, accounts, and les. This book is for experienced PI/open users and does not assume detailed knowledge of UniVerse.

26

UniVerse Basic

/productinfo/alldoc/UNIVERSE10/bas ic/Preface

API DocumentationThe following books document application programming interfaces (APIs) used for developing client applications that connect to UniVerse and UniData servers. Administrative Supplement for APIs: Introduces IBMs six common APIs, and provides important information that developers using any of the common APIs will need. It includes information about the UniRPC, the UCI Cong Editor, the ud_database le, and device licensing. UCI Developers Guide: Describes how to use UCI (Uni Call Interface), an interface to UniVerse and UniData databases from C-based client programs. UCI uses ODBC-like function calls to execute SQL statements on local or remote UniVerse and UniData servers. This book is for experienced SQL programmers. IBM JDBC Driver for UniData and UniVerse: Describes UniJDBC, an interface to UniData and UniVerse databases from JDBC applications. This book is for experienced programmers and application developers who are familiar with UniData and UniVerse, Java, JDBC, and who want to write JDBC applications that access these databases. InterCall Developers Guide: Describes how to use the InterCall API to access data on UniVerse and UniData systems from external programs. This book is for experienced programmers who are familiar with UniVerse or UniData. UniObjects Developers Guide: Describes UniObjects, an interface to UniVerse and UniData systems from Visual Basic. This book is for experienced programmers and application developers who are familiar with UniVerse or UniData, and with Visual Basic, and who want to write Visual Basic programs that access these databases. UniObjects for Java Developers Guide: Describes UniObjects for Java, an interface to UniVerse and UniData systems from Java. This book is for experienced programmers and application developers who are familiar with UniVerse or UniData, and with Java, and who want to write Java programs that access these databases. Using UniOLEDB: Describes how to use UniOLEDB, an interface to UniVerse and UniData systems for OLE DB consumers. This book is27

/productinfo/alldoc/UNIVERSE10/basic/Preface 1/9/02

for experienced programmers and application developers who are familiar with UniVerse or UniData, and with OLE DB, and who want to write OLE DB programs that access these databases.

28

UniVerse Basic

1Administering UniData on Windows NT or Windows 2000 0

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

Chapter

Introduction to UniVerse BASIC

1

BASIC Terminology . . . . . . . Subroutines . . . . . . . . . . Source Syntax . . . . . . . . . Statement Types . . . . . . . . Statement Labels . . . . . . . . Spaces or Tabs . . . . . . . . . Newlines and Sequential File I/O . . Special Characters . . . . . . . . Storing Programs . . . . . . . . Editing Programs . . . . . . . . Editing Programs in UniVerse . . Editing Programs Outside UniVerse Getting Started . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

. . . . . . . . . . . . .

1-4 1-6 1-7 1-8 1-10 1-11 1-12 1-13 1-15 1-16 1-16 1-16 1-17

/productinfo/alldoc/UNIVERSE10/basic/Ch1TOC.fm January 9, 2002 2:13 pm Administering UniData on Windows NT or Windows 2000

/productinfo/alldoc/UNIVERSE10/basic/Ch1TOC.fm January 9, 2002 2:13 pm Administering UniData on Windows NT or Windows 2000

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

1-2 UniVerse Basic

/productinfo/alldoc/UNIVERSE10/bas ic/Ch1

UniVerse BASIC is a business-oriented programming language designed to work efciently with the UniVerse environment. It is easy for a beginning programmer to use yet powerful enough to meet the needs of an experienced programmer. The power of UniVerse BASIC comes from statements and built-in functions that take advantage of the extensive database management capabilities of UniVerse. These benets combined with other BASIC extensions result in a development tool well-suited for a wide range of applications. The extensions in UniVerse BASIC include the following:s s s s s s s s s s s s s s s s

Optional statement labels (that is, statement numbers) Statement labels of any length Multiple statements allowed on one line Computed GOTO statements Complex IF statements Multiline IF statements Priority CASE statement selection String handling with variable length strings up to 2321 characters External subroutine calls Direct and indirect subroutine calls Magnetic tape input and output RetrieVe data conversion capabilities UniVerse le access and update capabilities File-level and record-level locking capabilities Pattern matching Dynamic arrays

1-3

/productinfo/alldoc/UNIVERSE10/basic/Ch1 1/9/02

BASIC TerminologyUniVerse BASIC programmers should understand the meanings of the following terms:s s s s s s

BASIC program Source code Object code Variable Function Keyword

BASIC ProgramA BASIC program is a set of statements directing the computer to perform a series of tasks in a specied order. A BASIC statement is made up of keywords and variables.

Source CodeSource code is the original form of the program written by the programmer.

Object CodeObject code is compiler output, which can be executed by the UniVerse RUN command or called as a subroutine.

VariableA variable is a symbolic name assigned to one or more data values stored in memory. A variables value can be numeric or character string data, the null value, or it can be dened by the programmer, or it can be the result of operations performed by the program. Variable names can be as long as the physical line, but only the rst 64 characters are signicant. Variable names begin with an alphabetic character and can include alphanumeric characters, periods ( . ), dollar signs ( $ ), underscores ( _ ),1 and percent signs ( % ). Upper- and lowercase letters are interpreted as different; that is, REC and Rec are different variables.1-4 UniVerse BASIC

/productinfo/alldoc/UNIVERSE10/bas ic/Ch1

FunctionA BASIC intrinsic function performs mathematical or string manipulations on its arguments. It is referenced by its keyword name and is followed by the required arguments enclosed in parentheses. Functions can be used in expressions; in addition, function arguments can be expressions that include functions. UniVerse BASIC contains both numeric and string functions.s

Numeric functions. BASIC can perform certain arithmetic or algebraic calculations, such as calculating the sine (SIN), cosine (COS), or tangent (TAN) of an angle passed as an argument. String functions. A string function operates on ASCII character strings. For example, the TRIM function deletes extra blank spaces and tabs from a character string, and the STR function generates a particular character string a specied number of times.

s

KeywordA BASIC keyword is a word that has special signicance in a BASIC program statement. The case of a keyword is ignored; for example, READU and readu are the same keyword. For a list of keywords, see BASIC Reserved Words.

1. An underscore cannot be the last character of a variable name. 1-5

/productinfo/alldoc/UNIVERSE10/basic/Ch1 1/9/02

SubroutinesA subroutine is a set of instructions that perform a specic task. It is a small program that can be embedded in a program and accessed with a GOSUB statement, or it can be external to the program and accessed with a CALL statement. Common processes are often kept as external subroutines. This lets the programmer access them from many different programs without having to rewrite them. When a GOSUB or CALL statement is encountered, program control branches to the referenced subroutine. An internal subroutine must begin with a statement label. An external subroutine must begin with a SUBROUTINE statement. A RETURN statement can be used at the end of a subroutine to return program ow to the statement following the last referenced GOSUB or CALL statement. If there is no corresponding CALL or GOSUB statement, the program halts and returns to the UniVerse command level. If an external subroutine ends before a RETURN statement is encountered, a RETURN is provided automatically. Note: If an ABORT, STOP, or CHAIN statement is encountered during subroutine execution, program execution aborts, stops, or chains to another BASIC program and control never returns to the calling program. One or more arguments separated by commas can be passed to the subroutine as an argument list. An argument can be a constant, variable, array variable, or expression, each representing an actual value. The SUBROUTINE argument list must contain the same number of arguments so that the subroutine can reference the values being passed to it. Arguments are passed to subroutines by passing a pointer to the argument. Therefore, arguments can also be used to return values to the calling program.

1-6 UniVerse BASIC

/productinfo/alldoc/UNIVERSE10/bas ic/Ch1

Source SyntaxA BASIC source line has the following syntax:

[ label ] statement [ ; statement ] You can put more than one statement on a line. Separate the statements with semicolons. A BASIC source line can begin with a statement label. It always ends with a carriage return (Return). It can contain up to 256 characters and can extend over more than one physical line.

1-7

/productinfo/alldoc/UNIVERSE10/basic/Ch1 1/9/02

Statement TypesBASIC statements can be used for any of the following purposes:s s s s s

Input and output control Program control Assignment (assigning a value to a variable) Specication (specifying the value of a constant) Documentation

Input statements indicate where the computer can expect data to come from (for example, the keyboard, a particular le, and so on). Output statements control where the data is displayed or stored. In general, BASIC statements are executed in the order in which they are entered. Control statements alter the sequence of execution by branching to a statement other than the next statement, by conditionally executing statements, or by passing control to a subroutine. Assignment statements assign values to variables, and specication statements assign names to constants. Program documentation is accomplished by including optional comments that explain or document various parts of the program. Comments are part of the source code only and are not executable. They do not affect the size of the object code. Comments must begin with one of the following: REM * ! $*

Any text that appears between a comment symbol and a carriage return is treated as part of the comment. Comments cannot be embedded in a BASIC statement. If you want to put a comment on the same physical line as a statement, you must end the statement with a semicolon ( ; ), then add the comment, as in the following example:IF X THEN A = B; REM correctly formatted comment statement B = C END

1-8 UniVerse BASIC

/productinfo/alldoc/UNIVERSE10/bas ic/Ch1

You cannot put comments between multiple statements on one physical line. For example, in the second line of the following program the statement B = C is part of the comment and is not executed:IF X THEN A = B; REM The rest of this line is a comment; B = C END

However, you can put comments in the middle of a statement that occupies more than one physical line, as in the following example:A = 1 B = 2 IF A = REM comment PRINT A REM comment END ELSE PRINT B

1-9

/productinfo/alldoc/UNIVERSE10/basic/Ch1 1/9/02

Statement LabelsA statement label is a unique identier for a program line. A statement label consists of a string of characters followed by a colon. The colon is optional when the statement label is completely numeric. Like variable names, alphanumeric statement labels begin with an alphabetic character and can include periods ( . ), dollar signs ( $ ), and percent signs ( % ). Upper- and lowercase letters are interpreted as different; that is, ABC and Abc are different labels. Statement labels, like variable names, can be as long as the length of the physical line, but only the rst 64 characters are signicant. A statement label can be put either in front of a BASIC statement or on its own line. The label must be rst on the linethat is, the label cannot begin with a space.

1-10

UniVerse BASIC

/productinfo/alldoc/UNIVERSE10/bas ic/Ch1

Spaces or TabsIn a program line, spaces or tabs that are not part of a data item are ignored. Therefore you can use spaces or tabs to improve the programs appearance and readability.

1-11

/productinfo/alldoc/UNIVERSE10/basic/Ch1 1/9/02

Newlines and Sequential File I/OUniVerse BASIC uses the term newline to indicate the character or character sequence that denes where a line ends in a record in a type 1 or type 19 le. The newline differs according to the operating system you are using. On UNIX le systems, a newline consists of a single LINEFEED character. On Windows NT le systems, a newline consists of the character sequence RETURN + LINEFEED. UniVerse BASIC handles this difference transparently in nearly every case, but in a few instances the operating system differences become apparent. If you want your program to work on different operating systems, watch sequential le I/O (that is, writing to or reading from type 1 and type 19 les, line by line or in blocks of data). In particular, be aware of the potential differences that occur:s s

When moving a pointer through a le When reading or writing blocks of data of a specied length

1-12

UniVerse BASIC

/productinfo/alldoc/UNIVERSE10/bas ic/Ch1

Special CharactersThe UniVerse BASIC character set comprises alphabetic, numeric, and special characters. The alphabetic characters are the upper- and lowercase letters of the alphabet. The numeric characters are the digits 0 through 9. The special characters are as follows. Most of the special characters are not permitted in a numeric constant or a variable name.Character Description Space Tab = + * ** / ^ ( ) # $ ! [ ] , . Equal sign or assignment symbol Plus sign Minus sign Asterisk, multiplication symbol, or nonexecutable comment Exponentiation Slash or division symbol Up-arrow or exponentiation symbol Left parenthesis Right parenthesis Number (pound or hash) sign or not equal to Dollar sign Exclamation point or nonexecutable comment Left bracket Right bracket Comma (not permitted in numeric data) Period or decimal point UniVerse BASIC Character Set

1-13

/productinfo/alldoc/UNIVERSE10/basic/Ch1 1/9/02

Character ; : & < > @ _

Description Single quotation mark or apostrophe Semicolon Colon or concatenation Ampersand (and) Less than (left angle bracket) Greater than (right angle bracket) At sign Underscore UniVerse BASIC Character Set (Continued)

1-14

UniVerse BASIC

/productinfo/alldoc/UNIVERSE10/bas ic/Ch1

Storing ProgramsBASIC programs are stored as records in type 1 or type 19 les. The program le must exist before you invoke an editor to create a new record to hold your program. Record IDs must follow the conventions for type 1 and type 19 les.

1-15

/productinfo/alldoc/UNIVERSE10/basic/Ch1 1/9/02

Editing ProgramsYou can use the UniVerse Editor or any suitable editor, such as vi on UNIX or edit on Windows NT, to write your programs. You can edit programs in the UniVerse environment or at the operating system level.

Editing Programs in UniVerseOn UNIX systems you can invoke vi from the UniVerse system prompt using this syntax: VI pathname pathname is the relative or absolute pathname of the program you want to edit. For example, the program PAYROLL is stored as a record in the le BP. To edit it with vi, enter: >VI BP/PAYROLL If you want to use vi, or any other editor, directly from UniVerse, you can create a VOC entry that invokes your chosen editor. For example, this VOC entry calls edit from UniVerse on Windows NT:EDIT 001 V 002 \win25\edit.com 003 PR

Editing Programs Outside UniVerseWhen you invoke an editor at the operating system level, remember that the UniVerse le holding the programs is implemented as a directory at the operating system level. For example, the YEAR.END program is stored as a record in the BP le in UniVerse. Its operating system pathname is BP\YEAR.END on Windows NT systems and BP/YEAR.END on UNIX systems.

1-16

UniVerse BASIC

/productinfo/alldoc/UNIVERSE10/bas ic/Ch1

Getting StartedTo create and use a BASIC program, follow these steps:1.

Use the CREATE.FILE command to create a type 1 or type 19 UniVerse le to store your BASIC program source. The RUN command uses the lename BP if a lename is not specied, so many people use BP as the name of their general BASIC program le. Use the UniVerse Editor or some other editor to create the source for your BASIC program as a record in the le you created in step 1. Once you have created the record containing your BASIC program source statements, use the BASIC command to compile your program. The BASIC command creates a le to contain the object code output by the compiler. You do not have to know the name of the object le because the program is always referred to by the source lename. If the BASIC compiler detects any errors, use the Editor to correct the source code and recompile using the BASIC command. When your program compiles without any errors, execute it using the RUN command. Use the RAID command to debug your program.

2. 3.

4. 5.

1-17

/productinfo/alldoc/UNIVERSE10/basic/Ch1 1/9/02

1-18

UniVerse BASIC

1Administering UniData on Windows NT or Windows 2000 0

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

Chapter

Data Types, Variables, and OperatorsTypes of Data . . . . . . . . Character String Data . . . . Numeric Data . . . . . . . Unknown Data: The Null Value. Constants . . . . . . . . . . Variables . . . . . . . . . . Array Variables . . . . . . File Variables . . . . . . . Select List Variables . . . . . Expressions . . . . . . . . . Format Expressions . . . . . Operators . . . . . . . . . . Arithmetic Operators . . . . String Operators . . . . . . Relational Operators . . . . Pattern Matching Operators . . IF Operator . . . . . . . . Logical Operators . . . . . Assignment Operators . . . . Dynamic Array Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-4 2-4 2-5 2-6 2-8 2-9 2-10 2-14 2-14 2-15 2-15 2-17 2-17 2-19 2-22 2-23 2-24 2-24 2-26 2-27

2

/productinfo/alldoc/UNIVERSE10/basic/Ch2TOC.fm January 9, 2002 2:13 pm Administering UniData on Windows NT or Windows 2000

/productinfo/alldoc/UNIVERSE10/basic/Ch2TOC.fm January 9, 2002 2:13 pm Administering UniData on Windows NT or Windows 2000

Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta Beta

2-2 UniVerse Basic

/productinfo/alldoc/UNIVERSE10/bas ic/Ch2

This chapter gives an overview of the fundamental components of the UniVerse BASIC language. It describes types of data, constants, variables, and how data is combined with arithmetic, string, relational, and logical operators to form expressions.

2-3

/productinfo/alldoc/UNIVERSE10/basic/Ch2 1/9/02

Types of DataAlthough many program languages distinguish different types of data, the UniVerse BASIC compiler does not. All data is stored internally as character strings, and data typing is done contextually at run time. There are three main types of data: character string, numeric, and unknown (that is, the null value).

Character String DataCharacter string data is represented internally as a sequence of ASCII characters. Character strings can represent either numeric or nonnumeric data. Their length is limited only by the amount of available memory. Numeric and nonnumeric data can be mixed in the same character string (for example, in an address). In NLS mode all data is held in the UniVerse internal character set. In all UniVerse I/O operations, data is converted automatically by applying the map specied for a le or a device. One character can be more than one byte long and can occupy zero or more positions on the screen. UniVerse BASIC provides functions so that programs can determine what these characteristics are. For more information about character sets, see UniVerse NLS Guide.

Character String ConstantsIn BASIC source code, character string constants are a sequence of ASCII characters enclosed in single or double quotation marks, or backslashes ( \ ). These marks are not part of the character string value. The length of character string constants is limited to the length of a statement. Some examples of character string constants are the following:"Emily Daniels" '$42,368.99' 'Number of Employees' "34 Cairo Lane" \"Fred's Place" isn't open\

The beginning and terminating marks enclosing character string data must match. In other words, if you begin a string with a single quotation mark, you must end the string with a single quotation mark.2-4 UniVerse BASIC

/productinfo/alldoc/UNIVERSE10/bas ic/Ch2

If you use either a double or a single quotation mark within the character string, you must use the opposite kind to begin and end the string. For example, this string should be written:"It's a lovely day."

And this string should be written:'Double quotation marks (") enclosing this string would be wrong.'

The empty string is a special instance of character string data. It is a character string of zero length. Two adjacent double or single quotation marks, or backslashes, specify an empty string:'' or "" or \\

In your source code you can use any ASCII character in character string constants except ASCII character 0 (NUL), which the compiler interprets as an end-of-string character, and ASCII character 10 (linefeed), which separates the logical lines of a program. Use CHAR(0) and CHAR(10) to embed these characters in a string constant.

Numeric DataAll numeric data is represented internally either as oating-point numbers with the full range of values supported by the systems oating-point implementation, or as integers. On most systems the range is from 10-307 through 10+307 with 15 decimal digits of precision.

Numeric ConstantsNumeric constants can be represented in either xed-point or oating-point form. Commas and spaces are not allowed in numeric constants.

2-5

/productinfo/alldoc/UNIVERSE10/basic/Ch2 1/9/02

Fixed-Point Constants.Fixed-point form consists of a sequence of digits, optionally containing a decimal point and optionally preceded by a plus ( + ) or minus ( ) sign. Some examples of valid xed-point constants are:12 -132.4 +10428

Floating-Point Constants.Floating-point form, which is similar to scientic notation, consists of a sequence of digits, optionally preceded by a plus ( + ) or minus ( ) sign representing the mantissa. The sequence of digits is followed by the letter E and digits, optionally preceded by a minus sign, representing the power of 10 exponent. The exponent must be in the range of 307 through +307. Some examples of valid oating-point constants are:1.2E3 -7.3E42 -1732E-4

Use the PRECISION statement to set the maximum number of fractional digits that can result from converting numbers to strings.

Unknown Data: The Null ValueThe null value has a special run-time data type in UniVerse BASIC. It was added to UniVerse BASIC for compatibility with UniVerse SQL. The null value represents data whose value is unknown. Note: Do not confuse the null value with the empty string. The empty string is a character string of zero length which is known to have no value. Unlike null, whose value is dened as unknown, the value of the empty string is known. You cannot use the empty string to represent the null value, nor can you use the null value to represent no value.

2-6 UniVerse BASIC

/productinfo/alldoc/UNIVERSE10/bas ic/Ch2

Like all other data in UniVerse BASIC, the null value is represented internally as a character string. The string is made up of the single byte CHAR(128). At run time when explicit or implicit dynamic array extractions are executed on this character, it is assigned the data type null. UniVerse BASIC programs can reference the null value using the system variable @NULL. They can test whether a value is the null value using the ISNULL and ISNULLS functions. There is no printable representation of the null value. In this manual the symbol (lambda) is sometimes used to denote the null value. Here is an example of the difference between an empty string and the null value. If you concatenate a string value with an empty string, the string value is returned, but if you concatenate a string value with the null value, null is returned.A B C X Y = = = = = @NULL "" "JONES" C:B C:A

The resulting value of X is "JONES", but the value of Y is the null value. When you concatenate known data with unknown data, the result is unknown. Programmers should also note the difference between the null valuea special constant whose type is nulland the stored representation of the null valuethe special character CHAR(128) whose type is string. BASIC programs can reference the stored representation of null using the system variable @NULL.STR instead of @NULL.

2-7

/productinfo/alldoc/UNIVERSE10/basic/Ch2 1/9/02

ConstantsConstants are data that do not change in value, data type, or length during program execution. Constants can be character strings or numeric strings (in either integer or oating-point form). A character string of no characters the empty stringcan also be a constant.

2-8 UniVerse BASIC

/productinfo/alldoc/UNIVERSE10/bas ic/Ch2

VariablesVariables are symbolic names that represent stored data values. The value of a variable can be:s s

Unassigned A string, which can be an alphanumeric character string, a number, or a dynamic array A number, which can be xed-point (an integer) or oating-point The null value A dimensioned array (that is, a vector or matrix) A subroutine name A le A select list

s s s s s s

The value of a variable can be explicitly assigned by the programmer, or it can be the result of operations performed by the program during execution. Variables can change in value during program execution. At the start of program execution, all variables are unassigned. Any attempt to use an unassigned variable produces an error message. A variable name must begin with an alphabetic character. It can also include one or more digits, letters, periods, dollar signs, underscores, or percent signs. Spaces and tabs are not allowed. A variable name can be any length up to the length of the physical line, but only the rst 64 characters are significant. A variable name cannot be any of the reserved words listed in BASIC Reserved Words.. In UniVerse, upper- and lowercase characters in a variable name are interpreted differently. UniVerse BASIC also provides a set of system variables called @variables. Many of these are read-only variables. Read-only @variables cannot be changed by the programmer. Most variables in BASIC remain available only while the current program or subroutine is running. Unnamed common variables, however, remain available until the program returns to the system prompt. Named common variables and @variables remain available until the user logs out of UniVerse. See the COMMON statement for information about named and unnamed common variables.2-9

/productinfo/alldoc/UNIVERSE10/basic/Ch2 1/9/02

In NLS mode you can include characters outside the ASCII character set only as constants dened by the $DEFINE and EQUATE statements, or as comments. Everything else, including variable names, must use the ASCII character set. For more information about character sets, see UniVerse NLS Guide.

Array VariablesAn array is a variable that represents more than one data value. There are two types of array: dimensioned and dynamic. Dimensioned arrays can be either standard or xed. Fixed arrays are provided in PICK, IN2, and REALITY avor accounts for compatibility with other Pick systems.

Dimensioned ArraysEach value in a dimensioned array is called an element of the array. Dimensioned arrays can be one- or two-dimensional. A one-dimensional array is called a vector. Its elements are arranged sequentially in memory. An element of a vector is specied by the variable name followed by the index of the element enclosed in parentheses. The index of the rst element is 1. The index can be a constant or an expression. Two examples of valid vector element speciers are:A(1) COST(35)

A two-dimensional array is called a matrix. The elements of the rst row are arranged sequentially in memory, followed by the elements of the second row, and so on. An element of a matrix is specied by the variable name followed by two indices enclosed in parentheses. The indices represent the row and column position of the element. The indices of the rst element are (1,1). Indices can be constants or expressions. The indices used to specify the elements of a matrix that has four columns and three rows are illustrated by the following:1,1 2,1 3,1 1,2 2,2 3,2 1,3 2,3 3,3 1,4 2,4 3,4

2-10

UniVerse BASIC

/productinfo/alldoc/UNIVERSE10/bas ic/Ch2

Two examples of valid matrix element speciers are:OBJ(3,1) WIDGET(7,17)

Vectors are treated as matrices with a second dimension of 1. COST(35) and COST(35,1) are equivalent specications and can be used interchangeably. Both vectors and matrices have a special zero element that is used in MATPARSE, MATREAD, and MATWRITE statements. The zero element of a vector is specied by vector.name(0), and the zero element of a matrix is specied by matrix.name(0,0). Zero elements are used to store elds that do not t in the dimensioned elements on MATREAD or MATPARSE statements. Dimensioned arrays are allocated either at compile time or at run time, depending on the avor of the account. Arrays allocated at run time are called standard arrays. Arrays allocated at compile time are called xed arrays. Standard arrays are redimensionable; xed arrays are not redimensionable and do not have a zero element. All arrays are standard unless the program is compiled in a PICK, IN2, or REALITY avor account, in which case they are xed arrays. To use xed arrays in PIOPEN, INFORMATION and IDEAL avor accounts, use the STATIC.DIM option of the $OPTIONS statement. To use standard arrays in PICK, IN2, and REALITY avor accounts, use $OPTIONS STATIC.DIM.

Dynamic ArraysDynamic arrays map the structure of UniVerse le records to character string data. Any character string can be a dynamic array. A dynamic array is a character string containing elements that are substrings separated by delimiters. At the highest level these elements are elds separated by eld marks ( F ) (ASCII 254). Each eld can contain values separated by value marks ( V ) (ASCII 253). Each value can contain subvalues separated by subvalue marks ( S ) (ASCII 252). A common use of dynamic arrays is to store data that is either read in from or written out to a UniVerse le record. However, UniVerse BASIC includes facilities for manipulating dynamic array elements that make dynamic arrays a powerful data type for processing hierarchical information independently of UniVerse les.

2-11

/productinfo/alldoc/UNIVERSE10/basic/Ch2 1/9/02

The number of elds, values, or subvalues in a dynamic array is limited only by the amount of available memory. Fields, values, and subvalues containing the empty string are represented by two consecutive eld marks, value marks, or subvalue marks, respectively. The following character string is a dynamic array with two elds:TOMSDICKSHARRYVBETTYSSUESMARYFJONESVSMITH

The two elds are:TOMSDICKSHARRYVBETTYSSUESMARY

and:JONESVSMITH

Conceptually, this dynamic array has an innite number of elds, all of which are empty except the rst two. References made to the third or fourth eld, for example, return an empty string. The rst eld has two values:TOMSDICKSHARRY

and:BETTYSSUESMARY

The rst value has three subvalues: TOM, DICK, and HARRY. The second value also has three subvalues: BETTY, SUE, and MARY. The second eld has two values: JONES and SMITH. Each value has one subvalue: JONES and SMITH. The following character string:NAME AND ADDRESS

can be considered a dynamic array containing one eld, which has one value, which has one subvalue, all of which are: NAME AND ADDRESS. The following character string can be considered a dynamic array containing two elds:JONESVSMITHVBROWNF$1.23VV$2.75

The rst eld has three values: JONES, SMITH, and BROWN. The second eld has three values: $1.23, an empty string, and $2.752-12 UniVerse BASIC

/productinfo/alldoc/UNIVERSE10/bas ic/Ch2

Intrinsic functions and operators allow individual subvalues, values, and elds to be accessed, changed, added, and removed. You can create a dynamic array in two ways: by treating it as a concatenation of its elds, values, and subvalues; or by enclosing the elements of the dynamic array in angle brackets, using the syntax:array.name < field# , value# , subvalue# >

For example, to create the dynamic array A as:JONESVSMITHF1.23S20V2.50S10

you can say:A="JONES":@VM:"SMITH":@FM:1.23:@SM:20:@VM:2.50:@SM:10

or you can say:A = "" A = A = A A A A "JONES" "SMITH" = 1.23 = 20 = 2.50 = 10

The example has two elds. The rst eld has two values, and the second eld has two values. The rst value of the second eld has two subvalues, and the second value of the second eld also has two subvalues. You must use the following statements to declare that the rst eld contains the two values JONES and SMITH:A = "" A = "JONES" A = "SMITH"

The statement:A = "" A = "JONES"

declares that the rst eld contains only JONES with no other values or subvalues. Similarly, the statement:A = 1.23

2-13

/productinfo/alldoc/UNIVERSE10/basic/Ch2 1/9/02

declares that the rst value of the second eld is 1.23 with no subvalues. The statements:A = 2.50 A = 10

declare that the second value of the second eld has two subvalues, 2.50 and 10, respectively.

File VariablesA le variable is created by a form of the OPEN statement. Once opened, a le variable is used in I/O statements to access the le. There are two types of le variable: hashed le variable and sequential le variable. File variables can be scalars or elements of a dimensioned array.

Select List VariablesSelect list variables are created by a form of the SELECT statement. A select list variable contains a select list and can be used only in READNEXT statements. Unlike other variables, a select list variable cannot be an element of a dimensioned array.

2-14

UniVerse BASIC

/productinfo/alldoc/UNIVERSE10/bas ic/Ch2

ExpressionsAn expression is part of a BASIC statement. It can comprise:s s s s s

A string or numeric constant A variable An intrinsic function A user-dened function A combination of constants, variables, operators, functions, and other expressions

Format ExpressionsA format expression formats variables for output. It species the size of the eld in which data is displayed or printed, the justication (left, right, or text), the number of digits to the right of the decimal point to display, and so on. Format expressions work like the FMT function. The syntax is: variable format format is a valid string expression that evaluates to:

[ width ] [ background ] justication [ edit ] [ mask ]Either width or mask can specify the size of the display eld. background species the character used to pad the eld (Space is the default padding character). You must specify justication as left, right, or text (text left-justies output, but breaks lines on spaces when possible). edit species how to format numeric data for output, including such things as the number of digits to display to the rig


Recommended