Download MaxBasic Tutorial and User's Guide Basic Programming for

Transcript
Siemens Applied Automation
Pre-release product information
DRAFT;8 October, 1999
MaxBasic_User's_Guide.doc; Page 2 of 40
\.................................................................................................................... Fehler! Textmarke nicht definiert.
Introduction and Prerequisites ..............................................................................................................................4
Installing MaxBasic..............................................................................................................................................4
Development Environment...................................................................................................................................5
Writing a MaxBasic program ...........................................................................................................................5
Opening the .bas file.....................................................................................................................................5
Editing ..........................................................................................................................................................7
Saving the .bas file .......................................................................................................................................7
Testing on the Workstation...............................................................................................................................7
Connecting to the database ...........................................................................................................................8
Setting Input Parameters...............................................................................................................................8
Running the Program....................................................................................................................................9
Correcting the Program ..............................................................................................................................10
Downloading and Testing on the Maxum ......................................................................................................10
Working with the Program Table ...................................................................................................................11
Scheduling MaxBasic Programs to Run .........................................................................................................12
Frequency/Time of Day..............................................................................................................................12
Event...........................................................................................................................................................12
MaxBasic programming .....................................................................................................................................12
Declaring Variables ........................................................................................................................................12
Variable names ...........................................................................................................................................13
Variable Scope............................................................................................................................................13
Data types ...................................................................................................................................................13
Arrays .........................................................................................................................................................13
Program Control .............................................................................................................................................13
Do….Loop..................................................................................................................................................13
For….Next..................................................................................................................................................13
If..Then…elseif….else….endif ..................................................................................................................14
Select Case .................................................................................................................................................14
Extracting Information from the Database .....................................................................................................14
Table...........................................................................................................................................................14
Snapshot .....................................................................................................................................................14
Dynaset.......................................................................................................................................................14
Recordset Navigation .....................................................................................................................................15
MoveFirst, MoveLast, MoveNext, MovePrevious .....................................................................................15
FindFirst, FindLast, FindNext, FindPrevious .............................................................................................15
Changing information in the Database ...........................................................................................................16
Setting Database Attributes from MaxBasic ..............................................................................................16
Using Table and Dynaset Objects...............................................................................................................16
Using SQL Update .....................................................................................................................................17
MaxBasic Quick Reference ................................................................................................................................18
SQL Quick Reference.........................................................................................................................................21
Primary Keys..................................................................................................................................................21
Data Types......................................................................................................................................................21
SQL Built-in Functions ..................................................................................................................................21
Conditions ......................................................................................................................................................22
Select Statement .............................................................................................................................................22
Update Statement ...........................................................................................................................................23
Send Statement ...............................................................................................................................................23
Some Database Tables........................................................................................................................................24
APPLICATION..............................................................................................................................................24
STREAM........................................................................................................................................................25
PROGRAM ....................................................................................................................................................26