PowerBASIC and PBASIC - Head-to-Head



Copyright 1991, BJ Gleason



In this column, I want to make it perfectly clear the differences

between PBASIC, the freeware Interpreter and PowerBASIC.  While I

am the author of PBASIC, I want to make it perfectly clear that

this will be an unbiased review.  I will be comparing PBASIC,

version 4.9, with PowerBASIC for the Portfolio.



It came in a big box, and when I opened it up, there was a small

box - PowerBASIC.  I opened it, and found, in my opinion, the

smallest compiler in the world.  The manual is 204 pages, and is

smaller in size than the original Portfolio manual, but is very

easy to read, and very well written.



The compiler itself is very complete and includes random access

files, and interrupt driven serial I/O, as well as integers and

double precision floating point numbers.  It can compile to .COM

or .RUN files.  RUN files will allow to access maximum memory. 

However, the compiler will not generate stand alone programs.  To

run the compiled code, you have to have the runtime module

PBRUN.RUN.  This is a 23k file that you can distribute this with

your programs.  The compiled code is VERY fast....



The compiler comes on a ROM card, with a number of support files,

as well as sample programs.  However, you can not compile the

sample programs until you copy them to a RAM card, or C: drive. 

The compiler will generate the code to the same location that the

source comes from.  Since C: drive is small and unreliable, you

will really need to copy the files to a RAM card for development

purposes.



The compiler will not run on the PC.  You can use a standard text

editor on a PC.  If you want to develop programs on the PC, you

can buy PowerBASIC for the PC, or a special PowerBASIC

development kit for the Portfolio that runs on the PC.  I do not

yet know the price for the special development kit.



PowerBASIC will use the last file that you edited, but will not

point to the error in the editor.  It does not allow you to take

advantage of special Portfolio features, such as menus, windows,

and other Portfolio-Only features.



Lets take a look at the Pros and Cons for each:

 

PowerBASIC Pros:

 

     More memory available

     Programs run faster

     Random Access files

     Supplied on ROM Card

     Interrupt Driven Serial Input/Output



 

PowerBASIC Cons:

 

     Only runs on the Portfolio

     Debugging is harder

     Does not interact with the editor

     Does not make use of the internal Portfolio features

     Doesn't allow for Hex constants

     Cost $75+

     PowerBASIC for the PC another $75+

 



PBASIC Pros:



     Runs on the PC and the Portfolio (and HP)

     Editor points to errors

     Allows Access to internal features (Menus, etc.)

     Importing from a .WKS file

     PGC graphics support with Animation

     Cost: Free

     Updated regularly





PBASIC Cons:



     Requires about 70k of memory to run

     Slow

     Not 100% compatible with GWBASIC

     Transfer to Portfolio can be a minor problem



Here is a list of features that PBASIC and PowerBASIC have in

Common:



[dave - make this multicolumn, small font]



ABS

ASC

ATN

BEEP

BIN$

CALL

CALL INTERRUPT

CHDIR

CHR$

CLEAR

CLOSE

CLS

COMMAND$

COS

CSRLIN

DATA

DATE$

DEF FN

DEF SEG

DIM

DO WHILE, WEND

END

EOF

ERL, ERR

ERROR

EXP

FOR, NEXT

FRE

GOSUB

GOTO

HEX$

IF, IF (block)

INKEY$

INP

INPUT

INPUT #

INPUT$

INSTAT

INSTR

INT

KILL

LCASE$

LEFT$

LEN

LET

LINE

LINE INPUT

LINE INPUT #

LOCATE

LOG

LPOS

LPRINT

LPRINT USING

MID$

MKDIR

NAME

OCT$

ON ERROR

ON GOSUB

ON GOTO

OPEN

OUT

PEEK

POINT

POKE

POS

PRINT

PRINT USING

PRINT #

PRINT # USING

PSET

RANDOMIZE

READ

REG

REM

RESTORE

RESUME

RETURN

RIGHT$

RMDIR

RND

SCREEN

SGN

SIN

SQR

STR$

STRING$

TAB

TAN

TIME$

TROFF, TRON

UCASE$

VAL

VARPTR

VARSEG

WHILE, WEND



Here are the additional functions and statements included with

PowerBasic.  Most of these command are to support the Random

