TBsampleSP09.tru

REM Kelly Zambito
REM CS110 03
REM Luying Li
REM TRUE BASIC Program Assignment
REM 2/13/09

PRINT "TRUE BASIC sample program"
PRINT "My name is Kelly Zambito"
PRINT "This is my first TRUE BASIC program"
PRINT "My section number in CS110 is 03"
PRINT "My CS110 TA is Luying Li"
PRINT "My favorite color is blue"
PRINT "When I buy a new car, it will be a BMW"
PRINT " and of course it will be black"
END

Comments

Re: First TB prog ...

kzambito ... Nice job Kelly. Below is a simple TB program listing you might want to highlight - copy - paste into your TB software. Regards ... Tom M

! filename: parse_file.tru, tjm, 10-21-03
! parses any file for all its characters & their frequencies

OPTION BASE 0
DIM p(255, 2)
MAT p=zer

PRINT " This program creates a Table of ASCII characters and their frequency"
PRINT " in the named target file."
PRINT
INPUT prompt " [Path...\]Filename.Ext of target file = ? ": fname$
PRINT
PRINT " For file ";fname$; " the Char Frequency Table is:"
PRINT

OPEN #1: name fname$, org byte, access input ! fetch file to parse
ASK #1: FILESIZE fs
READ #1, bytes fs: z$

FOR ii=0 to 255 ! create character index
LET p(ii,0)=ii
NEXT ii

FOR ii=1 to fs ! accumulate z$ character frequency
LET a$=z$[ii:ii]
LET a=ord(a$)
LET p(a,1)=p(a,1)+1
NEXT ii

PRINT " Char: Chr$(Char) Char Freq"
PRINT " -------- ---------- ---------"

FOR ii=0 to 255 ! print character table
IF mod(p(ii,0),128)>31 then
PRINT " "; p(ii,0), chr$(p(ii,0)), p(ii,1)
ELSE
PRINT " "; p(ii,0), " ", p(ii,1)
END IF
PAUSE .2
NEXT ii
PRINT
PRINT " There were "; fs; " characters in the file ... "
!GET KEY k
!mat print p;
!get key k

END