Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to BASIC Programming Ken R. Hall, Ph.D. Ken R. Hall Consultants Portland, Oregon.

Similar presentations


Presentation on theme: "Introduction to BASIC Programming Ken R. Hall, Ph.D. Ken R. Hall Consultants Portland, Oregon."— Presentation transcript:

1 Introduction to BASIC Programming Ken R. Hall, Ph.D. Ken R. Hall Consultants Portland, Oregon

2 Speaker’s Qualifications Ken Hall is a PICK/SHIMS consultant and owner of Ken R. Hall Consultants. Ken has over 25 years experience developing applications in PICK, Universe, and Unidata. Ken is a reseller of IBM U2 (Universe) and Raining Data database products. Ken has developed business applications for distributors, retailers, mail order houses, manufacturers, and leasing companies.

3 Learning Objectives As a result of this presentation, you will be able to: –Look at a BASIC program with an editor –Read the statements in a BASIC program –Know where to look for more information when you don’t understand the program

4 Presentation Agenda Concepts and Terminology Creating and Viewing Programs An Introduction to commonly used BASIC statements Where to find more information about BASIC

5 UniVerse Database Concepts Multivalue database structure –Accounts and Files –Keys or Item-Ids –Variable length Record Structure Each subdivision has a separator character –Records or Items Fields or Attributes –Values within Fields »Subvalues within Values

6 Terminology of PICK/BASIC Statements – a line of BASIC code CUST.NO = CUSTOMER.REC Constants and Literals – things that don’t change OK.RESPONSE = “YES” Assignment Statements – changing values NUMBER.PRODS = 0 Functions – things available from the system TODAY = DATE() Operators – symbols that associate variables –Arithmetic, Logical, or String +, -, *, /; #, =, GE, LE, LT, GT; :

7 Creating and Viewing Programs Create a File to store programs –CREATE.FILE YOURBP Naming a program Use the Editor, ED or WED, to create/edit a program –ED YOURBP YOUR.PROGRAM Compile the program with BASIC command –BASIC YOURBP YOUR.PROGRAM Activate the program with RUN command –RUN YOURBP YOUR.PROGRAM Activate the program with CATALOG command –CATALOG YOURBP YOUR.PROGRAM

8 Fundamental BASIC Statements PROMPT PRINT CRT or DISPLAY INPUT END STOP IF … THEN … ELSE LEN(), ABS(), DATE(),TIME OPEN READ WRITE GO or GOTO * comments for clarity * looping FOR NEXT LOOP UNTIL or WHILE REPEAT * finding records SELECT READNEXT

9 Adding Comments for Clarity Comment lines start with *, !, or REM –* PROGRAM TO PRINT INVOICES FOR XYZ COMPANY –! This line is also a comment Programs often start with comments that explain the purpose of the program and the author Comment lines can be used as spacers for clarity –* –* TODAY is a constant to store the current date –TODAY = DATE() –* Comments document modifications to the program

10 Simple Input of Information PROMPT defines the character displayed when user input is requested by the program –* send the colon when input is requested –PROMPT ‘:’ INPUT requests user input from the keyboard –Puts prompt character at current cursor position –Input is completed by hitting Enter key –INPUT CUSTOMER.NAME Input can be positioned and/or formatted –INPUT @(ROW,COL):CUSTOMER.NAME

11 Output of Data PRINT sends data to either screen or printer –Controlled with PRINTER ON or PRINTER OFF statements –PRINT “This is a test of output” –PRINT CUSTOMER.NAME CRT sends data to the screen –CRT YOUR.NAME Output can be positioned and/or formatted –PRINT @(ROW,COL):CUSTOMER.NAME “L#25”

12 Marking the END The END statement is used to: –Marks the end of the program * the last line is below END –Marks the end of a multi-line statement IF DAYS.PAST.DUE > “90” THEN PRINT “OVER 90 DAYS PAST DUE” END The STOP statement causes the program to terminate. * the next line exits this program after Q is typed IF DATA.INPUT = ‘Q’ THEN STOP END

13 Logical Control with IF … THEN Single line statement: IF X > “10” THEN PRINT “More than ten” ELSE PRINT “Ten or less” Multi-line IF statement: IF X > “10” THEN PRINT “X is greater than ten” END ELSE PRINT “X is ten or less” END

14 Logical Control with LOOP Single line LOOP statement: X = 0 LOOP X = X + 5 WHILE X < 100 DO PRINT “X is ”: X REPEAT * Go here when X is equal to or greater than 100 Multi-line LOOP statement: X = 0 LOOP X = X + 5 WHILE X < 100 DO PRINT “X is ”:X REPEAT * Go here when X is equal to or greater than 100

15 OPEN file and READ data Use OPEN to gain acces to a file OPEN ‘CUSTOMER’ TO CUST.FILE ELSE STOP Use READ to read a record from a file CUST.NO = ‘1023’ READ CUSTOMER.REC CUST.FILE, CUST.NO THEN CRT CUSTOMER.REC ; * display customer name END ELSE CRT ‘CUSTOMER ‘:CUST.NO:’ not found’

16 WRITE data to a file Use WRITE to save data to a record WRITE CUSTOMER.REC ON CUST.FILE, CUST.NO Use WRITEV to save a variable in a field CUST.NO = ‘1023’ CUSTOMER.NAME = “ABC ELECTRIC CO.” WRITEV CUSTOMER.NAME ON CUST.FILE, CUST.NO, 1 Corresponding READV reads a field READ V CUSTOMER.NAME FROM CUST.FILE, CUST.NO, 1 ELSE CUSTOMER.NAME = ‘UNKNOWN’ END

17 Sample BASIC Program * A simple program that opens a file and reads data PROMPT '' 10: CRT 'Enter first file name: ': INPUT F1 IF F1 = '' OR F1 = 'X' OR F1 = "." THEN STOP OPEN F1 TO FILE1 ELSE CRT 'CANNOT open file ':F1 GO 10 END READ TEST.REC FROM FILE1, ‘TEST’ THEN CRT ‘TEST.REC IS ‘:TEST.REC END ELSE CRT ‘TEST IS NOT ON FILE’ END STOP END

18 PICK BASIC Book Jonathan E. Sisk's Pick/BASIC: A Programmer's Guide Found on the web at: http://www.jes.com/pb/index.html

19 IBM UniVerse Documentation To view or get copy of UniVerse BASIC manual, follow the link below: Found on the web at: http://www-306.ibm.com/software/data /u2/pubs/library/ Click on UniVerse version that you want. Choose “install doc set” to download the entire UV documentation set with installer.

20 Q&A

21 Thank You! Ken R. Hall Ken R. Hall Consultants kenrhall@old-scholls.com 503-702-7841


Download ppt "Introduction to BASIC Programming Ken R. Hall, Ph.D. Ken R. Hall Consultants Portland, Oregon."

Similar presentations


Ads by Google