Access file.



 $COM

 $STACK

 CIRCLE

 CVD, CVI, CVS

 DEF FN, END DEF

 DEFINT

 DEFSNG

 DEFDBL

 DEFSTR

 DO, LOOP

 EXECUTE

 EXIT

 FIELD

 GET

 GET$

 LOC

 LOF

 LSET

 MKI$, MKS$, MKD$

 OPEN COM

 PUT

 PUT$

 RSET

 SEEK

 STRPTR

 STRSEG

 SUB, END SUB

 TONE



Here are the additional functions and statements that are

included with PBASIC.



ACOS

ALARM

ASIN

BLOAD

BOX

BSAVE

CHAIN

CLICK

CMODE

COSH

CWD$

DECR

DEG

DIAL

DISPLAY

DMS

DOSVER

ERRWIN

EVAL

FALSE

FINDFILE$

FINDNEXT$

FILESIZE

FIX

FORMFEED

GETDISPLAY

GLOCATE

GPRINT

INCR

INVERT

LTRIM$

MENU

MSD

NUMFMT

OFF

PBVER

PGLOAD

PGSAVE

PGSHOW

PI

PORT

PRINTER

PRTSC

RAD

RAND

REFRESH

REPEAT/UNTIL

ROMVER

RTRIM$

RUN

SINH

SHIFT

SOUND

SPACE$

STATUS

STOP

SWAP

SYSTEM

TANH

TICK

TIMER

TRUE

VCSRLIN

VLOCATE

VMOVE

VPOS

WAIT

WKSREAD

WKSREAD$

WKSTYPE

WRITE

WRITE#





As you can see from the above lists, PBASIC has many more

functions and features than PowerBASIC, but PowerBASIC does have

a few features that are missing in PBASIC.  The choice is up to

you...



--------------------------------------------------------------





PBASIC Programming



Copyright 1991, BJ Gleason





When we last left, we were talking about PBASIC version 4.7. 

Well, in the intervening time, two additional releases were made. 

The current version is now 4.9, so I will start off today's

column discussing the new features, and that will lead us nicely

into the rest of the column, Graphics Programming.



NEW FEATURES FOR VERSION 4.8



     New Functions: 

          CHARPTR   - Return the address of Character Table

          CWD$      - Return the Current Working Directory

          EXISTS    - Returns TRUE if a file exists

          FILESIZE  - Returns the size of the current file

          FINDFILE$ - Search for a filename

          FINDNEXT$ - Returns the name of the next matching File

     New Statements: 

          CMODE     - Set the character printing mode

          GLOCATE   - Locate for graphics printing

          GPRINT    - Print a bit pattern



     PRINT will now work on a graphics screen, so you mix text

     and graphics.

     The new command line switch, -P, allows users to swap memory

     cards before running a program.

     You can now use an array for MENU elements.





Let's take a closer look at these new features:



FILE DIRECTORY FUNCTIONS



In keeping with the theme of Graphics, this program will allow

you to select a .PGC file a menu and display it.  This will show

you have to use FINDFILE$, FINDNEXT$, and the new option in MENU.



' Pick a .PGC File to display

'

' Set string size small since we may have a lot 

ssize=15

dim fn$(200)   ' up to 200 file names

n=0

mask$="*.PGC"

fn$(n)=cwd$+mask$   ' make 1st entry the TITLE for menu

incr(n)

'

' get the file filename that matches "*.PGC"

'

fn$(n)=findfile$(mask$)

'

' get the rest of the filenames

'

while fn$(n)<>""

     incr(n)

     fn$(n)=findnext$    ' get the next file name

                         ' returns "" when no more

wend



s=n

if s>6 then

     s=6  ' six elements at a time

     ' add a up/down arrow if more than 6 elements

     fn$(0)=fn$(0)+" "+chr$(18)

endif

'

' display the menu - since the count is negative, that means

' use the array fn$(0)...fn$(n) for the title and elements

'

m=0:t=0

10 m=menu(1,1,s,t,m,-n,fn$(0))

if m=-1 then cls:end          ' <esc> key was pressed

m=m%256                       ' find the element number

t=m\256

pgshow fn$(m+1),0

goto 10





GRAPHICS



PBASIC offers a large number of functions for support of

Graphics.  PBASIC supports Don Messerli's PGC, Portfolio Graphics

