703
Copyright © 1996-2019 by PowerBASIC Tools, LLC. All Rights Reserved. PowerBASIC Console Compiler Version 5

PowerBASIC Console Compiler Version 5 Console Compiler v5.0.pdfPowerBASIC Console Compiler Version 5 2 / 703 Table of contents Home ..... 26

  • Upload
    others

  • View
    111

  • Download
    9

Embed Size (px)

Citation preview

  • Copyright © 1996-2019 by PowerBASIC Tools, LLC. All Rights Reserved.

    PowerBASIC ConsoleCompiler Version 5

  • PowerBASIC Console Compiler Version 5

    2 / 703

    Table of contents

    Home ............................................................................................................. 26Introducing PB/CC 5 for Windows ...................................................................... 26What's New ..................................................................................................... 28

    New Statements and Functions ...................................................................... 28Changes to existing Statements and Functions ................................................. 31Additional Changes ...................................................................................... 33New in the IDE ............................................................................................ 35

    Users Guide .................................................................................................... 36Running PB/CC ............................................................................................ 36

    Running PB/CC ........................................................................................ 36Running PB/CC from Windows .................................................................. 37Running PB/CC from DOS ......................................................................... 37PB/CC Command Line Switches ................................................................. 38

    The Integrated Development Environment ...................................................... 38The Integrated Development Environment .................................................. 38The PowerBASIC User Interface ................................................................ 39Toolbar Buttons ....................................................................................... 40Editor Hot Keys ........................................................................................ 41IDE Context Menu .................................................................................... 43File Templates ......................................................................................... 44Project Files ............................................................................................ 45Custom Help Files .................................................................................... 45IDE Dialogs ............................................................................................. 46

    Code Finder Dialog Box ........................................................................ 46Command Line Dialog Box .................................................................... 46Debugger Evaluate Dialog Box ............................................................... 47Find Dialog Box ................................................................................... 47Go to Line Dialog Box ........................................................................... 47Primary Source File Dialog Box .............................................................. 48Replace Dialog Box .............................................................................. 48

    IDE Options ............................................................................................ 48IDE Options ........................................................................................ 48Browsing for Include folders ................................................................. 49Compiler Preferences ........................................................................... 50Editor Preferences ................................................................................ 52Editor Text Preferences ......................................................................... 53File Preferences ................................................................................... 54General Preferences ............................................................................. 55Printer Preferences ............................................................................... 56Syntax Color Preferences ...................................................................... 56Syntax Color Selector ........................................................................... 58Syntax Custom Color Selector ............................................................... 58

    Writing Programs in PBCC ............................................................................ 59

  • PowerBASIC Console Compiler Version 5

    3 / 703

    Writing Programs in PBCC ........................................................................ 59What is a Console? ................................................................................... 59Hello, World! Example .............................................................................. 60Creating Programs ................................................................................... 60Line numbers and Labels .......................................................................... 62Long lines ............................................................................................... 63Statement separation ................................................................................ 63Structured Programming .......................................................................... 64Variables ................................................................................................. 65

    Debugging PB/CC Programs .......................................................................... 66Debugging PB/CC Programs ...................................................................... 66How the integrated debugger works ........................................................... 67The DEBUG Menu .................................................................................... 67Debugging a simple program .................................................................... 69

    Debugging a simple program ................................................................ 69TWORD.BAS Source Listing .................................................................. 70Setting and using breakpoints ............................................................... 72Tracing execution ................................................................................ 72Evaluating a variable ............................................................................ 73Summary ............................................................................................ 74

    The PowerBASIC COM Browser ..................................................................... 74The PowerBASIC COM Browser ................................................................. 74The PowerBASIC COM Browser user interface ............................................. 75The PowerBASIC COM Browser Menu ........................................................ 76The PowerBASIC COM Browser Toolbar ..................................................... 77Shortcut Keys .......................................................................................... 78Registered Type Library View .................................................................... 78Source Code View .................................................................................... 79Getting Help ............................................................................................ 80Opening a type-library .............................................................................. 81Saving the Source Code ............................................................................ 81Options Dialog ........................................................................................ 82The PowerBASIC COM Browser Tutorial ..................................................... 83

    Programming Reference ................................................................................... 89Programming Reference ............................................................................... 89Data Types .................................................................................................. 90

    Data Types .............................................................................................. 90Integer Data Types .................................................................................. 91

    Byte (?) .............................................................................................. 91Double-word (???) ............................................................................... 91Integers (%) ....................................................................................... 92Long integers (&) ................................................................................. 93Quad integers (&&) .............................................................................. 93Word (??) ........................................................................................... 94

    Floating Point Data Types ......................................................................... 94

  • PowerBASIC Console Compiler Version 5

    4 / 703

    Currency (@) and Extended-currency (@@) ............................................ 94Double-precision floating-point (#) ........................................................ 95Extended-precision floating-point (##) .................................................. 96Single-precision floating-point (!) ........................................................... 97

    String Data Types .................................................................................... 97ASCIIZ strings ..................................................................................... 97Dynamic (Variable-length) strings ($) ..................................................... 98FIELD strings ....................................................................................... 99Fixed-length strings .............................................................................. 99String expressions .............................................................................. 100String Operations ............................................................................... 101

    Array Data Types ................................................................................... 115Array Data Types ............................................................................... 115Subscripts ......................................................................................... 116String arrays ...................................................................................... 117Multidimensional arrays ...................................................................... 118Array storage requirements ................................................................. 118Internal representations of arrays ......................................................... 119Arrays within User-Defined Types ........................................................ 119Array operations ................................................................................ 120

    User-Defined Types and Unions ............................................................... 120User-Defined Types (UDTs) ................................................................. 120Defining User-Defined Types ............................................................... 121Accessing the fields of a User-Defined Type .......................................... 122Nesting User-Defined Types ................................................................ 122Arrays within User-Defined Types ........................................................ 123Using arrays of User-Defined Types ..................................................... 124Using User-Defined Types with procedures and functions ....................... 124Storage requirements and restrictions ................................................... 125Built-in User Defined Types ................................................................. 126Unions .............................................................................................. 127

    Unions .......................................................................................... 127Storage requirements and restrictions ............................................... 127

    Pointer Data Types ................................................................................. 128Pointers (@) ...................................................................................... 128Pointers to ASCIIZ and fixed-length strings ........................................... 131Pointers to arrays ............................................................................... 132Pointers to arrays with dual indexes ..................................................... 134

    Constants .............................................................................................. 134Constants and Literals ......................................................................... 134Defining Constants ............................................................................. 135Numeric Equates ................................................................................ 136Built-in numeric equates ..................................................................... 138Built In RGB Color Equates .................................................................. 139String Equates ................................................................................... 143

  • PowerBASIC Console Compiler Version 5

    5 / 703

    Built-in string equates ......................................................................... 144Bit Data Types ....................................................................................... 145GUID Data Types ................................................................................... 145Object Data Types .................................................................................. 146Variant Data Types ................................................................................. 147Comparative Data Types ......................................................................... 149

    C/C++ .............................................................................................. 149Delphi ............................................................................................... 150Visual Basic 6 .................................................................................... 151

    Variables and Variable Scope ....................................................................... 152Variables ............................................................................................... 152Default Variable Typing .......................................................................... 152Variable Scope ....................................................................................... 153THREADED variables .............................................................................. 154LOCAL, GLOBAL and STATIC considerations ............................................ 155

    Operators .................................................................................................. 156Arithmetic Operators .............................................................................. 156Relational Operators ............................................................................... 157Operator Precedence .............................................................................. 158

    Files ......................................................................................................... 159Files ..................................................................................................... 159Sequential Files ...................................................................................... 159Random Access Files .............................................................................. 160Binary Files ............................................................................................ 162

    Errors and Error Trapping ........................................................................... 163Error Overview ...................................................................................... 163Numeric Errors ...................................................................................... 163Error range ........................................................................................... 164User-defined Errors ................................................................................ 164Compile Time Errors .............................................................................. 164

    Compile-time errors ........................................................................... 164Error 401 - Expression too long/complex .............................................. 165Error 402 - Statement too long/complex ............................................... 165Error 403 - #IF nesting overflow ......................................................... 165Error 404 - #INCLUDE file/Macro nesting overflow ................................ 165Error 405 - Block nesting overflow ....................................................... 166Error 406 - Compiler out of memory .................................................... 166Error 407 - Source line too long .......................................................... 166Error 408 - Wrong compiler for this program ........................................ 166Error 409 - Sub/Function/Method/Property is too large ........................... 166Error 411 - "," expected ...................................................................... 167Error 412 - ";" expected ...................................................................... 167Error 413 - "(" expected ...................................................................... 167Error 414 - ")" expected ...................................................................... 167Error 415 - "=" expected ..................................................................... 167

  • PowerBASIC Console Compiler Version 5

    6 / 703

    Error 416 - "-" expected ...................................................................... 167Error 417 - "*" expected ..................................................................... 168Error 418 - Statement expected ........................................................... 168Error 419 - Label/line number expected ................................................ 168Error 420 - Relational operator expected ............................................... 168Error 421 - String operand expected .................................................... 168Error 422 - Scalar variable expected ..................................................... 168Error 423 - Array variable expected ...................................................... 168Error 424 - Numeric variable expected .................................................. 169Error 425 - String variable expected ..................................................... 169Error 426 - Variable expected .............................................................. 169Error 427 - Integer constant expected .................................................. 169Error 428 - Positive integer constant expected ....................................... 169Error 429 - String constant expected .................................................... 169Error 430 - Integer variable expected ................................................... 170Error 431 - Numeric scalar variable expected ......................................... 170Error 432 - Long-integer variable expected ........................................... 170Error 433 - Matrix array expected (integer/float) .................................... 170Error 434 - End of line expected .......................................................... 170Error 435 - #IF expected .................................................................... 170Error 436 - #ENDIF expected .............................................................. 171Error 437 - AS expected ..................................................................... 171Error 438 - Member name expected ..................................................... 171Error 439 - GOSUB expected ............................................................... 171Error 440 - GOTO expected ................................................................ 171Error 441 - IN expected ...................................................................... 171Error 442 - THEN expected ................................................................. 171Error 443 - TO expected ..................................................................... 172Error 444 - WITH expected ................................................................. 172Error 445 - OF expected ..................................................................... 172Error 446 - FUNCTION expected .......................................................... 172Error 447 - IF expected ....................................................................... 172Error 448 - DO loop expected .............................................................. 172Error 449 - SELECT expected .............................................................. 172Error 450 - CASE expected .................................................................. 173Error 451 - FOR loop expected ............................................................ 173Error 452 - SUB expected .................................................................... 173Error 453 - Equate (%xyz) expected ..................................................... 173Error 454 - END FUNCTION expected .................................................. 173Error 455 - END IF expected ............................................................... 173Error 456 - LOOP/WEND expected ....................................................... 174Error 457 - END SELECT expected ....................................................... 174Error 458 - END SUB expected ............................................................ 174Error 459 - NEXT expected .................................................................. 174Error 460 - Undefined equate .............................................................. 174

  • PowerBASIC Console Compiler Version 5

    7 / 703

    Error 461 - Array not dimensioned ...................................................... 174Error 462 - Undefined Procedure reference ........................................... 174Error 463 - Undefined label/line reference ............................................. 175Error 464 - Undefined class reference ................................................... 175Error 465 - Duplicate definition ............................................................ 175Error 466 - Duplicate name definition ................................................... 175Error 467 - Duplicate line number ........................................................ 175Error 468 - Duplicate equate ............................................................... 176Error 469 - Quad integer variable expected ........................................... 176Error 471 - Invalid line number ........................................................... 176Error 472 - Invalid label ...................................................................... 176Error 473 - Invalid numeric format ...................................................... 176Error 474 - Invalid name .................................................................... 176Error 475 - Metastatements not allowed here ........................................ 176Error 476 - Block/scanned statements not allowed here .......................... 177Error 477 - Syntax error ..................................................................... 177Error 478 - Resource file error ............................................................. 177Error 479 - Array bounds error ............................................................ 177Error 480 - Parameter mismatches definition ......................................... 177Error 481 - Mismatch with prior definition ............................................. 177Error 482 - Data type mismatch ........................................................... 178Error 483 - Requires Object Procedure (Method/Property) ...................... 178Error 484 - Requires procedure (Sub/Function/Method/Property) ............. 178Error 485 - Dynamic/Field strings not allowed ....................................... 178Error 486 - BYVAL option not allowed .................................................. 178Error 487 - Multiple NEXT not allowed .................................................. 179Error 488 - Numeric processor overflow ............................................... 179Error 489 - Invalid string length .......................................................... 179Error 490 - Static array too large ......................................................... 179Error 491 - Invalid register variable ...................................................... 179Error 492 - Invalid SORT function ........................................................ 179Error 493 - Compiler file not found/accessible ....................................... 180Error 494 - ASM not allowed here ........................................................ 180Error 495 - Compiler file read error ...................................................... 180Error 496 - Destination file write error .................................................. 180Error 497 - Assembler syntax error ...................................................... 180Error 498 - Assembler variables must be declared ................................. 180Error 499 - Statement must be first on line ........................................... 181Error 500 - Variable name must be unique ............................................ 181Error 501 - Parameters too large (exceed 64 Kb) ................................... 181Error 502 - COM interface name expected ............................................. 181Error 503 - Multiple Main Functions have been defined ........................... 181Error 504 - Executable requires PBMAIN/WINMAIN function ................... 181Error 505 - Debugging requires EXE file, not DLL .................................. 182Error 506 - Declaration must precede statements ................................... 182

  • PowerBASIC Console Compiler Version 5

    8 / 703

    Error 507 - OLE variable expected ........................................................ 182Error 508 - INSTANCE not allowed here ............................................... 182Error 509 - Interface mismatches class ................................................. 182Error 510 - Interface name expected .................................................... 182Error 511 - Numeric operand expected ................................................. 183Error 512 - Nested brackets not allowed ............................................... 183Error 513 - "]" expected ...................................................................... 183Error 514 - Enclosing angle brackets expected .............................. 183Error 515 - Fixup overflow .................................................................. 183Error 516 - DEFtype, Type ID or type-specifier required ......................... 183Error 517 - OPTIONAL requires CDECL or SDECL .................................. 183Error 518 - "[...]" requires CDECL ........................................................ 184Error 519 - Missing declaration ............................................................ 184Error 520 - TYPE expected .................................................................. 184Error 521 - UNION expected ............................................................... 184Error 522 - END TYPE expected ........................................................... 184Error 523 - END UNION expected ........................................................ 185Error 524 - Undefined type ................................................................. 185Error 525 - Type ID or specifier (?%&!#$) not allowed .......................... 185Error 526 - Period not allowed ............................................................ 185Error 527 - End of statement expected ................................................. 185Error 528 - Type too large .................................................................. 185Error 529 - Pointer variable error ......................................................... 185Error 530 - Invalid member name/definition ......................................... 186Error 531 - Object variable expected .................................................... 186Error 532 - Variant variable expected ................................................... 186Error 533 - Dispatch object variable expected ........................................ 186Error 534 - Bit field error .................................................................... 186Error 535 - Dynamic string variable expected ........................................ 186Error 536 - Too many imports ............................................................. 187Error 537 - Pointer expected ............................................................... 187Error 538 - Invalid FOR/NEXT limits ..................................................... 187Error 539 - Invalid thread function ....................................................... 187Error 540 - Float opcode with a register variable .................................... 187Error 541 - Register size conflict .......................................................... 188Error 542 - May not be altered ............................................................. 188Error 543 - Must be outside Sub/Function/Class... .................................. 188Error 544 - Field variable expected ....................................................... 188Error 545 - AT expected ..................................................................... 188Error 549 - BYVAL required with pointers ............................................. 188Error 550 - Too many data statements ................................................. 189Error 551 - Not supported in this version .............................................. 189Error 552 - TRY statement expected ..................................................... 189Error 553 - CATCH statement expected ................................................ 189Error 554 - END TRY statement expected ............................................. 189

  • PowerBASIC Console Compiler Version 5

    9 / 703

    Error 555 - ON ERROR/RESUME not allowed here ................................. 189Error 556 - Function restricted to threads .............................................. 190Error 557 - Macro too long/complex ..................................................... 190Error 558 - MACRO expected .............................................................. 190Error 559 - END MACRO expected ....................................................... 190Error 562 - INTERFACE expected ......................................................... 191Error 563 - END INTERFACE expected ................................................. 191Error 564 - MACROTEMP not allowed here ........................................... 191Error 565 - Macro mismatch with code position ..................................... 191Error 566 - CLASS expected ................................................................ 191Error 567 - END CLASS expected ......................................................... 191Error 568 - METHOD expected ............................................................ 191Error 569 - END METHOD expected ..................................................... 192Error 570 - PROPERTY expected .......................................................... 192Error 571 - END PROPERTY expected .................................................. 192Error 572 - PROPERTY GET expected ................................................... 192Error 574 - Not allowed in an Event Class ............................................. 192Error 575 - EVENT SOURCE is not declared .......................................... 192Error 576 - Too many Interfaces .......................................................... 192Error 577 - EVENT INTERFACE expected .............................................. 193Error 578 - INHERIT of Base Class expected ......................................... 193Error 579 - BYREF variable or BYVAL/BYREF variant expected ................. 193Error 580 - Duplicate GUID usage ........................................................ 193Error 581 - Type Library creation error ................................................. 193Error 582 - Duplicate Dispatch interface ................................................ 193Error 583 - Unpaired PROPERTY definition ........................................... 194Error 584 - Mismatched PROPERTY pair ............................................... 194Error 585 - PROPERTY requires BYVAL parameters ............................... 194Error 586 - User Defined Type or AS expected ...................................... 194Error 587 - Invalid Constructor/Destructor ............................................ 194Error 588 - Indirect operand must be bracketed: [12] ............................ 194Error 589 - Dual/IDispatch interface is required ..................................... 194Error 590 - PROPERTY SET requires at least one parameter ................... 195Error 591 - BYVAL with OUT is not allowed .......................................... 195Error 592 - Return value required ........................................................ 195Error 593 - Dual or Automation interface is required .............................. 195Error 594 - Macro ends with continuation '_' ......................................... 195Error 595 - Object return type required ................................................ 195Error 596 - Inherited interface expected ................................................ 196Error 597 - Invalid name or sequence in the interface ............................ 196Error 598 - CLASS METHOD name expected ......................................... 196Error 599 - Invalid within an INTERFACE ............................................. 196Error 600 - Macro phase error, referenced before define ......................... 196Error 601 - One INHERIT per interface ................................................. 196Error 603 - Incompatible with a Dual/IDispatch interface ........................ 196

  • PowerBASIC Console Compiler Version 5

    10 / 703

    Error 605 - Macro parameter mismatch ................................................ 197Error 606 - Macro empty parentheses "()" are needed ............................ 197Error 607 - Too many macro expansions .............................................. 197Error 613 - Cannot compile - the program is now running ...................... 197Error 801 to 815 - Internal error .......................................................... 197

    Run Time Errors .................................................................................... 197Run-time errors ................................................................................. 197Disk Errors ........................................................................................ 198Error 0 - No error .............................................................................. 199Error 5 - Illegal function call ................................................................ 199Error 6 - Overflow .............................................................................. 200Error 7 - Out of memory ..................................................................... 200Error 9 - Subscript / Pointer out of range .............................................. 200Error 11 - Division by zero .................................................................. 200Error 24 - Device time-out .................................................................. 200Error 51 - Internal error ...................................................................... 200Error 52 - Bad file name or number ..................................................... 201Error 53 - File not found ..................................................................... 201Error 54 - Bad file mode ..................................................................... 201Error 55 - File is already open ............................................................. 201Error 57 - Device I/O error .................................................................. 201Error 58 - File already exists ................................................................ 201Error 61 - Disk full ............................................................................. 202Error 62 - Input past end .................................................................... 202Error 63 - Bad record number ............................................................. 202Error 64 - Bad file name ..................................................................... 202Error 67 - Too many files .................................................................... 202Error 68 - Device unavailable ............................................................... 202Error 69 - COMM error ....................................................................... 203Error 70 - Permission denied ............................................................... 203Error 71 - Disk not ready .................................................................... 203Error 72 - Disk media error ................................................................. 203Error 74 - Rename across disks ........................................................... 203Error 75 - Path/file access error ........................................................... 203Error 76 - Path not found .................................................................... 204Error 99 - Object error ....................................................................... 204Error 241 - Global memory corrupt ...................................................... 204Error 242 - String space corrupt .......................................................... 204

    Error Trapping ....................................................................................... 204Error Trapping ................................................................................... 204How error traps work ......................................................................... 205Setting an error trap ........................................................................... 206Writing an error handler ..................................................................... 206Exiting an error handler ...................................................................... 207Error Trapping Summary .................................................................... 208

  • PowerBASIC Console Compiler Version 5

    11 / 703

    Graphics ................................................................................................... 208Printing ..................................................................................................... 210Resource Files ............................................................................................ 211

    What is a Resource File? ......................................................................... 211Resource Editors .................................................................................... 211Resource Compiling ............................................................................... 212Resource Scripts .................................................................................... 212Converting a .RC to a .RES ...................................................................... 213Converting a .RES to a .PBR .................................................................... 214

    Serial Communications ............................................................................... 214Serial Communications ........................................................................... 214Communications Basics ........................................................................... 216Communication Buffers ........................................................................... 217Parity and general error checking ............................................................. 218Start and Stop bits ................................................................................. 218Opening a communications port .............................................................. 219Reading and writing data ........................................................................ 221A simple communications program .......................................................... 222

    TCP and UDP Communications .................................................................... 226TCP and UDP Communications ................................................................ 226The Internet Protocol (IP) ....................................................................... 227User Datagram Protocol (UDP) ................................................................ 228Transmission Control Protocol (TCP) ........................................................ 228Winsock ................................................................................................ 229Request for Comments (RFC) .................................................................. 229TCP clients and servers ........................................................................... 230Simple Mail Transfer Protocol (SMTP) ....................................................... 230An ECHO client and server using TCP ....................................................... 232

    The Inline Assembler ................................................................................. 235The Inline Assembler ............................................................................. 235Using assembly-language in your code ..................................................... 236Inline Assembler code syntax .................................................................. 236Flat memory model ................................................................................ 237Protected mode programming ................................................................. 237Mnemonics and Operands ....................................................................... 238Opcodes and Mnemonics ........................................................................ 239Registers ............................................................................................... 240Data types in registers ............................................................................ 241MMX registers ........................................................................................ 242The stack .............................................................................................. 242Balancing the stack ................................................................................. 243Tricks of the stack .................................................................................. 244Stack Overhead Reduction ....................................................................... 245Saving registers ..................................................................................... 246Saving Registers at the Sub/Function level ................................................ 246

  • PowerBASIC Console Compiler Version 5

    12 / 703

    Intermixing ASM and BASIC code ............................................................ 247Using ESP and EBP ................................................................................. 249Saving the FPU registers ......................................................................... 250Tricks in preserving registers ................................................................... 250Addressing and pointers ......................................................................... 251Effective addressing ................................................................................ 252Passing parameters ................................................................................ 254Parameters passed by reference or by copy ............................................... 254Parameters passed by value .................................................................... 255Passing arrays ....................................................................................... 255Passing dynamic strings .......................................................................... 256Accessing PowerBASIC variables by name ................................................ 257Commenting Assembly code ................................................................... 257

    Objects and COM Programming ................................................................... 257What is an object, anyway? ..................................................................... 257Where are objects located? ...................................................................... 258Why should I use objects? ...................................................................... 259What are the parts of an object? .............................................................. 260Are there other important "Buzz-Words"? .................................................. 261What does a Class look like? .................................................................... 263What is a Base Class? ............................................................................. 264What does an Interface look like? ............................................................. 265Just what is COM? .................................................................................. 266What is a COM component? .................................................................... 267How do you publish an object? ................................................................ 268How are GUID's used with objects? .......................................................... 268What is inheritance? ............................................................................... 269How do you create an object? ................................................................. 271How do you duplicate an object variable? ................................................. 272How do you call a Direct Method? ............................................................ 273What is a Compound Object Reference? ................................................... 274What is an hResult? ................................................................................ 275How do you register a COM Component? ................................................. 276What is a Class Method? ......................................................................... 276What are Constructors and Destructors? ................................................... 277What is DISPATCH? ............................................................................... 278Late Binding .......................................................................................... 278ID Binding ............................................................................................. 279Creating a DISPATCH Object ................................................................... 280How do you call a DISPATCH METHOD? .................................................. 280What are Connection Points? ................................................................... 281Enumerating Collections ......................................................................... 284What are Type Libraries? ........................................................................ 285Built-in Interfaces ................................................................................... 286

    Upgrading From DOS ................................................................................. 286

  • PowerBASIC Console Compiler Version 5

    13 / 703

    Upgrading From DOS ............................................................................. 286Language Incompatibilities ...................................................................... 287Creating Programs ................................................................................. 287Default Variable Typing .......................................................................... 287Defining Constants ................................................................................. 288Graphics ............................................................................................... 289Labels ................................................................................................... 289Memory ................................................................................................ 289Using Sequential Files ............................................................................. 290Using Binary Files ................................................................................... 290Using Random Access Files ..................................................................... 290Variable Types ....................................................................................... 291Keyword Differences ............................................................................... 292

    Optimizing your code ................................................................................. 296Keyword Reference ......................................................................................... 297

    Keyword Quick Finder ................................................................................. 297Keyword Reference ..................................................................................... 314Format and typefaces ................................................................................. 315Command Summary .................................................................................. 316

    Command Summary .............................................................................. 316Array Operations ................................................................................... 316COM Commands .................................................................................... 317Communication Control .......................................................................... 318Compiler Operations .............................................................................. 319Debugging and Error Control .................................................................. 320File Commands ...................................................................................... 320Flow Control .......................................................................................... 322Graphic Commands ................................................................................ 323Input Commands ................................................................................... 324Memory Management ............................................................................. 325Metastatements ...................................................................................... 325Numeric Operations ............................................................................... 326Operating System .................................................................................. 328Printing Commands ................................................................................ 330Screen Text Commands .......................................................................... 331String Operations ................................................................................... 333Thread Control ...................................................................................... 347Time Commands ................................................................................... 347Misc Operations ..................................................................................... 347

    #ALIGN metastatement .............................................................................. 348#BLOAT metastatement ............................................................................. 348#BREAK metastatement .............................................................................. 348#COMPILE metastatement .......................................................................... 349#COMPILER metastatement ....................................................................... 349#CONSOLE metastatement ......................................................................... 349

  • PowerBASIC Console Compiler Version 5

    14 / 703

    %DEF operator .......................................................................................... 349#DEBUG CODE metastatement .................................................................... 350#DEBUG DISPLAY metastatement ............................................................... 351#DEBUG ERROR metastatement .................................................................. 351#DEBUG PRINT metastatement ................................................................... 352#DIM metastatement .................................................................................. 353#IF/#ELSEIF/#ELSE/#ENDIF metastatements ............................................... 353#INCLUDE metastatement .......................................................................... 355#OPTIMIZE metastatement ......................................................................... 356#OPTION metastatement ........................................................................... 356#REGISTER metastatement ......................................................................... 357#RESOURCE metastatement ....................................................................... 357#STACK metastatement .............................................................................. 358#TOOLS metastatement ............................................................................. 358#UTILITY metastatement ........................................................................... 359ABS function ............................................................................................. 359ACODE$ function ....................................................................................... 359AND operator ............................................................................................ 359ARRAY ASSIGN statement .......................................................................... 360ARRAY DELETE statement .......................................................................... 360ARRAY INSERT statement .......................................................................... 362ARRAY SCAN statement ............................................................................. 363ARRAY SORT statement ............................................................................. 365ARRAYATTR function ................................................................................. 370ASC function ............................................................................................. 371ASC statement ........................................................................................... 372ASM statement .......................................................................................... 372ATN function ............................................................................................. 376BEEP statement .......................................................................................... 377BGR function ............................................................................................. 377BIN$ function ............................................................................................ 378BIT CALC statement ................................................................................... 378BIT function .............................................................................................. 379BIT statement ............................................................................................ 380BITS function ............................................................................................ 381BITS functions ........................................................................................... 381BITSE function ........................................................................................... 382BUILD$ function ........................................................................................ 382CALL DWORD statement ............................................................................. 383CALL statement ......................................................................................... 385CALLSTK statement .................................................................................... 388CALLSTK$ function .................................................................................... 389CALLSTKCOUNT function ........................................................................... 389CBYT, CCUR, CCUX, CDBL, CDWD, CEXT, CINT, CLNG, CQUD, CSNG, and ...... 390CEIL function ............................................................................................. 391

  • PowerBASIC Console Compiler Version 5

    15 / 703

    CHDIR statement ....................................................................................... 391CHDRIVE statement ................................................................................... 392CHOOSE function ....................................................................................... 392CHR$ function ........................................................................................... 392CLASS/END CLASS Block ............................................................................ 393CLIPBOARD statement ................................................................................ 394CLOSE statement ....................................................................................... 395CLS statement ........................................................................................... 396CLSID$ function ......................................................................................... 396CODEPTR function ..................................................................................... 397COLOR statement ...................................................................................... 397COMM CLOSE statement ............................................................................. 398COMM function .......................................................................................... 398COMM LINE statement ................................................................................ 400COMM OPEN statement .............................................................................. 401COMM PRINT statement ............................................................................. 401COMM RECV statement ............................................................................... 402COMM RESET statement ............................................................................. 402COMM SEND statement ............................................................................... 402COMM SET statement ................................................................................. 403COMMAND$ function .................................................................................. 405CONSHNDL function ................................................................................... 406CONSIN function ....................................................................................... 406CONSNAME$ function ................................................................................ 407CONSOLE GET LOC statement ..................................................................... 407CONSOLE GET SCREEN statement ............................................................... 408CONSOLE GET SIZE statement .................................................................... 408CONSOLE GET VIEW statement ................................................................... 408CONSOLE GET VIRTUAL statement ............................................................. 409CONSOLE NAME statement ......................................................................... 409CONSOLE SCREEN statement ...................................................................... 409CONSOLE SET FOCUS statement ................................................................. 410CONSOLE SET LOC statement ..................................................................... 410CONSOLE SET SCREEN statement ............................................................... 410CONSOLE SET VIEW statement ................................................................... 411CONSOLE SET VIRTUAL statement .............................................................. 412CONSOUT function .................................................................................... 412COS function ............................................................................................. 413CSET$ function .......................................................................................... 414CSET statement ......................................................................................... 414CURDIR$ function ...................................................................................... 415CURSOR function ....................................................................................... 415CURSOR statement .................................................................................... 415CURSORX function ..................................................................................... 415CURSORY function ..................................................................................... 416

  • PowerBASIC Console Compiler Version 5

    16 / 703

    CVBYT functions ........................................................................................ 416DATA statement ........................................................................................ 417DATACOUNT function ................................................................................ 418DATE$ system variable ............................................................................... 418DECLARE statement ................................................................................... 419DECR statement ......................................................................................... 422DEFBYT, DEFCUR, DEFCUX, DEFDBL, DEFDWD, DEFEXT, DEFINT, DEFLNG, .... 423DESKTOP GET CLIENT statement ................................................................ 424DESKTOP GET LOC statement ..................................................................... 424DESKTOP GET SIZE statement .................................................................... 424DIM statement ........................................................................................... 424DIR$ CLOSE statement ............................................................................... 428DIR$ function ............................................................................................ 429DISKFREE function ..................................................................................... 430DISKSIZE function ...................................................................................... 431DO/LOOP statements ................................................................................. 431END statement ........................................................................................... 433ENVIRON$ function .................................................................................... 433ENVIRON statement ................................................................................... 434EOF function ............................................................................................. 434EQV operator ............................................................................................ 435ERASE statement ....................................................................................... 436ERL system variable ................................................................................... 436ERL$ function ............................................................................................ 437ERR and ERRCLEAR system variables ........................................................... 437ERROR$ function ....................................................................................... 438ERROR statement ....................................................................................... 438EXIT statement .......................................................................................... 438EVENT SOURCE statement .......................................................................... 440EVENTS statement ..................................................................................... 442EXE read-only user defined type .................................................................. 443EXP, EXP2 and EXP10 functions ................................................................... 444EXTRACT$ function .................................................................................... 444FIELD statement ........................................................................................ 445FILEATTR function ..................................................................................... 446FILECOPY statement .................................................................................. 447FILENAME$ function ................................................................................... 448FILESCAN statement .................................................................................. 448FIX function ............................................................................................... 449FLUSH statement ....................................................................................... 449FONT END statement ................................................................................. 449FONT NEW statement ................................................................................. 450FOR/NEXT statements ................................................................................ 451FORMAT$ function ..................................................................................... 453FRAC function ........................................................................................... 456

  • PowerBASIC Console Compiler Version 5

    17 / 703

    FREEFILE function ...................................................................................... 457FUNCNAME$ function ................................................................................. 457FUNCTION/END FUNCTION statements ....................................................... 458GET statement ........................................................................................... 462GET$ statement ......................................................................................... 464GETATTR function ..................................................................................... 465GETSTDERR function ................................................................................. 466GETSTDIN function .................................................................................... 466GETSTDKBD function ................................................................................. 466GETSTDOUT function ................................................................................. 466GETSTDVID function .................................................................................. 467GLOBAL statement ..................................................................................... 467GLOBALMEM statement .............................................................................. 468GOSUB/GOSUB DWORD statements ............................................................. 469GOTO/GOTO DWORD statements ................................................................ 469GRAPHIC ARC statement ............................................................................ 470GRAPHIC ATTACH statement ...................................................................... 471GRAPHIC BITMAP END statement ................................................................ 472GRAPHIC BITMAP LOAD statement ............................................................. 472GRAPHIC BITMAP NEW statement ............................................................... 473GRAPHIC BOX statement ............................................................................ 473GRAPHIC CHR SIZE statement .................................................................... 474GRAPHIC CLEAR statement ......................................................................... 475GRAPHIC COLOR statement ........................................................................ 475GRAPHIC COPY statement .......................................................................... 475GRAPHIC DETACH statement ...................................................................... 476GRAPHIC ELLIPSE statement ....................................................................... 476GRAPHIC FONT statement .......................................................................... 477GRAPHIC GET BITS statement .................................................................... 478GRAPHIC GET CLIENT statement ................................................................ 479GRAPHIC GET DC statement ....................................................................... 479GRAPHIC GET LINES statement ................................................................... 479GRAPHIC GET LOC statement ..................................................................... 479GRAPHIC GET MIX statement ...................................................................... 480GRAPHIC GET PIXEL statement ................................................................... 480GRAPHIC GET POS statement ..................................................................... 481GRAPHIC GET PPI statement ...................................................................... 481GRAPHIC GET SCALE statement .................................................................. 481GRAPHIC INKEY$ statement ....................................................................... 482GRAPHIC INPUT FLUSH statement .............................................................. 482GRAPHIC INPUT statement ......................................................................... 482GRAPHIC INSTAT statement ....................................................................... 483GRAPHIC LINE INPUT statement ................................................................. 483GRAPHIC LINE statement ........................................................................... 483GRAPHIC PAINT statement ......................................................................... 484

  • PowerBASIC Console Compiler Version 5

    18 / 703

    GRAPHIC PIE statement ............................................................................. 485GRAPHIC POLYGON statement .................................................................... 486GRAPHIC POLYLINE statement .................................................................... 487GRAPHIC PRINT statement ......................................................................... 488GRAPHIC REDRAW statement ..................................................................... 488GRAPHIC RENDER statement ...................................................................... 489GRAPHIC SAVE statement .......................................................................... 489GRAPHIC SCALE statement ......................................................................... 490GRAPHIC SET BITS statement ..................................................................... 490GRAPHIC SET FOCUS statement .................................................................. 491GRAPHIC SET FONT statement ................................................................... 491GRAPHIC SET LOC statement ...................................................................... 492GRAPHIC SET MIX statement ...................................................................... 492GRAPHIC SET PIXEL statement ................................................................... 493GRAPHIC SET POS statement ...................................................................... 493GRAPHIC STRETCH statement .................................................................... 493GRAPHIC STYLE statement ......................................................................... 494GRAPHIC TEXT SIZE statement ................................................................... 495GRAPHIC WAITKEY$ statement ................................................................... 495GRAPHIC WIDTH statement ........................................................................ 495GRAPHIC WINDOW CLICK statement ........................................................... 496GRAPHIC WINDOW END statement ............................................................. 496GRAPHIC WINDOW statement ..................................................................... 496GUID$ function .......................................................................................... 497GUIDTXT$ function .................................................................................... 498HEX$ function ............................................................................................ 498HI function ................................................................................................ 499HIBYT function .......................................................................................... 499HIINT function .......................................................................................... 500HIWRD function ......................................................................................... 500HOST ADDR statement ............................................................................... 500HOST NAME statement ............................................................................... 501IDISPINFO pseudo-object ........................................................................... 501IF/END IF block ......................................................................................... 503IF statement .............................................................................................. 504IIF function ............................................................................................... 505IMP operator ............................................................................................. 506INCR statement ......................................................................................... 506INKEY$ function ........................................................................................ 507INPUT FLUSH statement ............................................................................. 508INPUT statement ....................................................................................... 508INPUT# statement ..................................................................................... 509INSHIFT function ....................................................................................... 510INSTANCE statement ................................................................................. 510INSTAT function ........................................................................................ 511

  • PowerBASIC Console Compiler Version 5

    19 / 703

    INSTR function .......................................................................................... 511INT function .............................................................................................. 512INTERFACE / END INTERFACE Block (Direct) ................................................ 512INTERFACE/END INTERFACE block (IDBind) ................................................ 515ISFALSE and ISTRUE operators ................................................................... 516ISFILE Function ......................................................................................... 517ISINTERFACE Function ............................................................................... 518ISMISSING function ................................................................................... 518ISNOTHING function .................................................................................. 518ISOBJECT function ..................................................................................... 519ITERATE statement .................................................................................... 519JOIN$ function .......................................................................................... 520KEY$ function ............................................................................................ 521KEY statement ........................................................................................... 521KILL statement ........................................................................................... 521LBOUND function ....................................................................................... 522LCASE$ function ........................................................................................ 522LEFT$ function .......................................................................................... 523LEN function .............................................................................................. 523LET statement ........................................................................................... 524LET statement (with Objects) ...................................................................... 525LET statement (with Types) ......................................................................... 527LET statement (with Variants) ...................................................................... 528LINE INPUT statement ................................................................................ 529LINE INPUT# statement ............................................................................. 530LO function ............................................................................................... 531LOBYT function ......................................................................................... 531LOC function ............................................................................................. 531LOCAL statement ....................................................................................... 532LOCATE statement ..................................................................................... 532LOCK statement ......................................................................................... 533LOF function .............................................................................................. 533LOG, LOG2 and LOG10 functions ................................................................. 534LOINT function .......................................................................................... 534LOWRD function ........................................................................................ 534LPRINT ATTACH statement ........................................................................ 535LPRINT CLOSE statement ........................................................................... 536LPRINT FLUSH statement ............................................................................ 536LPRINT FORMFEED statement ..................................................................... 537LPRINT$ function ....................................................................................... 537LPRINT statement ...................................................................................... 538LSET$ function .......................................................................................... 538LSET statement .......................................................................................... 539LTRIM$ function ........................................................................................ 539MACRO/END MACRO block ......................................................................... 540

  • PowerBASIC Console Compiler Version 5

    20 / 703

    MAK function ............................................................................................. 544MAKDWD, MAKLNG and MAKPTR functions .................................................. 544MAKINT and MAKWRD functions ................................................................. 545MAT statement .......................................................................................... 545MAX function ............................................................................................. 546MCASE$ function ....................................................................................... 547ME pseudo-variable .................................................................................... 547METHOD/END METHOD statements ............................................................. 547MID$ function ............................................................................................ 551MID$ statement ......................................................................................... 552MIN function ............................................................................................. 553MKBYT$, MKCUR$, MKCUX$, MKD$, MKDWD$, MKE$, MKI$, MKL$, MKQ$, ...... 553MKDIR statement ....................................................................................... 554MOD operator ............................................................................................ 554MOUSE statement ...................................................................................... 555MOUSEBUTTONS function .......................................................................... 556MOUSESTAT function ................................................................................. 556MOUSEX function ....................................................................................... 556MOUSEY function ....................................................................................... 556MYBASE pseudo-variable ............................................................................ 557NAME statement ........................................................................................ 557NOT operator ............................................................................................ 557NUL$ function ........................................................................................... 558OBJACTIVE function .................................................................................. 559OBJECT statement ..................................................................................... 559OBJPTR function ........................................................................................ 561OBJRESULT function .................................................................................. 562OBJRESULT$ function ................................................................................ 563OCT$ function ........................................................................................... 563ON ERROR statement ................................................................................. 564ON GOSUB statement ................................................................................. 565ON GOTO statement .................................................................................. 565OPEN statement ......................................................................................... 566OPTION EXPLICIT statement ...................................................................... 569OR operator .............................................................................................. 569PAGE statement ......................................................................................... 570PAGEACTIVE function ................................................................................ 571PAGEVISIBLE function ................................................................................ 571PARSE$ function ........................................................................................ 571PARSE statement ....................................................................................... 572PARSECOUNT function ............................................................................... 573PATHNAME$ function ................................................................................. 574PATHSCAN$ function ................................................................................. 574PBMAIN function ........................................................................................ 575PCOPY statement ....................................................................................... 576

  • PowerBASIC Console Compiler Version 5

    21 / 703

    PEEK and PEEK$ functions .......................................................................... 576POKE and POKE$ statements ....................................................................... 577PRINT statement ........................................................................................ 578PRINT# statement ..................................................................................... 579PRINTER$ function .................................................................................... 581PRINTERCOUNT function ........................................................................... 581PROCESS GET PRIORITY statement ............................................................. 581PROCESS SET PRIORITY statement ............................................................. 582PROFILE statement .................................................................................... 583PROGID$ function ...................................................................................... 584PROPERTY/END PROPERTY statement ......................................................... 585PUT statement ........................................................................................... 588PUT$ statement ......................................................................................... 589RAISEEVENT statement .............................................................................. 590RANDOMIZE statement ............................................................................... 590READ$ function ......................................................................................... 591REDIM statement ....................................................................................... 592REGEXPR statement ................................................................................... 593REGISTER statement .................................................................................. 596REGREPL statement .................................................................................... 597REM statement ........................................................................................... 601REMAIN$ function ...................................................................................... 601REMOVE$ function ..................................................................................... 602REPEAT$ function ...................................................................................... 602REPLACE statement .................................................................................... 603RESET statement ....................................................................................... 603RESUME statement .............................................