Standard for screen displays.  This format allows for fast and

easy screen displays using the PGSHOW statement.  You can also

display, edit and save PGC file using PGLOAD and PGSAVE.  With

PGLOAD, the display is fast enough to allow for approximately 6

frames per second animation.



The latest functions allow for combining text and graphics on the

same screen.  As you might be aware, due to the design of the

video screen on the Portfolio, text will not be displayed

properly when the screen is in graphics mode.  PBASIC 4.9

overcomes that limitation, by allowing you to combine Text and

Graphics, but then takes the next logical steps.  PBASIC allows

you to display character with attributes:  Reverse video,

Underline, Wide, Narrow, Sideways, Upside Down, Double Height,

and Half Height.  In fact, you can combine these different modes!



The CMODE statement will set the mode that the text will print

out in:



     Bit  Characteristic

     0    Underline      (+1)

     1    Reverse        (+2)

     2    Double Width   (+4)

     3    Upside Down    (+8)

     4    Sideways       (+16)

     5    Double Height  (+32)

     6    Half Height    (+64)

     7    Half Width     (+128)

     8    OR bits        (+256)

     9    XOR bits       (+512)



For example: to print in Reverse Wide = 2+4 = 6.  To print

sideways, use 16, to print sideways in the other direction, use

sideways and upside down, 24.



Bits 8 and 9 determine how the characters are printed.  If both

are off, the entire bit map is printed.  If bit 8 is set, the

bits are OR'd on the screen.  This means that the background is

left unchanged.  If bit 9 is set, the characters are XOR'd on to

the screen.  This is useful for making sure that the characters

are not lost on a dark background.  There is a little program to

show the difference:



     screen 6

     line(10,0)-(50,50),1,BF

     a$="this is a test"

     cmode=0:print a$;"  Normal Text"

     cmode=256: print a$;" OR'd Text"

     cmode=512: print a$;" XOR'd Text"

     wait



Note: On some Portfolios, there is a bug with the READ_PIXEL in

the ROM.  If CMODE=512 doesn't work, (runs just like CMODE=0) try

running FIX0D.COM.  CMODE should then work properly.



In order to display text and graphics, I had to create a

character set for the Portfolio, which is modeled on the

Portfolio's character set.  The big advantage to this is that you

can actually REPLACE the character set.  CHARPTR points to the

base of the character set.  Each character is represented by a

8x6 pixel font.  Each character then requires a 6 byte bit map. 

For example, the bit map for the character "A" is

7E,11,11,11,7E,00.  If you want to change how the character "A"

looks on the graphics screen, you can replace the bitmap.  The

address of the bit map for any character is:



     base = charptr+(asc(c$)*6)



You can then POKE the new values into memory:



     base = charptr+(asc("A")*6)

     for x=0 to 5

          read bm

          poke base+x,bm

     next x

     screen 6

     print "Press Any Key..."

     wait

     1 data &h7f, &h11, &h11, &h7f, &h70, &h00



When you run this program, the "A" in "Any" should look like that

fancy computer text you always see in the movies.



You can replace the entire character set using this technique. 

If you want to use a different character set, I suggest the

following technique:



     ' Replace Character set

     base = charptr

     for x=0 to 255*6

          read bm

          poke base+x,bm

     next x

     1 data...

     2 data...

     ' now RUN the other program to free up memory!

     run "myprog.bas"



This will allow you to replace the character set, and then run

the other program, freeing up the memory the DATA statements

required.  If you do not want to replace the entire character

set, change the FOR loop to reflect only the ASCII values of the

characters you want to change.



Instead of replacing the character set, you can create new

characters using the GPRINT statement.  This can be used to

display bitmaps as well.  To display the computer font "A" using

GPRINT:



     GPRINT "7f11117f70"



This is the technique used to create the little running man in

RUNMAN.BAS.





ABOUT THE AUTHOR



     Mr. BJ Gleason is an Instructor at The American University

     in the Computer Science and Information Systems Department. 

     He has been programming for over a decade now, and is the

     author of PBASIC 4.9.



     You can write to him at:



          BJ Gleason

          The American University

          CSIS  (Thin Air Labs)

          4400 Massachusetts Avenue, N.W.

          Washington, DC  20016



          Compuserve : 73337,2011

          EMAIL : bjgleas@auvm.american.edu

