Blitz Basic

Embed Size (px)

Citation preview

  • 8/9/2019 Blitz Basic

    1/247

    BLITZ BASIC 2

    1. GETTING STARTEDDirectory tree 06Using Ted t e B!it"2 Editor 0#Entering Te$t 0#%ig !ig ting &!oc's o( te$t 0)T e Editor *en+s 0)T e B!it" ,i!e Re-+ester 11T e Co /i!er *en+ 11Co /i!er /tions 12

    ey&o rd S ortc+ts 13

    2. BLITZ BASIC4S 15*y ,irst rogr 15T e rint Co nd 15,or tted rinting 17A Si /!e 8 ri &!e 17B!it"2 /er tors 17Boo!e n /er tors 1#Bin ry /er tors 1#*+!ti/!e Co nds 1#A Si /!e Loo/ 1#Nested Loo/s 1)

    9 i!e..9end nd Re/e t..Unti! 1)End!ess Loo/s 1:Using String 8 ri &!es 1:

    rogr ,!o; 20 ARRA=S AND LISTS 23N+ eric Ty/es 23De( +!t Ty/es 23

    T e D t St te ent 25N+ eric ?er(!o;s 25String Ty/es 27Syste Const nts 27

    ri iti?e Ty/es S+ ry 27Ne;Ty/es 26Arr ys inside Ne;Ty/es 2#T e Use t Directi?e 2)

    1

  • 8/9/2019 Blitz Basic

    2/247

    ARRA=S 2:LISTS 30Di ing Lists 30Adding ite s to !ist 30

    rocessing Lists 31

    Re o?ing Ite s ,ro List 32List Str+ct+re 32T e ointer Ty/e 33

    5. R CEDURES 33Introd+ction 33St te ents 33,+nctions 35Rec+rsion 37Accessing G!o& ! 8 ri &!es 36

    roced+res S+ ry 36

    Asse &!er in B!it" roced+res 36

    7. ERR R C%EC ING@DEBUGGING 3#Co /i!e Ti e Errors 3#T e CERR Directi?e 3#R+nti e Errors 3)T e B!it" De&+gger 3)T e De&+gger G dgets 3:Tr cing /rogr e$ec+tion 3:Res+ ing Nor ! E$ec+tion 508ie;ing co nd istory 50Direct *ode 50De&+gger Errors 51

    6. BLITZ B

  • 8/9/2019 Blitz Basic

    3/247

    S/rites 56S!ices 56,i!es 56

    & ects S+ ry 5#

    #. BLITZ * DE 5#S!ice * gic 5#S oot Scro!!ing 5)D+ ! ! y(ie!d 5)Co//er Contro! 5)T e B!itter 5:

    A ig *ode 5:S+ ry 70

    ). AD8ANCED T ICS 70Resident ,i!es 70

    /er ting Syste C !!s 71C !!ing S Li&r ries 71Accessing S Str+ct+res 72Loc ting 8 ri &!es @ L &e!s 73Const nts 73Condition ! Co /i!ing 75* cros 77* cro r eters 76T e 40 r eter 7#Rec+rsi?e * cros 7)Re/! cing ,+nctions ;it * cros 7)T e C* 'e C r cter 7)In!ine Asse &!er 7:GetReg @ +tReg 7:Asse &!er in roced+res 60

    :. R GRA**ING @ TI*IZING 61L &e! nd 8 ri &!e N es 61Sty!e 61N ing re! ted /ro&!e s 62Re r's nd Co ents 62

    Str+ct+red /rogr ing 62ee/ing t ings od+! r 63ee/ing yo+r code re d &!e 65/ti ising Code 65

    A!gorit s 67Loo/s 67Loo'+/ t &!es 67Using ointers 66

    3

  • 8/9/2019 Blitz Basic

    4/247

    Testing er(or nce 66/ti ising G es 66

    10. R GRA* E A* LES 6#N+ &er G+essing 6#

    St nd !one 9or'Benc /rogs 6)A Gr / ic E$ /!e 6:Using *en+s @ ,i!e Re-+esters #0String G dgets #1

    ro/ G dgets #3D t & se Ty/e A/!ic tion #5T e one Boo' rogr #5List rocessor (or E$ec #6

    ri e N+ &er Gener tor #)C!i//ed B!its #:D+ ! ! ytie!d S!ice )0

    Do+&!e B+((ering )1S oot Scro!!ing )2

    11. T%E DIS LA=LIBRAR=@AGA )3Introd+ction )3Initi !ising )5,! gs +sed ;it InitCo/List )5Co!ors )7S oot Scro!!ing )7D+ ! ! y(ie!d )7S/rites )6,etc *ode )6*+!ti/!e Dis/! ys )6Ad? nced Co//er Contro! )6Dis/! y E$ /!e 1 )#Dis/! y E$ /!e 2 ))

    4

  • 8/9/2019 Blitz Basic

    5/247

    C **AND RE,ERENCE SECTI N ): A ENDIR 1F R GRA* ,L 9 0): A 1F C * ILE TI*E ERR RS 202R 2F 8ARIABLE %ANDLING 0:7 Gener ! Synt $ Errors 202R 3F IN UT UT UT C **ANDS 0:) roced+re Re! ted Errors 203R 5F ,ILE %ANDLING @ I,,IN, 103 Const nt Re! ted Errors 205

    R 7F NU*ERIC@STRING ,UNCTI NS 106 E$/ression E !+ tion Errors 205R 6F C * ILER DIRECTI8ES 113 I!!eg ! Errors 205R #F ASSE*BLER DIRECTI8ES 116 Li&r ry B sed Errors 207R )F *E* R= C NTR L 11) Inc!+de Errors 207R :F R GRA* STARTU 120 rogr ,!o; B sed Errors 207R 10F SLICE C **ANDS 121 Ty/e B sed Errors 206R 11F DIS LA= LIBRAR= 127 Condition Co /i!ing Errors 20#R 12F BLITZ* DE I C **ANDS 12: Resident B sed Errors 20#R 13F BIT*A C **ANDS 133 * cro B sed Errors 20#R 15F 2D DRA9ING C **ANDS 137 Arr y Errors 20)R 17F ANI*ATI N SU RT 13# Interr+/t B sed Errors 20)

    R 16F S%A E %ANDLING 13# Direct *ode 20:R 1#F BLITTING C **ANDS 151 Se!ect...End Se!ect Errors 210R 1)F S RITE %ANDLING 15# B!it" *ode 210R 1:F C LLISI N DETECTI N 15: Str nge Be st Errors 210R 20F ALETTE C **ANDS 171 A 2F ERATING S=STE* CALLS 210R 21F S UND *USIC @ S EEC% 177 E EC 211R 22F SCREEN C **ANDS 160 D S 215R 23F 9IND 9 C **ANDS 163 GRA %ICS 21)R 25F GADGET C **ANDS 1#5 INTUITI N 221R 27F *ENU C **ANDS 1)1 DIS , NT 225R 26F GADT LS C **ANDS 1)5R 2#F ASL LIBRAR= C **ANDS 1)) A 3F %ARD9ARE REGISTERS 225R 2)F ARE C NTR L 1): Bit/! ne @ Dis/! y Contro! 225 Co nd ActionH Codes 1:3 T e Co//er 22#R 2:F BRE C **ANDS 1:) Co!o+r Registers 22)R 30F SERIAL RT C **ANDS 200 G!itter Contro! 22) A+dio Contro! 231 S/rite Contro! 232 Inter+/t Contro! 233 D*A Contro! 235 A ig CIAs 237

    A 5F 6)000 ASSE*BL= LANGUAGE236 6)000 Instr+ction Set 23: Registers 236 Addressing 236 rogr ,!o; 23# T e St c' 23) Condition ! ,! gs 23) Condition ! Tests 23)

    5

  • 8/9/2019 Blitz Basic

    6/247

    Directory Tree (or % rd Dis' +sers

    D%1F B!it" /rogr (i!es

    B!it"!i&s resident (i!es

    ig !i&s ig !i&r ries ot er!i&s t ird / rty !i&r ries

    De?e!o/ers doc+ ent tion

    cid!i&src cid !i&r ry so+rce code ig inc!+des syste inc!+des too!so+rce de?e!o/er too!so+rce code +ser!i&docs does (or t ird / rty (i&s +ser!i&/rogs test /rogr s (or t ird / rty (i&s

    User!i&so+rce so+rce code (or t ird / rty (i&s

    E$ /!es ig ode ndre;sde os &!it" ode r'sde os Je$ /!e code si onsde os tedsde os

    too!s

    User!i&s

    1. GETTING STARTED

    6

  • 8/9/2019 Blitz Basic

    7/247

    Using Ted t e B!it"2 Editor

    To enter nd co /i!e yo+r /rogr s yo+ need n editor. B!it"2 co es ;it te$teditor t t cts &ot s n inter( ce to t e B!it"2 co /i!er s ;e!! s st nd !one

    scii editor scii is t e co /+ter st nd rd (or nor ! te$tH

    T e ori"ont ! nd ?ertic ! & rs re c !!ed 4scro!! & rs4. ; en t e (i!e yo+ reediting is !onger or ;ider t n t e screen yo+ c n /osition yo+r ?ie; o( t e (i!e &ydr gging t ese & rs inside t eir &o$es ;it t e !e(t o+se &+tton.

    At t e &otto o( t e screen is in(or tion &o+t t e c+rsor /osition re! ti?e to t est rt o( t e (i!e yo+ re editing s ;e!! s e ory onitor t t !ets yo+ 'no; t e! rgest &!oc' o( e ory ? i! &!e in yo+r A ig syste .

    Using t e !e(t o+se &+tton yo+ c n dr g t e B!it"2 screen +/ nd do;n +st !i'e nyot er A ig screen s ;e!! s /! ce it to t e & c' ;it t e (ront to & c' g dgets tt e to/ rig t o( t e screen.

    Entering Te$t

    T e editor c n &e tre ted +st !i'e st nd rd ty/e;riter> +st go e d nd ty/e>+sing t e ret+rn 'ey to st rt ne; !ine.

    T e s !! &o$ t t o?es cross t e screen s yo+ ty/e is c !!ed t e c+rsor. 9 eret e c+rsor is /ositioned on t e screen is ; ere t e !etters ;i!! //e r ; en yo+ ty/e.

    By +sing t e rro; 'eys yo+ c n o?e t e c+rsor ro+nd yo+r doc+ ent> erein to&e 'no;n s t e (i!e.

    I( yo+ /! ce t e c+rsor in t e idd!e o( te$t yo+ ?e !re dy ty/ed yo+ c n insert!etters +st &y ty/ing> t e editor ;i!! o?e !! t e c r cters +nder nd to t e rig t o(t e c+rsor !ong one nd insert t e 'ey yo+ /ressed into t e s/ ce cre ted.

    T e DEL 'ey ;i!! re o?e t e c r cter direct!y +nder t e c+rsor nd o?e t ere ining te$t on t e !ine !e(t one c r cter to co?er +/ t e g /.

    T e 'ey to t e !e(t o( t e DEL 'ey ;i!! !so re o?e c r cter &+t +n!i'e t e DEL 'eyit re o?es t e c r cter to t e !e(t o( t e c+rsor o?ing t e c+rsor nd t e rest o( t e!ine to t e !e(t.

    T e TAB 'ey ;or's si i! r to ty/e;riter o?ing t e c+rsor nd ny te$t to t e rig to( t e c+rsor rig t &y so ny co!+ ns.T e RETURN 'ey s entioned !!o;s yo+ to st rt ne; !ine. I( yo+ re in t e

    idd!e o( !ine o( te$t nd ; nt to o?e !! te$t to t e rig t o( t e c+rsor do;n to

    7

  • 8/9/2019 Blitz Basic

    8/247

    ne; !ine +se s i(t RETURN> t is is 'no;n s inserting c rri ge ret+rn.

    To oin t;o !ines o( te$t +se t e A ig 'ey&o rd co &in tion.

    Using t e s i(t 'eys in co &in tion ;it t e rro; 'eys yo+ c n o?e t e c+rsor to

    t e ?ery st rt or end o( !ine nd +/ nd do;n ; o!e / ge o( t e doc+ ent.

    By /ointing ;it t e o+se to /osition on t e screen yo+ c n o?e t e c+rsort ere &y c!ic'ing t e !e(t o+se &+tton.

    See 'ey&o rd s ortc+ts t t e end o( t is c /ter (or ot er 'eys +sed ;it t e B!it"2.

    %ig !ig ting &!oc's o( te$t

    9 en editing te$t> es/eci !!y /rogr s yo+ o(ten need to o/er te on &!oc' o( te$t.osition t e o+se t t e st rt or end o( t e &!oc'> o!d do;n t e !e(t o+se &+ttonnd dr g t e o+se to ig !ig t t e re yo+ ;is to co/y> de!ete> s ?e or indent.

    9 i!e o!ding do;n t e &+tton yo+ c n scro!! t e dis/! y &y o?ing t e /ointer to t e?ery to/ or &otto o( t e dis/! y.

    =o+ c n !so se!ect &!oc' ;it t e 'ey&o rd> /osition t e c+rsor t t e st rt o( t e&!oc' o( te$t> it t e ,1 'ey t en /osition t e c+rsor t t e end o( t e te$t nd it ,2.

    A s/eci ! (e t+re (or str+ct+red /rogr ers is t e A ig A 'ey co &in tion> t is+to tic !!y ig !ig ts t e c+rrent !ine nd ny &o?e or &e!o; t t re indented t e

    s e n+ &er o( s/ ces.

    T e Editor *en+s

    Using t e rig t o+se &+tton yo+ c n ccess t e en+ syste o( t e B!it"2 editor.,o!!o;ing is !ist o( (e t+res ccessi&!e (ro t ese en+s in order (ro !e(t to rig t.

    T e R

  • 8/9/2019 Blitz Basic

    9/247

    en &!es yo+ to e si!y se!ect t e (i!e n e yo+ ;is to s ?e yo+r (i!e s. See ! terin t is c /ter (or (+!! descri/tion o( +sing t e (i!e re-+ester.

    DE,AULTSC nges t e !oo' o( t e B!it"2 editor. =o+ c n edit t e / !ette> se!ect t e si"e o( (ont

    nd te!! t e syste i( yo+ ;is icons to &e cre ted ; en yo+r (i!es re s ?ed. T escro!! rgins dict te o; ( r (ro t e edge o( t e screen yo+r c+rsor needs to &e&e(ore B!it" scro!!s t e te$t.

    AB UT Dis/! ys ?ersion n+ &er nd credits concerning B!it"2.RINT Sends yo+r (i!e to n o+t/+t de?ice +s+ !!y RTF t e /rinter de?ice.

    CLIL +nc es co nd !ine inter( ce (ro t e editor> +se t e ENDCLI co nd to c!oset is CLI nd ret+rn to t e B!it"2 editor.

    CL SE9BC!oses 9B i( it is c+rrent!y o/en. T is o/tion s o+!d on!y &e +sed i( yo+ re r+nning?ery s ort on e ory s c!osing 9B c n (ree &o+t 50 o( ? !+ &!e C i/*e .

    UITC!ose t e B!it"2 editor nd ret+rns yo+ to ;or'&enc or CLI.

    T e EDIT*en+

    C =Co/ies &!oc' o( te$t t t is ig !ig ted ;it t e o+se or (! (2 'ey co &in tion tot e c+rrent c+rsor /osition. T e ,5 'ey is not er 'ey&o rd s ortc+t (or C =.

    ILL De!etes ig !ig ted &!oc' o( te$t s e s s i(t ,3 'eyH.

    BL C T DIS S ?es ig !ig ted &!oc' o( te$t to dis' in scii (or t.

    INSERT,R *DISLo ds (i!e (ro dis' nd inserts it into t e (i!e yo+ re editing t t e c+rsor /osition.

    , RGET De se!ects &!oc' o( te$t t t is se!ected ig !ig tedH.

    INSERTLINE Bre 's t e !ine into t;o !ines t t e c+rrent c+rsor /osition.

    DELETE LINE De!etes t e !ine o( te$t t e c+rsor is c+rrent!y !oc ted on.

    DELETE RIG%T De!etes !! te$t on t e !ine to t e rig t o( t e c+rsor.

    9

  • 8/9/2019 Blitz Basic

    10/247

    < IN ! ces t e te$t on t e !ine &e!o; t e c+rsor t t e end o( t e c+rrent !ine.

    BL C TAB S i(ts !! ig !ig ted te$t to t e rig t &y one t & rgin.

    BL C UNTAB S i(ts !! ig !ig ted te$t to t e !e(t &y one t & rgin.

    T e S URCE *en+

    T *o?es t e c+rsor to t e to/ o( t e (i!e

    B TT * *o?es t e c+rsor to t e ! st !ine o( t e (i!e.

    G T LINE *o?es t e c+rsor to t e !ine n+ &er o( yo+r c oice.

    T e SEARC% *en+

    ,IND 9i!! se rc t e (i!e (or string o( c r cters.

    NE T ositions t e c+rosr t t e ne$t occ+rrence o( t e ,ind String entered +sing t e,IND en+ o/tion s &e!o;H.

    RE8I US9i!! /osition t e c+rosr t t e ! st occ+rrence o( t e ,indF String entered+sing t e ,IND en+ o/tion s &e!o;H.

    RE LACE 9i!! c rry o+t t e s e (+nction s disc+ssed in t e ,IND re-+ester &e!o;.

    A(ter se!ecting ,IND in t e SEARC% en+ t e (o!!o;ing re-+ester ;i!! //e rFTy/e t e string t t yo+ ;is to se rc (or into t e to/ string g dget nd c!ic' onNE T. T is ;i!! /osition t e c+rsor t t e ne$t occ+rrence o( t e string> i( t ere is nos+c string t e screen ;i!! (! s .

    Use t e RE8I US icon to se rc & c'; rds (ro t e c+rrent c+rsor /osition.

    T e CASE SENSITI8E o/tion ;i!! on!y (ind strings t t ?e s e !etters c /it !i"ed>

    de( +!t is t t t e se rc ;i!! ignore ; et er !etters re c /s or not.

    To re/! ce t e (ind string ;it n !tern te string c!ic' on t e &o$ ne$t to RE LACEFnd ty/e t e !tern te string. RE LACE ;i!! se rc (or t e ne$t occ+rrence o( t e ,indF

    string> de!ete it> nd insert t e Re/! ceF string in it4s /! ce.RE LACE ALL ;i!! c rry on t ro+g t e (i!e doing re/! ces on !! occ+rrences o(t e ,indF string.

    10

  • 8/9/2019 Blitz Basic

    11/247

    T e B!it" ,i!e Re-+ester

    9 en yo+ se!ect !o d or s ?e> B!it"2 /! ces (i!e re-+ester on t e screen.

    9it t e (i!e re-+ester yo+ c n -+ic'!y nd e si!y (ind t e (i!e on dis'.

    C!ic'ing on t e to/ !e(t o( t e ;indo; or on t e CANCEL g dget t t e &otto rig t ;i!!c nce! t e (i!e re-+ester ret+rning yo+ to t e editor.

    T e s!ider t t e rig t en &!es yo+ to scro!! +/ nd do;n t ro+g t e (i!es in t ec+rrent!y se!ected directory dr ;erH.

    Do+&!e c!ic'ing on (i!e n e /ointing to t e n e nd /ressing t e !e(t o+se &+ttont;iceH ;i!! se!ect t t (i!e n e.

    C!ic'ing on DIRM ;i!! c nge to t t directory nd !ist t e (i!es cont ined in it.

    C!ic'ing on ARENT ;i!! ret+rn yo+ to t e / rent directory.

    C!ic'ing on dri?es dds !ist o( !! dri?es> ?o!+ es nd ssigned de?icesto t e to/ o( t e (i!e !ist so yo+ c n o?e into t eir directories.

    =o+ c n !so enter / t nd (i!e n es ;it t e 'ey&o rd &y c!ic'ing on t e &o$es ne$tto AT%F nd ,ILEF nd entering t e s+it &!e te$t. T en C!ic' on t e g dget.

    CD is s/eci ! co nd +sed ; en /rogr ing in B!it"2 to c nge t e editorsc+rrent directory to t t s/eci(ied in t e / t n e. 9 en yo+ se!ect CLI or ! +nc t s' (ro t e editor its root directory ;i!! &e t t se!ected &y t e CD g dget.

    L st (e t+re o( B!it"2 ,i!eRe-+ester is t e &i!ity to si"e its ;indo;> dr gging &ottorig t o( t e ;indo; ;it t e !e(t o+se &+tton yo+ c n see ore (i!es t one ti e.

    T e Co /i!er *en+

    T e (o!!o;ing is disc+ssion o( t e e$tr o/tions nd co nds ? i! &!e ;it Ted

    ; en +sed in B!it"2 /rogr ing ode. T e Co /i!er en+ inc!+des !! t e co ndsneeded to contro! t e B!it"2 co /i!er.

    C * ILE RUN Co /i!es yo+r B!it"2 /rogr to e ory nd i( t ere re no errorsr+n t e /rogr .

    RUN R+ns t e /rogr i( it s !re dy &een s+ccess(+!!y co /i!ed to e ory.

    11

  • 8/9/2019 Blitz Basic

    12/247

    CREATE ,ILE Co /i!e yo+r B!it"2 /rogr to dis' s n e$ec+t &!e /rogr .

    TI NS See ne$t / ge (or det i!s &o+t B!it"2 co /i!er o/tions.

    CREATERESIDENT 9i!! cre te 4resident (i!e4 (ro t e c+rrent (i!e. A resident is

    (i!e inc!+ding !! const nts nd cro de(initions s ;e!! s ne;ty/e de(initions.By re o?ing ! rge c +n's o( t ese de(initions (ro yo+r code nd cre ting resident/re co /i!edH (i!e dr tic incre se in co /i!e s/eed c n &e tt ined.

    8IE9 T= EA!!o;s yo+ to ?ie; !! c+rrent!y resident ty/es. C!ic' on t e ty/e n e nd itsde(inition ;i!! &e s o;n. S+&ty/es c n &e ?ie;ed (ro t is e$/ nsion !so.

    CLI ARGU*ENTEn &!es yo+ to / ss / r eters to yo+r /rogr ; en e$ec+ting it (ro t eB!it"2 editor en?iron ent +st s i( yo+ d r+n t e /rogr (ro t e CLI.

    CALCULAT RA!!o;s yo+ do to c !c+! tions in & se 2> 10 nd 16. recede e$ ? !+es ;it

    nd &in ry ;it O. It !so s+//orts +!ti !e?e!s o( / rent esis.

    REL AD ALL LIBS9i!! re d !! (i!es (ro BLITZLIBSF & c' into B!it"2 co /i!er en?iron ent. ItKs +se(+!; en ;riting yo+r o;n B!it"2 !i&s nd ;is to test t e ;it o+t ?ing to re r+n B!it"2.

    Co /i!er /tionsT e (o!!o;ing is disc+ssion o( t e /tions re-+ester (o+nd in t e Co /i!er en+.

    Cre te Icons (or E$ec+t &!e ,i!esF i( on> t e co /i!er cre tes n icon tocco / ny t e (i!e cre ted ;it t e CREATE ,TLE o/tion. T is e ns t e /rogr

    ;i!! &e ccessi&!e (ro t e 9B. NoteF (or t e /rogr to e$ec+te correct!y ; en r+n (ro 9B t e 9BSt rtU/ co nd s o+!d &e inc!+ded t t e to/ o( t e so+rce code.

    En &!e R+nti e ErrorsF ; en on ;i!! tr / r+nti e errors nd in?o'e t e B!it"2de&+gger. See C /ter 7 (or t oro+g disc+ssion o( r+nti e errors in B!it"2.

    * 'e S !!est CodeF se!ects t;o / ss co /i!e ode> ; ic !; ys c !c+! tes t ein o+nt o( e ory re-+ired (or t e o& ect code. * 'e S !!est is +to tic !!y

    se!ected ; en cre ting e$ec+t &!e (i!es. Unse!ected> /rogr s ;i!! co /i!e -+ic'er.

    De&+g In(oF cre tes sy &o!s t &!e d+ring CREATE ,ILE so e$ec+t &!e c n &ede&+gged ore e si!y ;it de&+ggers s+c s *et dig 4s e$ce!!ent *et Sco/e.

    B+((er Si"esF !!o;s di((erent &+((ers to &e !tered ; en +sing B!it"2 s one / ssco /i!er. T ese &+((ers re +to tic !!y o/ti i"ed ; en +sing * 'eS !!est t;o

    12

  • 8/9/2019 Blitz Basic

    13/247

    / ss co /i!eH. T e one e$ce/tion is t e string &+((er setting> i( +sing ! rge stringss+c s re ding entire (i!es into one stringH t e string ;or's/ ce &+((er s o+!d &e

    incre sed in si"e to nd!e t e ! rgest string +sed.

    & ect * $i + sF !!o;s setting o( $i + n+ &er o( B!it"2 o& ects s+c s

    screens> s /es etc. See C /ter 6 (or t oro+g e$/! n tion o( B!it"2o& ects nd t eir $i + settings.

    ResidentF dds /reco /i!ed resident (i!es to t e B!it"2 en?iron ent. C!ic' in t e &o$nd ty/e in t e resident (i!e n e.

    ey&o rd S ortc+ts

    % ?ing to re c (or t e o+se to e$ec+te so e o( t e editor co nds c n &e n+is nce. T e (o!!o;ing is !ist o( 'ey&o rd s ortc+ts t t e$ec+te t e s e o/tions

    t t re ? i! &!e in t e en+s.

    T e rig t A ig 'ey is +st to t e rig t o( t e s/ ce & r nd s o+!d &e +sed !i'e t es i(t 'ey in co &in tion ;it t e st ted 'eys to e$ec+te t e (o!!o;ing co ndsF

    A ig A SELECTs !! te$t t t is indented t e s e o+nt s t e c+rrent !inestrict!y (or str+ct+red /rogr ing o+se'ee/ingH

    A ig B B TT * ;i!! /osition c+rsor on ! st !ine o( (i!e

    A ig D DELETE LINE re o?es t e !ine o( te$t on t e c+rsor /osition

    A ig , ,IND RE LACE e$ec+tes t e ,IND co nd in t e SEARC% en+

    A ig G G T LINE o?es c+rsor to s/eci(ic !ine o( (i!e

    A ig I INSERT LINE o?es !! te$t t nd &e!o; t e c+rsor do;n one !ine

    A ig < < IN LINE d oins ne$t !ine ;it c+rrent !ine

    A ig L L AD re ds (i!e (ro dis'

    A ig N NE T se rc es (or t e ne$t occ+rrence o( t e 4(ind string4

    A ig RE8I US se rc ed (or /re?io+s occ+rrence o( t e 4(ind string4

    A ig UIT ;i!! e$it t e B!it"2 editor

    13

  • 8/9/2019 Blitz Basic

    14/247

    A ig R RE LACE ;i!! re/! ce te$t t c+rsor i( s e s (ind stringH ;it t e!tern te string s/eci(ied ;it t e ,ind co nd.

    A ig S SA8E ;rites (i!e to dis'

    A ig T T o?es t e c+rsor to t e to/ o( t e (i!e

    A ig 9 , RGET ;i!! +n ig !ig t se!ected &!oc' o( te$t

    A ig = DELETE T RIG%T o( c+rsor

    A ig Z CLI

    A ig P DE,AULTS !!o;s t e +ser to c nge t e !oo' nd (ee! o( t e B!it"2 editor

    A ig Q BL C TAB o?es ; o!e &!oc' rig t one t &

    A ig BL C UNTAB o?es ; o!e &!oc' !e(t one t &

    2. BLITZ BASIC4S

    Ty/e in t e (o!!o;ing t;o !inesF

    rint T is is y (irst /rogr ;ritten in B!it"2*o+se9 it

    End

    T en +sing t e rig t &+tton se!ect C * ILE@RUN (ro t e to/ rig t en+.

    I( yo+ ?e ty/ed t e /rogr in correct!y B!it"2 CLI 9indo; ;i!! //e r ;it t eess ge> c!ic' t e o+se &+tton to ret+rn to t e editor T ts !! t ere is to it

    T e rint Co ndosition t e c+rsor on t e rint st te ent nd /ress t e %EL 'ey> t e synt $ (or t erint co nd //e rs t t e to/ o( t e screen. It s o+!d re dF

    rint E$/ression >E$/ression...QT e s-+ re &r c'ets e n t t t e rint co nd ;i!! cce/t ny n+ &er o(e$/ressions se/ r ted &y co s. An e$/ression c n &e ny n+ &er> string te$tin -+otes H> ? ri &!e or BASIC c !c+! tion. T e (o!!o;ing is n e$ /!e o( !! t ese.

    Don4t (orget to inc!+de t e *o+se9 it co nd ; en yo+ test t is> ot er;ise B!it"2;i!! /rint t e ess ge nd ret+rn yo+ to editor &e(ore yo+ e?en ?e ti e to re d it.

    14

  • 8/9/2019 Blitz Basic

    15/247

    rint 3> CARS > > #V3

    T e (o!!o;ing s o+!d &e /rinted o+t on t e CLI ;indo;F 3CARS03

    I( ;e dd so e s/ cing &et;een e c e$/ression !i'e soF rint 3> CARS > > > #V3

    T e res+!t ;i!! &e t e !ineF 3 CARS 0 3

    ,or tted rinting9e c n c nge t e ; y B!it"2 /rints n+ &ers +sing t e ,or t co nd> t isis +se(+! i( ; nt to /rint !ist o( n+ &ers> in co!+ n.

    N rint co nd is +sed to o?e c+rsor to ne;!ine (ter /rinting t e e$/ressions.

    ,or t WWW.00

    N/rint 23.7N/rint 10N/rint .7N/rint 0*o+se9 it

    A Si /!e 8 ri &!eT e in /o;er o( /rogr ing ! ng+ ge !ies in it4s &i!ity to ni/+! ten+ &ers nd te$t. 8 ri &!es re +sed to store t ese /ieces o( in(or tion.

    T e (o!!o;ing !ine ;i!! store t e ? !+e 7 in t e ? ri &!e F X7

    T e ? ri &!e no; o!ds t e ? !+e 7. 9e c n te!! t e co /+ter to dd 1 tot e ? !+e o( 'ing it 6 +sing t e (o!!o;ing e$/ressionF X V1

    An e$/ression c n cont in ore t n one o/er tion> &r c'ets c n &e +sed to'e one o/er tion &e e? !+ ted &e(ore t e ot ersF X V3H #

    B!it"2 /er tors

    An e? !+ tion is co!!ection o( ? ri &!es> const nts> (+nctions nd o/er tors.E$ /!es o( o/er tors re t e /!+s nd in+s signs.

    An o/er tor ;i!! gener te n o+tco e +sing eit er t e ? ri &!e on it4s rig tF XN T 7or (ro t e ? ri &!es on it4s !e(t nd rig tF X7V2An e? !+ tion c n inc!+de +!ti/!e o/er torsF X7 6V3As in t e tics t e order t e o/er tors re e? !+ ted ;i!! ((ect t e o+tco e> i( t e

    +!ti/!y is done (irst in t e &o?e e$ /!e t e res+!t is 33> i( t e ddition ; s done

    15

  • 8/9/2019 Blitz Basic

    16/247

    (irst> 7 6V3H> t e res+!t ;i!! &e 50.

    9 en B!it" /er(or s n e? !+ tion so e o/er tors ?e /recedence o?er ot ers nd;i!! &e e? !+ ted (irst> t e (o!!o;ing t;o e? !+ tions ;i!! ?e t e s e res+!t &ec +seB!it"2 ;i!! !; ys e? !+ te +!ti/!ic tion &e(ore dditionF

    X7 6V3 is t e s e s X3V7 6

    To o?erride t e order ; ic B!it"2 e? !+ tes t e &o?e> / rent esis c n &e dded>o/er tions enc!osed in / rent esis ;i!! &e e? !+ ted (irstF X7 6V3H

    T e (o!!o;ing t &!e !ists t e B!it"2 o/er tors gro+/ed in order o( /riority L%SX!e(tnd side> R%SXrig t nd sideH. /er tors in t e s e &o$ ?e t e s e /riority.

    N T R%S !ogic !!y N TtedR%S rit etic !!y neg ted

    BITSET L%S ;it R%S &it setBITCLR L%S ;it R%S &it c!e redBITC%G L%S ;it R%S &it c ngedBITTST tr+e i( L%S &it o( R%S is s

    LSL L%S !ogic !!y s i(ted !e(t R%S ti esASL L%S rit etic !!y s i(ted !e(t R%S ti esLSR L%S !ogic !!y s i(ted rig t R%S ti esASR L%S rit etic !!y s i(ted rig t R%S ti es

    @ L%S !ogic !!y ANDed ;it R%SL%S !ogic !!y Red ;it R%S

    Y L%S to t e /o;er o( R%SL%S +!ti/!ied &y R%SL%S di?ided &y R%S

    V L%S dded to R%SR%S s+&tr cted (ro L%S

    X tr+e i( L%S is e-+ ! to R%SM tr+e i( L%S is not e-+ ! to R%S

    tr+e i( L%S is !ess t n R%SM tr+e i( L%S is gre ter t n R%S

    X tr+e i( L%S is !ess t n or e-+ ! to R%SMX tr+e i( L%S is gre ter t n or e-+ ! to R%SAND L%S !ogic !!y ANDed ;it R%S

    R L%S !ogic !!y Red ;it R%S

    Boo!e n /er tors

    16

  • 8/9/2019 Blitz Basic

    17/247

    T e &oo!e n syste c n on!y o/er te ;it t;o ? !+es> tr+e nd ( !se. In B!it"2 ( !seis re/resented &y t e ? !+e 0> tr+e ;it t e ? !+e 1.T e o/er tors X> M> X> XM> M nd !! gener te &oo!e n res+!t tr+e or ( !seH.

    N rint 2X2 ;i!! /rint ? !+e 1 s t e res+!t o( t e o/er tion 2X2 is tr+e. T e o/er tors

    R> AND nd N T c n &e +sed s &oo!e n o/er tors> N/rint 2X2 AND 7X6 ;i!! /rint 0 st e res+!t is ( !se. R o/er tor ret+rns tr+e i( eit er !e(t or rig t nd side is tr+e. N To/er tor ret+rns ( !se i( t e (o!!o;ing o/er nd is tr+e nd tr+e i( t e o/er nd is ( !se.

    Bin ry /er tors

    * ny o( B!it"2 o/er tors /er(or &in ry ty/e rit etic. T ese o/er tions re ?ery( st s t ey direct!y corres/ond to instr+ctions &+i!t into t e co /+ter4s /rocessor.

    T e &in ry syste e ns t t !! n+ &ers re re/resented &y series o( 1s nd 0s.A &yte is de +/ o( s+c &its> ;ord 16 nd !ong ;ord 32.

    Disc+ssion o( &in ry o/er tors in B!it"2 c n &e (o+nd in te$t co?ering 6)000 /rocessor.

    *+!ti/!e Co nds

    T e (o!!o;ing /rogr st rts ;it ? !+e o( 0> it t en /roceeds to dd 12 to t e

    ? !+e o( nd /rint t e res+!t 5 ti es.

    X0X V12FN/rint X V12FN/rint X V12FN/rint X V12FN/rint

    *o+se9 it

    Note o; ;e c n /+t t;o co nds on t e s e !ine &y se/ r ting e c co nd;it co!on c r cter. A!so> t e (irst !ine X0 is not needed s ? ri &!es in B!it"2

    !; ys st rt o+t ;it ? !+e o( 0 ny; y.

    A Si /!e Loo/

    T e (o!!o;ing /rogr /rints o+t t e 12 ti es t &!e. Inste d o( ty/ing in 12 !inesto do t is ;e +se ,or..Ne$t !oo/. A !oo/ is ; ere t e /rogr is to!d to re/e t section o( /rogr ny ti es.,or iX1 To 12..Ne$t ;i!! e$ec+te t e co nds &et;een t e ,or nd Ne$t 12 ti es>t e ? ri &!e i is +sed to 'ee/ co+nt.

    17

  • 8/9/2019 Blitz Basic

    18/247

    T e steris' e ns +!ti/!y> Xi 12 e ns t e ? ri &!e no; e-+ !s 12 $ t e? ri &!e i. Bec +se i is co+nting +/ (ro 1 to 12 t e ? ri &!e is ssigned t e? !+es 12> 25> 36>5 .. s t e /rogr !oo/s.

    ,or iX1 To 12Xi 1 2N rint i> >12> X >

    Ne$t*o+se9 itEnd

    Note o; t e 2 !ines inside t e !oo/ re indented cross t e / ge. T is /r ctice'es it e sy to see ; ic &its o( t e /rogr re inside !oo/s nd ; ic re not.

    T e T & 'ey c n &e +sed to o?e t e c+rsor cross t e / ge so ny s/ ces

    ; en ty/ing in !ines t t re indented.

    No; try c nging t e (irst !ine to ,or iX1 To 100> s yo+ c n see t e co /+ter sno /ro&!e ; t so e?er doing it4s 12 ti es t &!e

    9e co+!d !so c nge t e n+ &er 12 in t e (irst 3 !ines to ny ot er n+ &er togener te n !tern ti?e ti es t &!e.

    Nested Loo/s

    ,o!!o;ing /rogr is n e$ /!e o( nesting !oo/s> ter t t re(ers to ?ing !oo/sinside o( !oo/s. By indenting t e code t t is inside inner !oo/ e?en (+rt er ;e c n 'ee/

    c ec' to 'e s+re e c ,or st te ent !ines +/ ;it e c Ne$t st te ent.

    ,or yX1 To 12,or $X1 To 12

    N rint y> >$> X >$ yNe$t

    Ne$t*o+se9 it

    T e nesting o( t e ,or $X1 To 12 inside t e ,or yX1 To 12 e ns t e !ine inside t e ,or$ ;i!! &e e$ec+ted 12 $ 12 ti es> e c ti e ;it ne;co &in tion o( $ nd y.

    9 i!e..9end nd Re/e t..Unti!

    T ere re t;o ot er si /!e ; ys to /rogr !oo/s in B!it"2 &esides +sing ,or..Ne$t.

    9 i!e..9end nd Re/e t..Unti! !oo/s re +sed s (o!!o;sF

    18

  • 8/9/2019 Blitz Basic

    19/247

  • 8/9/2019 Blitz Basic

    20/247

    X Si on F & X Ar strong Fc X V&

    T e ? ri &!e c ;i!! no; cont in t e string Si onAr strong . t er (+nctionst t ni/+! te strings re det i!ed in t e re(erence section o( t is n+ !.

    rogr ,!o;

    (ten /rogr ;i!! ?e to decide to do eit er one t ing or not er> t is is c !!ed/rogr "n (!o;. T e I( T en co nds re +sed to te!! t e /rogr to do so et ing on!yI( so e condition is tr+e. T e (o!!o;ing ;i!! on!y /rint %e!!o i( t e ? ri &!e s t e? !+e 7F I( X7 T en rint %e!!o

    T e &o?e !ine co+!d &e c nged to do section o( co nds i( ; s e-+ ! to 7+sing t e I,..Endi( str+ct+reF

    I( X7rint %e!!oX 1

    Endi(

    T e E!se co nd is +sed to e$ec+te n !tern ti?e section i( t e condition is not tr+eF

    I( X7rint %e!!o

    E!serint GoodBye

    Endi(

    Note o; ;e indent code inside condition ! &!oc's +st !i'e ;e did ;it!oo/s. T is 'es t e code ore re d &!e> it is e sier to see ; ic !ineso( code ;i!! &e e$ec+ted ; en t e condition is tr+e etc.

    T e condition (ter t e I( co nd c n &e ny co /!e$ e$/ression> t e (o!!o;ingre so e e$ /!es o( /ossi&!e test conditionsF

    I( X1 R &X2I( M&V7

    I( V10H 70 M & # 3

    An //endi$ t t e end o( t is n+ ! cont ins co /!ete descri/tion o( +sing+!ti/!e o/er tors nd t eir /recedence.

  • 8/9/2019 Blitz Basic

    21/247

    (ten t e /rogr ;i!! need to + / to di((erent section o( t e code. T eGoto nd Gos+& ro+tines re +sed (or t is. T e !oc tion t t t e /rogr is

    + /ing to needs ! &e! so t t Goto nd Gos+& c n re(erence t e !oc tiont ey re + /ing to. T e (o!!o;ing +ses t e ! &e! st r tF

    Goto st rtN rint %I T%EREst rt*o+se9 it

    T e Goto st te ent 'es t e /rogr + / to ! &e! st rt> %i T ere is ne?er /rinted.

    T e Gos+& co nd is +sed to + / to s+&ro+tine> s+&ro+tine is /iece o( codeter in ted ;it Ret+rn st te ent. T is e ns t t (ter e$ec+ting t e s+&ro+tine>/rogr (!o; ret+rns to ; ere t e Gos+& co nd ; s e$ec+ted nd c rries on.

    .st rtFGos+& ess geGos+& ess geGos+& ess ge*o+se9 itEnd

    . ess geN rint %e!!oRet+rn

    Note o; ! &e!s re /receded ;it /eriod T is 'es t e o+s &!e ! &e!s ; ic//e r in !ist on t e rig t o( t e editor screen. 9e c n 'e c+rsor + / to ! &e! &y

    c!ic'ing it in t is !ist. T is is e$tre e!y +se(+! (or ; en editing ! rge /rogr s.

    Getting In/+t (ro t e User

    A /rogr ;i!! o(ten re-+ire in/+t (ro t e +ser ; en it is r+nning eit er ?i t e'ey&o rd or o+se. ,or inst nce> t e *o+se9 it co nd ;i!! sto/ t e /rogr +nti!t e +ser c!ic's t e !e(t o+se &+tton.

    ey&o rd in/+t c n &e o&t ined +sing t e Edit nd Edit (+nctions ; ic is t e s e st e In/+t co nd in ot er ! ng+ ges.

    ,o!!o;ing s's t e +ser (or t eir n e nd /! ces it into string ? ri &!eF

    rint 9 t is yo+r n ePXEdit )0H

    N rint %e!!o >

    21

  • 8/9/2019 Blitz Basic

    22/247

    *o+se9 it

    N+ &er )0 in Edit )0H re(ers to $i + n+ &er o( c r cters t e +ser c n ty/e.

    To in/+t n+ &ers (ro t e +ser t e Edit (+nction is +sed> XEdit )0H ;i!! !et t e +ser

    ty/e in ny n+ &er +/ to )0 digits !ong nd ;i!! /! ce it in t e ? ri &!e .

    Arr ys

    (ten /rogr ;i!! need to ni/+! te gro+/s o( n+ &ers or strings. An rr y is&!e to o!d s+c gro+/s. I( ;e needed to 'ee/ tr c' o( ten n+ &ers t t ;ere !!

    re! ted> inste d o( +sing ten di((erent ? ri &!es ;e c n de(ine n rr y to o!d t e .

    T e Di st te ent is +sed to de(ine n rr yF Di 10H

    T e ? ri &!e c n no; o!d 10 ct+ !!y 11H n+ &ers> to ccess t e ;e/! ce n inde$ n+ &er inside &r c'ets (ter t e ? ri &!e n eF

    1 HX72HX6:HX22

    N rint :H1HX 1HV 2H

    N rint 1H

    T e /o;er o( n rr y is t t t e inde$ n+ &er c n &e ? ri &!e> i( iX2

    t en iH re(ers to t e s e ? ri &!e >is 2H.

    T e (o!!o;ing in/+ts 7 strings (ron1 t e +ser +sing ,or..Ne$t !oo/>&ec +se t e strings re /! ced in n n y t ey c n &e /rinted & c' o+tF

    Di 20H

    N rint Ty/e in 7 n es,oriX1 To7

    iH X Ed it )0HNe$t

    N rint T e n es yo+ ty/ed ;ere,or iX1 To 7

    N rint iHNe$t*o+se9 it Ne$t

    3. T= ES> ARRA=S AND LISTS

    22

  • 8/9/2019 Blitz Basic

    23/247

    N+ eric Ty/es

    B!it"2 s+//orts 6 di((erent ty/es o( ? ri &!es T ere re 7 n+ eric ty/es (or storingn+ eric ? !+es ;it di((ering r nges nd cc+r cies s ;e!! s string ty/e +sed tostore strings o( c r cters te$tH.

    T e (o!!o;ing t &!e descri&es e c B!it"2 n+ eric ? ri &!e ty/e ;it det i!s on itsr nge nd cc+r cy nd o; ny &ytes o( e ory e c re-+ires

    Ty/e S+((i$ R nge Acc+r cy Bytes

    Byte .& V 12: integer 19ord .; V 32#6) integer 2Long .! V 215#5)365) integer 5

    +ic' .- V 32#6).0000 1 67736 2,!o t .( V : 10 1) 1 10 1) 5

    23T e +ic' ty/e is (i$ed /oint ty/e> !ess cc+r te t n (!o ting /oint &+t ( ster.

    T e ,!o t ty/e is t e ,!o ting oint ty/e s+//orted &y t e A ig ! st , !i&r ries.

    A ? ri &!e is ssigned cert in ty/e &y dding t e re!e? nt s+((i$ to it4s n e A(ter t e(irst re(erence to ? ri &!e> its ty/e is ssigned nd ny (+t+re re(erences do notre-+ire t e s+((i$ +n!ess it is string ? ri &!e.

    ,o!!o;ing re so e e$ /!es o( ty/ic ! n+ eric ? ri &!es ;it t eir re!e? nt s+t(i$.

    yc r &X12#y[score.;X32000

    c i/.!X d((000 J denotes e$ ? !+es/eed3.-X700 # J -+ic' s 3 d./. cc+r cy!ig t[s/eed.(X3e) Je is e$/onent i.e. 3 10A)

    De( +!t Ty/es

    I( no s+((i$ is +sed in t e (irst re(erence o( ? ri &!e> B!it"2 ;i!! ssign t t ? ri &!e;it t e de( +!t ty/e. T is is initi !!y t e +ic' ty/e.

    T ere re t;o (or s o( t e De(Ty/e co nd> one ; ic c nges t e de( +!t ty/e t eot er ; ic de(ines t e ty/e o( !ist o( ? ri &!es s+//!ied &+t ; ic does not ((ectt e de( +!t ty/e.

    T e (o!!o;ing code i!!+str tes &ot +ses o( DE,T= EF

    X20 J ;i!! &e -+ic'DE,T= E .( J? rs ;it o+t s+((i$ ;i!! no; de( +!t to (!o t

    23

  • 8/9/2019 Blitz Basic

    24/247

    &X20 J& ;i!! &e (!o tDE,T= E .; c>d Jc @ d re ;ords> de( +!t sti!! (!o t

    NoteF t e second inst nce o( DE,T= E s o+!d &e re d de(ine ty/e r t er t n its (irst+se ; ic st nds (or c nge de( +!t ty/e. T e de( +!t ty/e c n !so &e set to

    ne;ty/e see (o!!o;ing sectionH.

    t er B!it"2 str+ct+res t t ;or' ;it cert in ty/e s+c s d t st te ents> (+nctions>/ee's nd /o'es ;i!! !so +se de( +!t ty/e i( no ty/e s+((i$ is inc!+ded.

    T e D t St te ent

    T e D t st te ent is +sed to o!d !ist o( ? !+es t t c n &e re d into ? ri &!es.T e Restore co nd is +sed to /oint t e d t /ointer t cert in D t st te ent.

    A.ty/e s+((i$ is dded to d t st te ent to de(ine ; t ty/e t e ? !+es !isted re.

    T e (o!!o;ing is n e$ /!e o( +sing D t in B!it"2F

    inFRe d >&>cRestore y(!o tsRe d d.( Restore ystringsRe d e >( >g

    y-+ic'sFD t 20>30>50

    y(!o tsFD t .( 20.357>10.#>:0.111

    ystringsFD t %e!!o > T ere > Si on

    NoteF i( t e d t /ointer is /ointing to di((erent ty/e t n t e ? ri &!e !isted in t eRe d st te ent *is tc ed Ty/es r+n+ e error occ+rs.

    N+ eric ?er(!o; @ Unsigned Integers

    9 en ? ri &!e is ssigned ? !+e o+tside o( it4s r nge too ! rgeH> n o?er(!o; error

    ;i!! occ+r. T e (o!!o;ing code ;i!! c +se n o?er(!o; error ; en it is e$ec+tedF

    .;X32#6# J is ;ord cont ining t e n+ &er 32#6#X V1 Jo?e((!o; occ+rs s res+!t is o+t o( r nge

    ?er(!o; c ec'ing is o/tion ! nd c n &e en &!ed dis &!ed in t e R+nTi e errorso/tions o( t e Co /i!er Con(ig+r tion. T e de( +!t setting is o(( e ning t e &o?ecode ;i!! not gener te r+nti e error. In so e inst nces> t e integer ty/es ;i!! &e

    24

  • 8/9/2019 Blitz Basic

    25/247

    re-+ired to re/resent +nsigned /ositi?e on!yH n+ &ers. ,or e$ /!e> &yte ? ri &!e;i!! &e re-+ired to o!d ? !+es &et;een nd 277 r t er t n 12# to 12). ?er(!o;c ec'ing s to &e dis &!ed in t e Error C ec'ing re-+ester o( t e Co /i!er /tions;indo; to +se +nsigned r nges s+c s t is.

    String Ty/es

    A string is ? ri &!e t t is +sed to store string o( c r cters> +s+ !!y te$t. T es+((i$ (or string ? ri &!e is eit er .s or t e tr dition ! c r cter.

    Un!i'e n+ eric ? ri &!es t e s+((i$ +st !; ys &e inc!+ded ;it t e n e.A!so> string ? ri &!e n es *A= &e re +sed s n+ eric ? ri &!e n es.

    T e (o!!o;ing is -+ite !eg !F

    X %ELL

    .;X20N rint >

    Syste Const nts

    B!it"2 reser?es (e; ? ri &!es t t o!d s/eci ! ? !+es 'no;n s syste const nts.T e (o!!o;ing ? ri &!es re reser?ed nd cont in t e !isted ? !+esF

    i X 3.1517n X 1(( X 0

    Tr+e X 1, !se X 0

    ri iti?e Ty/es S+ ry

    B!it"2 c+rrent!y s+//orts 6 /ri iti?e ty/es. Byte> 9ord nd Long re signed )> 16nd 32 &it ? ri &!e ty/es. T e +ic' ty/e is (i$ed /oint ty/e> !ess cc+r te t n

    , &+t ( ster. T e ,!o t ty/e is t e , ty/e s+//orted &y t e A ig , st , !i&r ries.

    T e String ty/e is st nd rd BASIC i /!e ent tion o( string4 ? ri &!e nd!ing.

    Using DetTy/e directi?e ? ri &!es c n &e de(ined s cert in ty/es ;it o+t dding t ere!e? nt s+((i$. nce ? ri &!e is de(ined s cert in ty/e> s+((i$ is not necess ry>e$ce/t in t e c se o( string ? ri &!es ; en t e s+((i$ +st !; ys &e inc!+ded.

    A ? ri &!e c n on!y &e o( one ty/e t ro+g o+t t e /rogr nd c nnot &e de(ined sny ot er e$ce/t g in in t e c se o( strings ; ere t e ? ri &!e n e c n ALS &e

    +sed (or n+ eric ty/e.

    25

  • 8/9/2019 Blitz Basic

    26/247

    Ne;Ty/es

    In ddition to t e 6 /ri iti?e ty/es ? i! &!e in B!it"2> /rogr ers !so ?e? i! &!e t e ( ci!ity to cre te t eir o;n c+sto ty/es.

    A Ne;Ty/e is co!!ection o( (ie!ds> si i! r to record in d t & se or C str+ct+re.T is en &!es t e /rogr er to gro+/ toget er re!e? nt (ie!ds in one ? ri &!e ty/e.

    T e (o!!o;ing code s o;s o; (ie!ds o!ding /erson4s n e> ge nd eig t c n &essigned to one ? ri &!eF

    NE9T= E . ersonn e

    ge.&eig t.-

    End NE9T= E

    . erson n eX % rry >20>2.1

    N rint eig t

    nce Ne;Ty/e is de(ined> ? ri &!es re ssigned t e ne; ty/e &y +sing s+((i$o( .Ne;Ty/en e (or e$ /!e . erson

    Indi?id+ ! (ie!ds ;it in Ne;Ty/e ? ri &!e re ccessed nd ssigned ;it t e& c's! s c r cter (or e$ /!eF eig tX eig tV1.

    9 en de(ining Ne;Ty/e str+ct+re> (ie!d n es ;it o+t s+((i$ ;i!! &essigned t e ty/e o( t e /re?io+s (ie!d. *ore t n one (ie!d c n &e !isted

    /er !ine o( Ne;Ty/e de(inition> t ey +st o;e?er &e se/ r ted &y co!ons.T e (o!!o;ing is not er e$ /!e o( Ne;Ty/e de(initionF

    Ne;Ty/e .n e$.;FyF" Jy @ " re !so ;ords see &o?eH? !+e.;s/eed.-n e

    End Ne;Ty/e

    Re(erences to string (ie!ds ; en +sing Ne;Ty/es do re-+ire or .s s+((i$ s nor !string ? ri &!es do> inc!+ding s+((i$ ;i!! c +se G r& ge t End co /i!e ti e error.

    ,ro t e (irst e$ /!eF

    26

  • 8/9/2019 Blitz Basic

    27/247

    n eX

  • 8/9/2019 Blitz Basic

    28/247

    NE9T= E .recordn e

    ge.;ddress.s 5Q >s e s ddress 5Q

    End NE9T= E

    DE,T= E .record /

    / ddress 0QX 10 St e?ins Arc de/ ddress 1QX r ng /e Ro d/ ddress 2QX A+c'! nd/ ddress 3QX Ne; Ze ! nd

    ,or iX0 To 3N rint / ddress iQ

    Ne$t

    *o+se9 it

    T e inde$Q c n &e o itted in ; ic c se t e (irst ite ite 0H ;i!! &e +sed.

    De(ining n rr y inside ne;ty/e ;it 0 e!e ents cre tes +nion ;it t e(o!!o;ing (ie!d &ot (ie!ds occ+/y t e s e e ory in t e Ne;Ty/eH.

    T e Use t Directi?e

    (ten ; en +sing co /!e$ Ne;Ty/es> / t n es to ccess (ie!ds ;it in (ie!dsc n &eco e ?ery !ong.

    (ten ro+tine ;i!1 &e de !ing on!y ;it one / rtic+! r (ie!d ;it in ne;ty/e. By +sing t e Use t directi?e ! rge / t n es c n &e ?oided.

    9 en & c's! s /recedes ? ri &!e or (ie!d n e B!it"2 ;i!! insert t eUse t / t de(inition ; en it co /i!es t e /rogr .

    T e (o!!o;ing codeF

    Use t s /es iH /os,or iX0 To : $V10 yV20 " 10

    Ne$tis e$/ nded intern !!y &y t e co /i!er to re dF

    28

  • 8/9/2019 Blitz Basic

    29/247

    ,or iX0 To :s /es iH /os $V10s /es iH /os yV20s /es iH /os " 10

    Ne$t

    Use t c n e!/ 'e ro+tines !ot ore re d &!e nd c n s ?e !ot o( ty/ing

    NoteF Use t is co /i!er directi?e> e nning t t it ((ects t e co /i!er s it re dst ro+g yo+r /rogr to/ to &otto not t e /rocessor ; en it r+ns yo+r /rogr .

    T is e ns t t i( ro+tine + /s to so e; ere e!se in t e /rogr t eUse t in e((ect ;i!! &e go?erned &y t e c!osest /re?io+s +se/ t in t e !isting.

    ARRA=S

    Arr ys in B!it"2 (o!!o; nor ! BASIC con?entions. A!! Arr ys *UST &e di ensioned&e(ore +se> y &e o( ny ty/e /ri iti?e or Ne;Ty/eH nd ny n+ &er o( di ensions.

    A!! rr ys re inde$ed (ro 0..n ; ere n is t e si"e. As ;it ost BASIC4s n rr ys+c s 70H c n ct+ !!y o!d 71 e!e ents inde$ed 0..70 inc!+si?e.

    An rr y ;i!! &e o( de( +!t ty/e +n!ess .ty/e s+((i$ is dded to t e rr y n eF

    Di .; 70H ( n rr y o( ;ords

    T e &i!ity to +se rr ys o( Ne;Ty/es o(ten red+ces t e n+ &er o( rr ys BASIC/rogr re-+ires.

    T e (o!!o;ingF Di A!ien(! gs 100H>A!ien$ 100H>A!ieny 100Hc n &e i /!e ented ;it t e (o!!o;ing codeF

    NE9T= E .A!ien(! gs.;$.;y.;

    End NE9T= E

    Di A!iens.A!ien 100H

    =o+ y no; ccess !! o( t e re-+ired !ien d t +sing +st one rr y.To set +/ !! o( t e !iens $ nd y entries ;it r ndo coordin tes

    ,or 'X1 To 100A!iens 'H $XRnd 320H>Rnd 200H

    29

  • 8/9/2019 Blitz Basic

    30/247

    Ne$t

    T is !so 'es it +c e sier to e$/ nd t e o+nt o( in(or tion (or t e !ienssi /!y &y dding ore entries to t e Ne;Ty/e de(inition> no ne; rr ys re-+ired.

    NoteF +n!i'e ost co /i!ers> B!it"2 D ES !!o; t e di ensioning o( rr ys;it ? ri &!e n+ &er o( e!e ents (or e$ /!eF Di nH. A!so strings in rr ys do notre-+ire $i + !engt setting s is t e c se ;it so e ot er ! ng+ ges.

    LISTS

    B!it"2 !so s+//orts n d? nced (or o( t e rr y 'no;n s t e List. Lists re rr ys>&+t ;it s!ig t!y di((erent c r cteristics.

    (ten on!y /ortion o( t e e!e ents in n rr y ;i!! &e +sed nd t e /rogr er ;i!!'ee/ co+nt in se/ r te ? ri &!e o( o; ny e!e ents re c+rrent!y stored in t e

    rr y. In t is sit+ tion t e rr y s o+!d &e re/! ced ;it !ist ; ic ;i!! 'e t ings&ot si /!er nd ( ster (or n ging t e rr y.

    Di ing Lists

    A !ist is di ensioned si i! r to n rr y e$ce/t t e ;ord List is inserted(ter t e ;ord Di . Lists re c+rrent!y !i ited to one di ension.

    %ere is n e$ /!e o( setting +/ !istF

    NE9T= E.A!ien

    (! gs.;F$FyEnd NE9T= E

    Di List A!iens.A!ien 100HT e di((erence &et;een !ist nd n rr y is t t B!it"2 ;i!! 'ee/ n intern ! co+nt o(

    o; ny e!e ents re stored in t e !ist reset to "ero (ter Di ListH nd n intern !/ointer to t e c+rrent e!e ent ;it in t e !ist c!e red (ter Di ListH.

    Adding ite s to !ist

    A !ist st rts o+t s e /ty> ite s c n &e dded +sing t e AddIte nd AddL st

    (+nctions. Bec +se t e !ist ig t &e (+!! &ot co nds ret+rn tr+e or ( !se toindic te ; et er t ey s+cceeded.

    T e (o!!o;ing dds one !ien to t e /re?io+s!y di ed !istF

    I( Addite A!iens HHA!iens H $XRnd 320H>Rnd 200H

    Endi(

    30

  • 8/9/2019 Blitz Basic

    31/247

    Note o; t ere is no inde$ ? ri &!e inside t e &r c'ets in eit er +se o( A!iens H.A!t o+g B!it"2 ;i!! not (! g n error ; en n inde$ is +sed> inde$es s o+!d ne?er &e+sed ;it !ist rr ys. T e e /ty &r c'ets re/resent t e c+rrent ite in t e !ist> in t isc se> t e ne;!y dded ite .

    Bec +se AddIte ret+rns ( !se ; en t e !ist is (+!! ;e c n +se 9 i!e..9end !oo/ to(i!! n entire !ist ;it !iens t en 'i!! 4e o(( s!o;!y HF

    9 i!e Addite A!iens HHA!iens H $XRnd 320HA!iens H yXRnd 200H

    9end

    T e &o?e !oo/s +nti! t e !ist is (+!!. 1s ;e ; nted to dd 20 !iens to !ist ;e co+!d+se ,or..Ne$t &+t sti!! need to c ec' i( t e !ist ; s (+!! e c ti e ;e dd n !ienF

    ,or iX1 To 20I( Addite A!iens HH

    A!iens H $XRnd 320HA!iens H ?XRnd 200H

    Endi( Ne$t

    Note t t !ists c n &e di ensioned to o!d ny ty/e not +st !iens

    rocessing Lists

    As entioned> ; en n ite is s+ccess(+!!y dded> t t ite &eco es t e c+rrentite . T is c+rrent ite y t en &e re(erenced &y s/eci(ying t e !ist rr y n e(o!!o;ed &y e /ty &r c'ets H.

    To /rocess !ist !oo/ t ro+g !! t e ite s dded to !istH> ;e reset t e !ist /ointer tot e &eginning +sing ResetList nd t en +se t e Ne$tIte co nd to ste/ t e /ointert ro+g t e ite s in t e !ist. T is intern ! /ointer /oints to t e c+rrent ite .

    T e (o!!o;ing o?es !! t e !iens in t e !ist in r t er ine((ecti?e nner to; rdst e idd!e o( t e screen 1 s+s/ectHF

    USE AT% A!iens HResetList A!iens H9 i!e Ne$tite A!iens HH

    I( $M160 T en $ 1 E!se $V1I( yM100 T en y 1 E!se yV1

    9end

    31

  • 8/9/2019 Blitz Basic

    32/247

  • 8/9/2019 Blitz Basic

    33/247

    T e /ointer ty/e in B!it"2 is co /!e$ &e st. 9 en yo+ de(ine ? ri &!e s /ointerty/e yo+ !so st te ; t ty/e it is /ointing to. T e (o!!o;ing de(ines &iggest s /ointer to ty/e C+sto er.

    De(Ty/e &iggest.C+sto er

    T e ? ri &!e &iggest is +st !ong ;ord t t o!ds e ory !oc tion ; ereso e ot er C+sto er ? ri &!e is !oc ted.

    As n e$ /!e ;e y ?e ! rge !ist o( c+sto ers> o+r ro+tine goes t ro+g t eone &y one> i( t e t+rno?er o( c+sto er is ! rger t n t e one /ointed to &y Biggestt en ;e /oint Biggest to; rds t e c+rrent c+sto erF &iggestXC+sto erArr y H

    nce ;e ?e !oo/ed t ro+g t e !ist ;e co+!d /rint o+t t e Biggest d t +st s i( it ; s ty/e C+sto er ; en it is ct+ !!y on!y /ointer to ? ri &!e ;it ty/ec+sto er ;it rint &iggest n e.

    5. R CEDURES

    Introd+ction

    A /roced+re is ; y o( 4/ c' ging4 ro+tines into se!( cont ined od+!es.nce ro+tine is / c' ged into /roced+re> it c n &e 4c !!ed4 (ro yo+r in

    code> / r eters c n &e / ssed> nd n o/tion ! ? !+e ret+rned to yo+r in code.Bec +se /roced+re cont ins its o;n 4!oc !4 ? ri &!e s/ ce> yo+ c n &e s+re t tnone o( yo+r in or 4g!o& !4 ? ri &!es ;i!! &e c nged &y t e c !!ing o( t e /roced+re.T is (e t+re e ns /roced+res re ?ery /ort &!e> in e((ect t ey c n &e /orted to ot er/rogr s ;it o+t con(!icting ? ri &!e n e ss!es.

    roced+res t t ret+rn res+!t re c !!ed (+nctions in B!it"2> ones t t do not re'no;n s st te ents.

    ,+nctions nd St te ents in B!it"2 ?e t e (o!!o;ing c r cteristicsF

    . t e n+ &er o( / r eters is !i ited to 6

    . gos+&s nd gotos to ! &e!s o+tside /roced+re4s code is strict!y i!!eg !

    . ny ? ri &!es +sed inside /roced+re ;i!! &e initi !i"ed ;it e?ery c !! St te ents

    STATE*ENTSF A /roced+re t t does not ret+rn ? !+e is c !!ed St te ent in B!it"2.

    A e$ /!e o( st te ent ty/e /roced+re ; ic /rints t e ( ctori ! o( n+ &er isFSt te ent ( ct\n]

    X1

    33

  • 8/9/2019 Blitz Basic

    34/247

    ,or 'X2 To nX '

    Ne$tN rint

    End St te ent

    ,or 'X1 To7( ct\']

    Ne$t*o+se9 it

    Use o( c+r!y &r c'ets \ nd ] to &ot de(ine / r eters (or t e /roced+re> nd in c !!ingt e /roced+re. T ese re necess ry e?en i( t e /roced+re re-+ires no / r eters.

    I( yo+ ty/e in t is /rogr > co /i!e nd r+n it> yo+ ;i!! see t t it /rints o+t t e( ctori !s o( t e n+ &ers (ro 1 to 7. =o+ y ?e noticed t t t e ? ri &!e ' s

    &een +sed in &ot t e /roced+re nd t e in code. T is is !!o; &!e &ec +se t e ' int e /roced+re is !oc ! to t e ( ct /roced+re> nd is co /!ete!y se/ r te (ro t e ' int e in /rogr . T e ' in t e in /rogr is 'no;n s g!o& ! ? ri &!e.

    =o+ y +se +/ to si$ ? ri &!es to / ss / r eters to /roced+re. I( yo+ re-+ire oret n t is> e$tr / r eters y &e /! ced in s/eci ! s red g!o& ! ? ri &!es.

    A!so> ? ri &!es +sed to / ss / r eters y on!y &e o( /ri iti?e ty/es> yo+ c nnot/ ss Ne;Ty/e ? ri &!e to /roced+re o;e?er yo+ c n / ss /ointer ty/es.

    ,+nctions

    In B!it"2> yo+ y !so cre te /roced+res ; ic ret+rn ? !+e> 'no;n s (+nctions.T e (o!!o;ing is t e s e ( ct /roced+re i /!e ented s (+nctionF

    ,+nction ( ct\n]X1

    ,or 'X2 To nX '

    Ne$t,+nction Ret+rn

    End ,+nction

    ,or 'X1 To7N rint ( ct\']

    Ne$t*o+se9 it

    Note o; ,+nction Ret+rn is +sed to ret+rn t e res+!t o( t e (+nction. T is is +core +se(+! t n t e /re?io+s ( ctori ! /roced+re> s ;e y +se t e res+!t in ny

    34

  • 8/9/2019 Blitz Basic

    35/247

    e$/ression ;e ; nt. ,or e$ /!eF ( ct '] ( ct\ ]

    A (+nction y ret+rn res+!t o( ny o( t e 6 /ri iti?e ty/es. To in(or /roced+re; t ty/e o( res+!t yo+ re ; nting to ret+rn> t e ty/e descri/tor y &e //ended to,+nction co nd. I( t is is o itted> c+rrent de( +!t ty/e ;i!! &e +sed nor !y .- H.

    T e (o!!o;ing is n e$ /!e o( string (+nctionF

    ,+nction s/c\n],or 'X1 To n

    X V Ne$t

    ,+nction Ret+rn End ,+nction

    rint s/c\20]> ?er %ere

    *o+se9 it

    Rec+rsion

    T e e ory +sed &y /roced+re4s !oc ! ? ri &!es is +ni-+e not on!y to t e ct+ !/roced+re> &+t to e c c !!ing o( t e /roced+re. E c ti e /roced+re is c !!ed ne;&!oc' o( e ory is !!oc ted nd treed on!y ; en t e /roced+re ends.

    T e i /!ic tions o( t is re t t /roced+re y c !! itse!( ;it o+t corr+/tingit4s o;n !oc ! ? ri &!es. T is !!o;s (or / eno enon 'no;n s rec+rsion. %ere is

    not er ?ersion o( t e ( ctori ! /roced+re ; ic +ses rec+rsionF

    ,+nction ( ct\n]I( nM2 T en nXn ( ct\n 1 ],+nction Ret+rn n

    End ,+nction

    ,or nX1 To 7N rint ( ct\n]

    Ne$t*o+se9 it

    T is e$ /!e re!ies on t e conce/t t t t e ( ctori ! o( n+ &er is ct+ !!y t en+ &er +!ti/!ied &y t e ( ctori ! o( one !ess t n t e n+ &er.

    Accessing G!o& ! 8 ri &!es

    35

  • 8/9/2019 Blitz Basic

    36/247

  • 8/9/2019 Blitz Basic

    37/247

    7. BLITZ ERR R C%EC ING AND DEBUGGING

    Co /i!e Ti e Errors

    B!it"2 re/orts t;o ty/es o( errors. Co /i!e ti e errors re t ose (o+nd ; en B!it"tte /ts to co /i!e yo+r code> r+nti e errors occ+r ; en /rogr is &eing e$ec+ted.

    T e (irst ty/e> co /i!e ti e errors> c +se ess ge to //e r on t e editor screen.9 en is se!ected yo+ re ret+rned to t e o((ending !ine o( code in yo+r /rogr .

    A//endi$ 2 o( t e B!it"2 Re(erence * n+ ! cont ins descri/tion o( !! t e /ossi&!eerrors t co /i!e ti e. T e (o!!o;ing !ist re/e ts so e B!it"2 r+!es t t ?e to &e

    &ided &y (or yo+r /rogr to &e s+ccess(+!!y co /i!edF

    1. Any B!it" (+nctions co nds t t ret+rn ? !+eH +st ?e t eir / r eters inside &r c'etsF

    I( Re d,i!e 0> r Ftest H

    2. B!it" co nds t t re not (+nctions +st not ?e t eir / r eter in &r c'etsF

    Bit* / 0>320>276>3

    3. Using .ty/e s+((i$ ; en re(erring to ite s in Ne;Ty/e ;i!! c +se g r& ge tend o( !ine errorF

    /erson n e X % rry J dro/ t e H

    5. A n+ eric ? ri &!e c n on!y &e one .ty/e> *is* tc ed Ty/e error ;i!! occ+r i( yo+tte /t to +se di((erent .ty/e s+((i$ (+rt er do;n t e /rogr ;it t e s e ? ri &!e

    n e ;it t e e$ce/tion o( string ? ri &!esH.

    ( co+rse t ere re ny +ndreds o( ist 'es t t c n c +se yo+r /rogr to ( i! toco /i!e> ost ;i!! re-+ire -+ic' !oo' in t e B!it"2 Re( * n+ ! to c ec' synt $o( co nd nd y&e cross re(erence yo+r code ;it one o( t e e$ /!es.

    Don4t (orget t e %e!/ 'ey to -+ic'!y c ec' t e synt $ o( co nd.

    T e CERR Directi?e

    9 en +sing cros nd condition ! co /i!ing yo+ y ;is to gener te yo+r o;nco /i!e ti e errors.T e CERR directi?e is +sed to gener te +ser de(ined co /i!e ti e errors. ,o!!o;ing ;i!!

    !t t e co /i!er nd gener te ess ge S o+!d % ?e 3 r eters F

    37

  • 8/9/2019 Blitz Basic

    38/247

    CERR S o+!d % ?e 3 r eters

    See condition ! co /i!ing in C /ter : (or ore in(or tion on CERR.

    R+nti e Errors

    Errors t t occ+r ; i!e yo+r /rogr is e$ec+ting re c !!ed r+nti e errors. 9 ende?e!o/ing /rogr s in B!it"> t e R+nti e Error De&+gger s o+!d !; ys &e en &!ed ont e Co /i!er /tions. I( itKs not nd n error occ+rs t e syste ;i!! cr s .

    I( yo+ need to r+n yo+r /rogr ;it o+t r+nti e errors en &!ed (or s/eed /+r/oses SetErr directi?e s o+!d &e inc!+ded to sto/ t e syste cr s ing> t e syste ;i!! t en

    + / to t e code !isted (ter t e SetErr.

    T e (o!!o;ing !ine inc!+ded t t e to/ o( yo+r /rogr is s+ggestedF

    SetErrFEndFEnd SetErr

    Any /rogr s t t +se (i!e nd!ing s o+!d !; ys inc!+de so e sort o( error tr //ingto nd!e sit+ tions ; ere /rogr c nnot !oc te (i!e> or t e (i!e itKs ;rong ty/e.

    Any o/er ting syste & sed so(t; re s o+!d !so !; ys inc!+de error c ec'ing sScreens nd 9indo;s y ( i! to o/en d+e to !o; e ory.

    =o+ y !so set+/ n error nd!er +st (or one section o( code. T e SetErr..error nd!er..End SetErr s o+!d &e t t e st rt o( t e section nd C!rErr t t e end.

    T e (o!!o;ing ;i!! (! s t e screen nd end i( Lo dS /es ( i!sF

    SetErr Dis/! yBee/[ 0End

    End SetErr

    Lo dS /es 0> (i!en e

    C!rErr

    T e B!it" De&+gger

    I( r+nti e error occ+rs ; en /rogr is r+n (ro editor t e B!it"2 de&+gger ;i!! &ecti? ted. R+nti eErrors +st !so &e en &!e in t e co /i!er o/tions re-+ester.

    T e de&+gger ;i!! not &e cti? ted i( t ere is n error nd!er !re dy

    38

  • 8/9/2019 Blitz Basic

    39/247

    en &!ed in t e /rogr +sing t e SetErr co nd.

    T e de&+gger c n !so &e cti? ted &y +sing t e CTRL ALT C 'eys> c!ic'ing on t eBR g dget o( t e de&+gger ;indo; or inc!+ding ST co nd in yo+r /rogr .

    T e de&+gger is /o;er(+! too! in (inding o+t c +ses o( errors nd !oc ting &+gs. T e&i!ity to ste/ & c' t ro+g code e$ec+ted /rior to t e &re ' gi?es t e /rogr r er ne$ce!!ent +nderst nding o( o; n error s occ+rred. T e (o!!;ing is screens ot o(t e de&+gger (ter t e /rogr enco+ntered ST co nd.

    Note> &y 'ing t e de&+gger ;indo; ! rger ore o( t e /rogr c n &e ?ie;ed.

    T e De&+gger G dgets

    T e (o!!o;ing is descri/tion o( t e de&+gger g dgetsF

    BR C!ic' on t is to sto/ /rogr r+nning nd en &!e t e B!it" de&+gger.

    ST Use t is to sto/ /rogr d+ring Tr ce ode.

    S S'i/ c +ses t e de&+gger to s'i/ co nd> /rogr e$ec+tion ;i!! contin+e (ro t e ne$t co nd ; en t en RUN.

    TRC Tr ce ode !!o;s t e /rogr er to sing!e ste/ t ro+g t eir code> &y incre sing t e si"e o( t e de&+gger ;indo; /rogr (!o; c n &e ?ie;ed.

    RUN C +ses /rogr e$ec+tion to res+ e (ter &eing sto//ed.

    8ie; /re?io+s co nd istory !!o;s t e /rogr er to re?ie; t e co nds t t ;ere e$ec+ted /rior to t e /rogr &eing sto//ed.

    MM 8ie; (or; rd !!o;s t e +ser to (or; rd t ro+g t e co nd istory (ter +sing t e ?ie; /re?io+s g dget.

    E C E$ec+te !!o;s t e /rogr er to n+ !!y enter B!it" co nd to &e e$ec+ted &y t e de&+gger.

    E8L E? !+ te !!o;s t e /rogr er to ?ie; ny ? ri &!e si /!y &y enteringit4s n e (ter c!ic'ing on E8L.

    Tr cing /rogr e$ec+tion

    T e de&+gger !!o;s t e +ser to sing!e ste/ t ro+g or tr ce /rogr e$ec+tion>dis/! ying in it4s ;indo; ; ic co nd is c+rrent!y &eing e$ec+ted.

    39

  • 8/9/2019 Blitz Basic

    40/247

    Ste/ is +sed to sing!e ste/ t ro+g yo+r /rogr > e c ti e yo+ c!ic' onST t e de&+gger ;i!! e$ec+te t e co nd /ointed to &y t e rro; nd sto/.Tr ce ste/s contin+o+s!y t ro+g t e code dis/! ying e c co nd s itgoes. To sto/ t e Tr ce +se t e ST g dget.

    Le?e! is +sed to c nge t e tr ce !e?e!> i( Le?e! is N> t e de&+gger ;i!! not tr ce orsing!e ste/ t ro+g t e inside ,or..Ne$t !oo/s &+t e$ec+te nor !!y +nti! !oo/ e$its.

    It ;i!! !so not tr ce t e e$ec+tion o( ny /roced+res or s+&ro+tines c !!ed> t is is ost+se(+! (or ; tc ing t e /rogr 4s in !oo/ ; i!e not ?ing to sit t ro+g t e tr ce o(e c s+&ro+tine ; en c !!ed.

    Res+ ing Nor ! E$ec+tion

    rogr e$ec+tion ret+rn nor !!y (ter de&+gger is cti? ted +sing R+n g dget.

    I( de&+gger ; s cti? ted +sing ST co nd t e rro; ;i!! &e /ointing to ST >&e(ore contin+ing t e co nd +st &e s'i//ed o?er +sing Ignore co nd. T is istr+e (or ny co nd t t s c +sed R+nTi e error nd in?o'ed t e de&+gger.

    To ret+rn to t e editor (ro t e de&+gger eit er it t e Esc /e 'ey or c!ic' on t e c!ose;indo; g dget o( t e de&+gger 9indo;.

    8ie;ing co nd istory

    T e de&+gger 'ee/s record o( t e co nds e$ec+ted &e(ore t e /rogr issto//ed in ! rge &+((er.

    T e B c' +/ co nd ;i!! ste/ & c'; rds (ro ; ere t e /rogr !ted>!!o;ing t e /rogr er to ?ie; t e /re?io+s co nds e$ec+ted &y t e

    co /+ter. A o!!o; rro; r's t e c+rrent /osition in t e istory &+((er.

    ,or; rd co nd is +sed to ste/ (or; rds t ro+g t e istory &+((er> tte /ting toste/ / st ; ere t e /rogr ; s sto//ed ;i!! /rod+ce AT END , BU,,ER error.

    T ese (e t+res re in? !+ &!e to (o!!o;ing t ro+g /rogr e$ec+tion +/ to ; ere t e/rogr ; s !ted. I( /rogr !ted in t e idd!e o( s+&ro+tine or

    /roced+re yo+ c n ste/ & c'; rds to (ind ; ere t e ro+tine ; s c !!ed (ro .

    Direct *ode

    9 i!e t e de&+gger is cti? ted t e /rogr er s t;o too!s ? i! &!e to e$ ine t eintern ! st te o( t e /rogr .To (ind o+t t e ? !+e o( ny ? ri &!es t e E8 L+ te co nd c n &e +sed. A /ro /t;i!! //e r> (ter ty/ing t e n e o( t e ? ri &!e nd itting ret+rn t e ? !+e ;i!! &e

    40

  • 8/9/2019 Blitz Basic

    41/247

    /rinted on t e de&+gger dis/! y.

    T e E eC+te co nd is +sed to r+n B!it"2 co nd. A /ro /t ;i!! //e r nd t e /rogr er c n t en ty/e in ny B!it"2 co nd s+c s CLS or nX2 H.

    De&+gger Errors

    ,o!!o;ing errors y occ+r ; en +sing direct ode co nds E? !+ te @ e ec+teF

    C n4t Cre te in Direct *ode

    cc+rs i( yo+ try nd E? !+ te non e$istent ? ri &!e not cre tedH in t e /rogr .

    Li&r ry Not A? i! &!e in Direct *ode

    cc+rs ; en B!it"2 co nd is e$ec+ted nd is (ro co nd !i&r ry not +sed &y

    t e /rogr . I( t e /rogr doesnKt +se strings (or inst nce> t e string co nd!i&r ry ;i!! not &e / rt o( t e o& ect code nd so ny string ty/e co nds ;i!! not &e

    &!e to &e e$ec+ted.

    Not Eno+g Roo in Direct *ode B+((er

    T is error s o+!d ne?er occ+r. i( it does t e o& ect &+tter si"e in t e Co /i!er /tionsre-+ester s o+!d &e incre sed.

    AT END , BU,,ER

    cc+rs i( t e /rogr er tries to ?ie; ,or; rd o( ; ere t e /rogr sto//ed.

    6. BLITZ B

  • 8/9/2019 Blitz Basic

    42/247

    ,i!es (or se-+enti ! nd r ndo ccess D S (i!e nd!ing*od+!es so+ndtr c'er co / ti&!e +sic o& ectsB!it"(onts )$) (onts (or ( st Bit* / te$t o+t/+tInt+i,onts ny si"e (onts (or 9indo; te$t o+t/+tS /es st nd rd B!it"2 gr / ics e!e ent

    !ettes co!o+r / !ette str+ct+reBit* /s st nd rd B!it"2 dis/! y e!e entSo+nds digitised so+nd s /!e e!e entS/rites B!it" ode rd; re s/rite e!e entScreens st nd rd Int+ition ty/e screens9indo;s st nd rd In+ition ty/e ;indo;sG dgets st nd rd Int+ition ty/e g dgets*en+s st nd rd Int+ition ty/e en+s

    & ect Si i! rities

    B!it"2 o& ects !! ?e set o( co nds !!o;ing t e /rogr to cre te or de(inet e > ni/+! te nd o( co+rse destroy t e .

    *ost o& ects ?e c /ter in t e B!it"2 re(erence n+ ! de?oted to t e > o+t!ining!! t e s/eci ! co nds +sed to cre te nd ni/+! te t e o& ect.

    A!! B!it"2 o& ects c n &e destroyed +sing t e ,ree co nd. I( n o& ect s not &eendestroyed ; en /rogr ends> B!it"2 ;i!! +to tic !!y ,ree t t o& ect.

    ,ree Bit* / 0 ;i!! (ree +/ !! e ory !!oc ted (or o& ect Bit* / 0> t is is +se(+! ; en+sing o& ects te /or ri!y nd ;i!! need e ory ! ter in t e /rogr > ot er;ise itKs+s+ ! to !et B!it" (ree +/ !! o& ects +to tic !!y ; en /rogr ends.

    & ect * $i + s

    E c o& ect s its o;n $i + . t is n+ &er de(ines o; ny o( one ty/e o( o& ect c n &e cre ted nd ni/+! ted &y t e /rogr . T e $i + c n &ec nged (or e c o& ect in t e Co /i!er /tions ;indo; o( t e editor.

    T e r+nti e error 8 !+e +t ( * $i + R nge e ns yo+ ?e tried to +se no& ect n+ &er gre ter t n t t set in t e $i + s ;indo; o( Co /i!er /tions.

    Using n & ect

    * ny co nds need /re?io+s!y cre ted o& ects /resent to o/er te /ro/er!y.,or e$ /!e> t e B!it co nd> ; ic is +sed to /! ce s /e onto &it /> needs&ot /re?io+s!y cre ted s /e o& ect nd &it / o& ect.

    9 en yo+ +se t e B!it co nd> yo+ s/eci(y t e s /e o& ect to &e &!itted nd B!it";i!! &!it t t s /e onto t e c+rrent!y +sed &it /.

    42

  • 8/9/2019 Blitz Basic

    43/247

    Use Bit* / 0 J 'e &it / t e c+rrent!y +sed &it /B!it 3>10>10 J&!it s /e 3 onto c+rrent!y +sed &it /

    T e Use co nd in t e /re?io+s e$ /!e 'es Bit* / 0 t e c+rrent!y +sed

    &it /. Screens> 9indo;s nd !ettes re t ree ot er B!it"2 o& ects t t o(ten needto &e c+rrent!y +sed> (or co nds to ;or' /ro/er!y.

    Note> ; en n o& ect is cre ted> it &eco es t e c+rrent!y +sed o& ect o( it4s c! ss.

    B!it"2 'es e$tensi?e +se o( t is c+rrent!y o& ect ide . It4s d? nt ges inc!+de ( ster/rogr e$ec+tion> !ess co /!e$ co nds> nd gre ter /rogr od+! rity.

    In/+t +/+t & ects

    Bit* /> ,i!e nd 9indo; o& ects c n !! o/er te s I de?ices. & ectIn/+t nd

    & ect +t/+t co nds !!o; +ser to c nne! in/+t nd o+t/+t to di((erent /! ces.

    T e rint co nd ;i!! !; ys ;rite to t e c+rrent o+t/+t o& ect> edit nd in'ey ;i!!!; ys tte /t to re d (ro t e c+rrent in/+t o& ect.

    9indo; +t/+t 2 J;indo; 2 is t e c+rrent o+t/+t o& ectrint %ELL

    Bit* /In/+t 1 J 'e &it / 1 t e c+rrent in/+t o& ectXEdit )0H

    & ect str+ct+res (or d? nced +sersH

    A//endi$ 1 o( t e B!it"2 re(erence n+ ! cont ins descri/tions o( e c o( t e B!it"2o& ect4s str+ct+res. T e Addr co nd is +sed to (ind t e !oc tion in e ory o( / rtic+! r o& ects str+ct+re.

    Ad? nced +sers c n +se t e Addr co nd ;it /ee' @ /o'e nd in!ine sse &!erro+tines to ccess i /ort nt ? !+es in n o& ect4s str+ct+re. T is is o(ten e!/(+! ;itsyste ty/e o& ects s+c s Screens nd 9indo;s t t cont in /ointers to t eirInt+ition co+nter/ rts.

    T e (o!!o;ing c !!s t e syste co nd ScreenTo,ront[ o&t ining t e !oc tiono( t e In+ition Screen str+ct+re (ro t e B!it"2 Screen o& ect in e ory.

    ScreenTo,ront[ ee'.! Addr Screen 0HH

    Ne$t !isting i!!+str tes o&t ining 9indo;4s syste str+ct+re nd ssigning it to /ointer ty/e .9indo;. A ig Li&s.Res s o+!d &e resident &e(ore r+n t is e$ /!e.

    43

  • 8/9/2019 Blitz Basic

    44/247

    ,indScreen 09indo; 0>10>10>100>100>:> SIZE *E >1>2

    ;.9indo;X ee'.! Addr 9indo; 0HH9indo; +t/+t 0Re/e t

    e?.!X9 itE?ent9Loc te 0>0N rint ; 9idtN rint ; %eig t

    Unti! e?X 200

    NoteF t e Ne;Ty/e.9indo; re(ers to t e syste Int+itionH ;indo; str+ct+re; ere s t e Ne;Ty/e .;indo; re(ers to t e B!it"2 ;indo; str+ct+re.

    ?er?ie; o( t e /ri ry B!it"2 & ects

    Screens

    Screens re cre ted +sing Screen nd ,indScreen co nds. 1st ;i!! o/en ne;screen ; i!e 2nd ;i!! 'e n e$isting Screen +s+ !!y 9B screenH B!it"2 Screen.

    ,ree Screen n s o+!d on!y &e tte /ted (ter ny 9indo;s o/en on t e Screen rec!osed (reedH (irst.

    Screen o& ects &ot con(ig+re t e reso!+tion o( t e dis/! y nd its / !ette s ;e!! s&eing t e /! ce ; ere 9indo;s re o/ened. Any 9indo;s o/ened> RGB or Use !etteco nds ;i!! +se t e c+rrent!y +sed screen.

    T e (+nction ee'.! ddr Screen nHH c n &e +sed to o&t in t e !oc tion o( t e syste.Screen str+ct+re ; en c !!ing syste ro+tines.

    9indo;s

    9indo;s re cre ted ;it t e 9indo; co nd. G dgets nd en+s re !; ysdded to t e c+rrent!y +sed ;indo; ; i!e t e dr ;ing co nds 9 !ot> 9Circ!e>

    9Line nd 9Bo$ !! render to t e c+rrent!y +sed 9indo;.

    9indo; o& ects c n &e +sed (or in/+t o+t/+t +sing 9indo;In/+t nd 9indo; +/+tco nds. T e c+rsor /osition (or in o+t c n &e contro!!ed ;it 9Loc te co nd.

    9indo;s c n &e (reed ;it o+t ;orry o( (reeing ny tt c ed g dget or en+!ists.

    G dget nd *en+ !ists

    44

  • 8/9/2019 Blitz Basic

    45/247

    G dgets nd en+s +st &e gro+/ed toget er in B!it" o& ects 'no;n s. yesyo+ g+essed it> g dget!ists nd en+!ists. T ese !ists re tt c ed to 9indo; ; ent e ;indo; is (irst cre ted o/enedH. T is e ns t t g dgets nd en+s s o+!d !! &e/re de(ined in t eir !ists t t e st rt o( t e /rogr .

    !ettes

    A / !ette o& ect cont ins RGB in(or tion (or e c o( t e co!o+rs in dis/! y.!ettes re !itt!e di((erent to reg+! r B!it" o& ects in t e (o!!o;ing ; ys.

    Use !ette ;i!! set t e c+rrent screen or s!ice to t e co!o+rs in t e / !ette.

    T e RGB co nd s ;e!! s t e Red H> Green H nd B!+e H (+nctions //!y tot e co!o+rs in t e c+rrent S!ice or Screen N T in t e c+rrent / !ette.

    T ere is no cre te / !ette co nd> t ey re eit er cre ted ; en !o ded (ro n I,,

    (i!e or ; en +sing !RGB> i( no / !ette o& ect e$ists ;it eit er co nd B!it"2 ;i!!cre te one.

    Bit* /s

    A &it / re(ers to t e rr y o( /i$e!s t t 'e +/ t e dis/! y. A &it / c n eit er &ecre ted ;it t e Bit* / co nd> !o ded (ro dis' or (etc ed (ro Screen +sing t eScreensBit* / co nd.

    A Bit / co nd c n &e (reed +sing t e ,ree Bit* / n co nd> yo+ c n not(ree &it /s cre ted ;it t e ScreensBit* / co nd.

    As ;it ;indo;s> &it /s c n &e +sed s in/+t o+t/+t de?ices ;it Bit* /In/+t ndBit* / +t/+t co nds. T ese re +sed /ri ri!y in B!it"*ode.

    In B!it"*ode t e 'ey&o rd s o+!d &e en &!ed ;it B!it" eys n &e(orette /ting to +se Bit* /In/+t.

    9 en +sing Bit* / +t/+t t e Loc te co nd c n &e +sed to /osition t e c+rsor.

    S /es

    S /es re +sed to cont in gr / ic i ges. T ey c n &e initi !i"ed &y eit er !o dingt e (ro dis' or &eing c!i//ed (ro &it / o& ect +sing GetAS /e co nd.

    S /es re (reed +sing st nd rd ,ree S /e n synt $. S /es s o+!d not &e (reed i(t ey re +sed ;it g dgets or en+ ite s +nti! re!e? nt g dget or en+!ist is (reed 1st.

    T ere re ny /o;er(+! co nds in B!it"2 to ni/+! te s /es inc!+ding rot tion

    45

  • 8/9/2019 Blitz Basic

    46/247

    nd sc !ing.

    S/rites

    S/rites re initi !i"ed &y eit er !o ding t e (ro dis' or con?erting s /e o& ect to

    s/rite o& ect +sing Get S/rite. T e s /e o& ect c n &e (reed once it s &eencon?erted to s/rite.

    ,ree S/rite n ;i!! (ree s/rite

    S/rites c n c+rrent!y on!y &e +sed in B!it" ode o;e?er in A ig ode> t e /ointerc n &e ssigned to sing!e s/rite o& ect.

    S!ices

    A s!ice is +sed to con(ig+re dis/! y in B!it" ode. T ey re initi !i"ed ;it S!iceco nd.

    Un!i'e ot er o& ects> sing!e s!ices c nnot &e (reed. ,reeS!ices is +sed to (ree !! s!icesc+rrent!y initi !ised.

    T e co nds S o;> S o;,> S o;B nd S o;S/rite !! +se t e c+rrent!y +se s!ice.T e RGB co nd !so ((ects t e co!o+r registers in t e c+rrent!y +sed s!ice s doest e Use !ette co nd.

    ,i!es

    Un!i'e ot er B!it" o& ects (i!es re o/ened nd c!osed r t er t n initi !i"ed @ 'i!!ed.

    ,i!es re initi !ised ;it /en,i!e H> Re d,i!e H nd 9rite,i!e H (+nctions. Un!i'e ot erB!it" o& ects (+nction is +sed so t e /rogr c n te!! i( (i!e ; s ;e!! o/ened.

    C!ose,i!e n co nd is +sed to 4(ree4 (i!e o& ect. T e co nd ,ree ,i!e n y !so&e +sed> +n!i'e ot er o& ects it is &est to c!ose !! (i!es yo+rse!( r t er t n re!y onB!it"2 to c!ose t e ; en t e /rogr e$its.

    A (i!e is o( co+rse n in/+t o+t/+t o& ect> t e co nds ,i!eIn/+t nd ,i!e +t/+t re

    +sed to direct in/+t nd o+t/+t to (i!es.

    Get> +t> Re d*e nd 9rite*e re-+ire (i!eW / r eters nd so do not re-+ire t e+se o( ,i!eIn/+t nd ,i!e +t/+t co nds.

    & ects S+ ry

    46

  • 8/9/2019 Blitz Basic

    47/247

    B!it"24s o& ects re c+sto d t str+ct+res +sed &y t e !i&r ries to nd!e ; o!essort ent o( entities. B!it"2 n ges t e e ory re-+ired &y t ese str+ct+res>

    (reeing t e +to tic !!y ; en /rogr ends.

    T ey /ro?ide si /!e inter( ce to ny o( t e ore co /!e$ B!it"2 co nds.

    r eter / ssing is ini ised s ny o( t e B!it"2 co nds t 'ed? nt ge o( t e c+rrent!y +sed o& ect.

    As !i&r ries re +/gr ded nd dded to B!it"2> ore o& ects ;i!! &e ddednd ?ers ti!ity nd (+nction !ity o( e$isting o& ects ;i!! &e incre sed.

    #. BLITZ * DE

    A!t o+g t e A ig 4s o/er ting syste is ?ery /o;er(+!> it4s &i!ity to t 'e (+!!d? nt ge o( t e gr / ics c / city o( t e c ine is !i ited. B!it" ode is (or

    /rogr ers ; nting to /rod+ce s oot ni ted gr / ics (or g es nd t e !i'e.

    T e co nd B!it" /+ts yo+r /rogr in B!it" ode. 9 en t is //ens t eo/er ting syste is dis &!ed nd yo+r /rogr t 'es o?er t e ; o!e c ine.T is e ns t t it ;i!! not +!ti t s' nd (i!e ccess is no !onger /ossi&!e.

    T e &ene(its o( B!it" ode re t t /rogr s r+n !ot -+ic'er nd dis/! yo/tions s+c s s oot scro!!ing nd d+ ! /! y(ie!d re /ossi&!e.B!it" ode is not /er nent st te> ; en yo+r /rogr re enters A ig odeor e$its> t e o/er ting syste is &ro+g t & c' to !i(e s t o+g not ing //ened.

    C re(+! ttention +st &e / yed reg rding entering B!it" ode> ?ersion 1.3nd o!der o( t e o/er ting syste c n t 'e +/ to 2 seconds to (!+s ny &+((ers (ter

    (i!e is c!osed. =o+ s o+!d !; ys ens+re t t &so!+te!y no dis' or (i!e ccess is t 'ing/! ce &e(ore entering B!it" ode. At t e ti e o( t is ;riting> no so(t; re et od o(

    c ie?ing t is s yet &een disco?ered. T e &est ;e c n s+ggest is t t 89AIT 100 s o+!d !; ys &e e$ec+ted &e(ore +sing B!it" ode.

    S!ice * gic

    T e designers o( t e A ig rd; re ?e i /!e ented ny (e t+res (or c ei?ings oot > ( st gr / ics. A(ter entering B!it" ode t e dis/! y is contro!!ed +sing S!ices.

    S!ices re +c ore (!e$i&!e t n t e o/er ting syste 4s Screens> t ey !!o; (e t+ress+c s s oot scro!!ing> do+&!e &+((ered dis/! ys nd +c ore.

    T e &i!ity to ?e ore t n one s!ice e ns t t t e dis/! y c n &e s/!it intodi((erent regions e c ;it t eir o;n reso!+tion.T e (o!!o;ing is descri/tion o( t e in dis/! y (e t+res ccessi&!e ;it s!icesF

    S oot Scro!!ing

    47

  • 8/9/2019 Blitz Basic

    48/247

    S oot scro!!ing is c ei?ed &y dis/! ying on!y /ortion o( ! rge &it /. T e A igrd; re en &!es +s to o?e t e dis/! y ;indo; ro+nd t e inside o(

    ! rge &it / s t e (o!!o;ing di gr s o;sF

    T e dis/! y ;indo; re/resents ; t is s o;n on t e onitor> s ;e o?e t e

    dis/! y ;indo; cross t e &it / to t e rig t t e i ge ;e see on t e screen scro!!ss oot !y to t e !e(t.

    T e B!it" co nds S o;> S o;, nd S o;B !!o; +s to set t e /osition o( t edis/! y ;indo; inside t e &it /.

    T e &o?e di gr !i its t e o+nt ;e c n scro!! to t e si"e o( t e &it /. Byd+/!ic ting t e !e(t /ortion o( t e &it / on t e rig t ;e c n s oot !y scro!! dis/! y

    cross> ; en it re c es t e rig t> reset it & c' to t e ( r !e(t. As t ere is no c nge; en t e dis/! y is reset to t e !e(t t e i!!+sion o( contin+o+s scro!!ing is cre ted.

    T e &o?e !e(t rig t scen rio !so //!ys to ?ertic ! scro!!ing +/ nd do;nH.

    D+ ! ! y(ie!d

    In so e sit+ tions> t e dis/! y ;i!! &e de +/ o( & c'gro+nd nd (oregro+nd.A ig s t e &i!ity to dis/! y one &it / on to/ o( t e ot er c !!ed d+ ! /! y(ie!d

    ode to c ie?e t is e((ect.

    In d+ ! /! y(ie!d dis/! y> t;o ) co!o+r &it /s c n &e dis/! yed> one in(ront o( t eot er> ny /i$e!s set to co!o+r "ero in t e (ront /! y(ie!d ;i!! &e tr ns/ rent !ettingt e & c' /! y(ie!d s o; t ro+g . E c /! y(ie!d c n ?e its o;n co!o+rs.

    Co//er Contro!

    S oot ni tion is c ei?ed &y o?ing gr / ics in sync ;it t e ?ideo dis/! y. T edis/! y is cre ted &y ?ideo &e t t redr ;s t e screen !ine &y !ine e?ery 70t o( second. (ten> itKs +se(+! to sync t ings to ?ertic ! /osition o( t e ?ertic ! &e . T is is

    c ei?ed +sing t e A ig gr / ics co /rocessor 'no;n s t e Co//er.

    B!it"2 o((ers se?er ! ; ys o( t 'ing d? nt ge o( t e co//er rd; re. T e ost/o/+! r is to c nge t e co!o+r o( t e & c'gro+nd co!o+r to /rod+ce r in&o; ty/ee((ects on t e dis/! y. T is is c ei?ed +sing t e Co!S/!it co nd.

    T ose ;it good 'no;!edge o( A ig rd; re y ;is to /rogr co//er to 'eot er c nges t di((erent ?ertic ! /! ces> t is c n &e c ei?ed +sing C+sto Co/.

    T e B!itter

    48

  • 8/9/2019 Blitz Basic

    49/247

    A ig s c+sto rd; re s/eci(ic !!y to tr ns(er gr / ic i ges onto &it /s'no;n s t e g!itter. B!it"2 o((ers se?er ! ; ys o( &!itting s /es onto &it / nd s/eci ! Scro!! co nd to s i(t re s o( &it / ro+nd +sing t e &!ister.

    ,o!!o;ing is &rie( o?er?ie; o( t e ? rio+s &!ister & sed co nds in B!it"2F

    B!it +sed to /+t s /es onto &it /s.

    B!it s e s B!it &+t B!it"2 re e &ers ; ere t e s /e ; s /+t nd ;i!! er se it ; en it is ti e to o?e t e s /e so e; ere e!se on t e &it /.

    BB!it s e s B!it &+t ; en it is ti e to o?e t e s /e> inste d o( er sing t e s /e> B!it"2 re/! ces ; t ; s on t e &it / /re?io+s to t e BB!it.

    SB!it s es s B!it &+t ;it stenci! (e t+re ; ic /rotects cert in re s o( t e &it / (ro &eing &!itted on.

    B!oc' ( st ?ersion o( B!it t t ;or's on!y ;it rect ng+! r s /es +!ti/!e o( 16 /i$e!s ;ide.

    C!i/B!it S!o; ?ersion o( B!it ; ic ;i!! c!i/ t e s /e to (it inside t e &i /.

    Scro!! +sed to co/y sections o( &it / (ro one /osition to not er.

    A ig *ode

    It is !so /ossi&!e to + / o+t o( B!it" ode nd & c' into A ig ode.T is c n done +sing eit er t e A ig or A ig st te ent.

    Using A ig to go & c' into A ig ode ;i!! (+!!y ret+rn yo+ to t e A ig 4snor ! dis/! y> co /!ete ;it o+se /ointer.

    Using A ig ;i!! ret+rn yo+ to A ig ode> &+t ;i!! not ((ect t e dis/! y t !!. T is!!o;s B!it" ode /rogr s to + / into A ig ode (or o/er tions s+c s (i!e I >

    t en + / & c' to B!it" ode ;it o+t ?ing to destroy B!it" ode dis/! y.

    An I /ort nt note

    =o+ s o+!d !; ys ens+re t t &so!+te!y no dis' or (i!e ccess is t 'ing /! ce &e(oreentering B!it" ode. At t e ti e o( t is ;riting> no so(t; re et od o( c ie?ing t iss yet &een disco?ered.

    By (o!!o;ing t ese g+ide!ines +sing B!it" ode s o+!d &e /retty s (eF

    . A!; ys ; it (or t e (!o//y dri?e !ig t to go o+t i( yo+ ?e s ?ed so e so+rce code&e(ore Co /i!ing R+nning /rogr ; ic ! +nces str ig t into B!it" ode.

    49

  • 8/9/2019 Blitz Basic

    50/247

    . A7:0 % rd dri?e +sers !; ys ; it (or t e second &!in' o( t e dri?e !ig t; en +sing 9or'&enc 1.3> 2.0 +sers ?e t ere &+((ers (!+s ed in one go.

    . I( yo+ +se t e A ig st te ent (or t e /+r/ose o( ;riting d t to dis'> it4s good

    ide to e$ec+te de! y &e(ore go & c' to B!it" ode In e((ect> si +! ting &o?e.E$ec+ting 89 it 270 ;i!! /ro?ide de! y o( &o+t 7 seconds s (e de! y to +se.A(ter re ding d t +se 89 it 70. Anot er i /ort nt t ing to re e &er &o+t B!it"

    ode is t t ny co nds re-+iring t e /resence o( t e S &eco e +n ? i! &!e; i!e yo+4re in B!it" ode. I( yo+ tte /t to o/en 9indo; in B!it" ode> yo+ ;i!! &egreeted ;it n 4 n!y ? i! &!e in A ig *ode4 error t co /i!e ti e. ,or t is re son>t e Re(erence G+ide c!e r!y st tes ; ic co nds re ? i! &!e in ; ic ode.

    T e B!it"> A ig > nd A ig st te ents re !! co /i!er directi?es. T is e ns t ey+st //e r in //!ic &!e order in yo+r so+rce code.

    S+ ry

    B!it"2 /ro?ides t;o en?iron ents (or yo+r /rogr s to e$ec+te in. A ig odes o+!d &e +sed (or ny //!ic tions so(t; re nd ; ene?er yo+r g e needsto !o d d t (ro dis'. B!it" ode is (or /rogr s t t need to t 'e d? nt ge o( t es/eci ! dis/! y odes ;e ?e /ro?ided in B!it"2. T ese /ro?ide /er(or nce t t is

    +st not ? i! &!e in A ig ode &+t ;i!! !t t e A ig 4s o/er ting syste .

    To conc!+de> t e on!y ti e it is cce/t &!e to c!ose do;n t e A ig 4s +!ti t s'ingen?iron ent is ; en t e so(t; re is dedic ted to entert in ent. Any //!ic tionsso(t; re t t +ses B!it" ode ;i!! N T &e ;e!co ed &y t e A ig co +nity.

    ). AD8ANCED T ICS

    Resident ,i!es

    To 'e ;riting /rogr s ; ic ni/+! te ! rge n+ &er o( Ne;Ty/es> crosor const nts e sier> B!it"2 inc!+des (e t+re 'no;n s resir!ent(i!es.

    A resident (i!e cont ins /re co /i!ed !ist o( Ne;Ty/es> cros nd const nts. By

    cre ting resident (i!es> !! t ese de(initions c n &e dro//ed (ro t e in code 'ingit s !!er nd t ster to co /i!e.

    To cre te resident (i!e yo+ ;i!! need /rogr ; ic cont ins !! t e Ne;Ty/es.cros nd const nts yo+ ; nt to con?ert to resident (i!e (or t.

    T e (o!!o;ing is n e$ /!e o( s+c /rogr F

    NE9T= E.test

    50

  • 8/9/2019 Blitz Basic

    51/247

    .!&.;

    End NE9T= E

    * cro c

    N rint %e!!oEnd * cro

    $constX 10

    To con?ert t ese de(initions to resident (i!e> !! yo+ need to do is C * ILE@RUN t e/rogr > t en se!ect CREATE RESIDENT (ro t e C * ILER en+. At t is /oint> yo+;i!! &e /resented ;it (i!e re-+ester into ; ic yo+ enter t e n e o( t e resident(i!e yo+ ;is to cre te. T t4s !! t ere is to cre ting resident (i!e

    nce cre ted> resident (i!e y &e inst !!ed in ny /rogr si /!y &y entering t e

    n e o( t e resident (i!e into one o( t e 4RESIDENT4 (ie!ds o( t e co /i!er o/tionsre-+ester. nce t is is done> !! Ne;Ty/e> cro nd const nt de(initions cont ined int e resident (i!e ;i!! +to tic !!y &e ? i! &!e.

    Resident (i!e A*IGALIBS.RES cont ins !! t e str+ct+res> const nts nd crosssoci ted ;it t e A ig S. T ose ( i!i r ;it /rogr ing t e S ;i!! not ?e to

    inc!+de !! t e +s+ ! !i&r ry e der (i!es nd ;i!! s ?e in+tes e?ery co /i!e ti e.

    /er ting Syste C !!s

    *+c e((ort s &een de to !et t e B!it"2 /rogr er 'e t e ost o( t eA ig 4s /o;er(+! o/er ting syste .

    C !!ing /er ting Syste Li&r ries

    (ten t e /rogr er ;it good 'no;!edge o( t e S ;i!! ; nt to ccess ro+tinest t ?e not &een s+//orted &y t e 4intern !4 B!it"2 co nd set. A!! ro+tines in t eE$ec> Int+ition> D S nd Gr / ics !i&r ries re ccessi&!e (ro B!it"2 see //endi$ 7in B!it"2 Re(erence * n+ !H.

    S+//ort (or ot er A ig st nd rd !i&r ries is ? i! &!e &y /+rc sing t e

    B!it"2 d? nced /rogr ers / c' (ro Acid So(t; re.

    ,o!!o;ing is e$ /!e o( c !! ro+tines in A ig R *4s gr / ics @ int+ition !i&r riesF

    ,indScreen 0 J+se ;or'&enc screenJo/en gi e"ero"ero ;indo;

    9indo; 0>0>10>320>1)0> 50)> >1>2

    51

  • 8/9/2019 Blitz Basic

    52/247

    r/.!XR st ort 0H Jget r st/ort (or ;indo;;in.!X ee'.! Addr 9indo; 0HH J(ind ;indo; str+ct+re

    Dr ;E!!i/se[r/> 100>100> 70>70 Jgr / ics !i&r ry*o?e9indo;[;in>)>0 Jint+ition !i&r ry

    Bit* / 1>320>200>2 Jset+/ ;or' &it /Circ!e( 160>100>100>1 Jdr ; so et ing

    Jt en tr ns(er it to ;indo;

    B!tBit* /R st ort[ Addr Bit* / 1H>0>0>r/>0>0>100>100> c0

    9 itE?ent

    T e (in ! co nd B!tBit* /R st ort[ is ?ery +se(+! (or tr ns(erring gr / ics dr ;n;it t e ( ster &it / & sed B!it"2 co nds onto 9indo;.

    T is is ?ery syste (riend!y ; y o( c ei?ing t is o& ecti?e.

    Accessing /er ting Syste str+ct+res

    9it t e (i!e A*IGALIBS.RES resident see st rt o( c /terH e?en ore contro! o( t eS is /ossi&!e. T e (o!!o;ing is n e$ /!e o( ccessing S str+ct+res.

    J? ri &!e e$ec /oints to t e E$ecB se str+ctJ? ri &!e y!ist /oints to List ty/eJ? ri &!e ynode /oints to syste node

    e$ec.E$ecB seX ee'.! 5Hy!ist. ListX e$ec Li&Listynode.NodeX y!ist ! [%e d

    9 i!e ?node !n[S+ccX ee' ynode !n[N eHJ/rint node n e

    N rint ?nodeX ?node !n[S+ccF-o to ne$t node

    9end

    *o+se9 it

    T e +se o( t e steris' in ? ri &!en e.ty/e e ns t t inste d o( B!it"2cre ting ? ri &!e o( cert in ty/e it ct+ !!y +st cre tes 4/ointer4 to t t ty/e.T e ty/e str+ct+reH c n t en &e ccessed +st !i'e it ; s n intern ! B!it"2 ? ri &!e.

    T e co nd ee' is n e$ce!!ent ; y o( retrie?ing te$t (ro S str+ct+res> it re dse ory direct!y into B!it"2 string ? ri &!e +nti! it its n+!! c r 0HH.

    52

  • 8/9/2019 Blitz Basic

    53/247

    Loc ting 8 ri &!es nd L &e!s in *e ory

    T e /ers nd 4@4H c r cter c n &e +sed to (ind t e ddress o( ? ri &!ein t e A ig 4s e ory. ,or e$ /!eF

    JJ An e$ /!e o( +sing 4@4 to (ind t e ddress o( ? r.J8 r.!X7

    o'e.! @8 r> 10N rint 8 r *o+se9 it

    T is is si i! r to t e 8 r tr (+nction s+//!ied in ot er BASIC4s.

    9 en s'ing (or t e ddress o( string ? ri &!e> t e ret+rned ? !+e ;i!!/oint to t e (irst c r cter o( t e string. T e !engt o( t e string is 5&yte ? !+e> !oc ted t t e ddress 5.

    T e 4P4 c r cter c n &e +sed to (ind t e ddress o( /rogr ! &e! in t eA ig 4s e ory. ,or e$ /!eF

    JJAn e$ /!e o( (inding t e ddress o( /rogr ! &e!J* 8E W10>T ere J;o sse &!y code on t is !ineN rint ee'.; PT ereH*o+se9 itEndJT ereFDc.; 0 J;o nd g in ere

    T ese (e t+res re re !!y on!y o( +se to /rogr ers ;it so e sse &!y! ng+ ge e$/erience ; o need +ncon?ention ! e ns (or t eir ends.

    Const nts

    A 4const nt4> in BASIC /rogr ing ter s> is ? !+e ; ic does not c nget ro+g o+t t e e$ec+tion o( /rogr . T e 7 in X7 is const nt.

    A s sign WH &e(ore ? ri &!e n e e ns t t it is const nt no !onger ? ri &!e H nd c nnot c nge in ? !+e ; en t e /rogr is r+nning.W;idt X320 e ns t e ? ri &!e W;idt is const nt nd ;i!! !; ys &e X 320.

    53

  • 8/9/2019 Blitz Basic

    54/247

    Const nts ?e t e (o!!o;ing /ro/ertiesF

    . re ( ster t n ? ri &!es nd do not re-+ire ny e ory

    . 'e /rogr s ore re d &!e t n +sing n+ &ers

    . c n &e +sed in sse &!er

    . c n &e +sed ;it condition ! co /i!ing e? !+ tions

    . c n on!y o!d integer ? !+es

    . 'e it e sier to c nge const nt o+nt +sed t ro+g o+t /rogr

    . c n &e !tered t ro+g t e so+rce t co /i!e ti e &+t N T t r+nti e

    T e ost i /ort nt s/ect o( const nts (ro BASIC /rogr ers /oint o( ?ie; is t t ny 4 gic n+ &ers4 t t //e r t ro+g o+t t eir code c n &ere/! ced &y e ning(+! ;ords s+c s W;idt .

    I( t e /rogr e?er s to &e odi(ied to ;or' ;it ne; ;idt > inste d o( goingt ro+g !! t e so+rce c nging ny ention o( t e n+ &ers 43204> t e /rogr erc n +st c nge t e const nt e-+ te t t e to/ o( t e /rogrW;idt X320 to W;idt X650 etc.

    Condition ! Co /i!ing

    !!o;s t e /rogr er to s;itc t e co /i!er on nd o(( s it re ds t ro+g t e so+rcecode> contro!!ing ; ic / rts o( t e /rogr re co /i!ed nd ; ic re not.Condition ! co /i!ing is +se(+! (or /rod+cing di((erent ?ersions o( t e s e so(t; re;it o+t +sing 2 di((erent so+rce codes. It c n !so &e +sed to cri//!e de o ?ersion o(t e so(t; re or /rod+ce di((erent /rogr s (or di((erent rd; re con(ig+r tions.

    Tr c'ing do;n &+gs c n !so in?o!?e t e +se o( condition ! co /i!ing> &y t+rning o((ny +nnecess ry / rts o( code it &eco es e sier to /in/oint ; ere e$ ct!y t e error is

    occ+rring. %o;e?er ;e o/e t e B!it"2 de&+gger ;i!! 'e t is /r ctice o&so!ete.

    T e condition ! co /i!er directi?es re s (o!!o;sF

    CNI, co /i!er on i( n+ eric co / rison is tr+e> o(( ot er;iseCSI, co /i!er on i( string co / rison is tr+e> o(( ot er;iseCELSE s;itc co /i!er (ro /re?io+s st te onXMo(( o((XMonCEND end o( condition ! &!oc' restores /re?io+s st teHT e co /i!er s n intern ! on o(( s;itc > (ter CNI, or CSI, co / rison t eco /i!er s;itc es on (or tr+e> o(( (or ( !se. A CELSE ;i!! togg!e t e co /i!er s;itc

    54

  • 8/9/2019 Blitz Basic

    55/247

    nd t e CEND ;i!! restore t e on o(( st te to t t o( t e /re?io+s CNI, CSI,.

    CNI, CEND &!oc's c n &e nested.

    ItKs i /ort nt re e &er t t CNI, directi?e on!y ;or's ;it const nt / r eters (or

    e$ /!e> 474> 4Wtest4 nd not ;it ? ri &!es. T is is &ec +se B!it"2 +st &e &!e toe? !+ te t e co / rison ; en it is ct+ !!y co /i!ing> nd ? ri &!es re notdeter ined +nti! /rogr is ct+ !!y r+n.

    T e (o!!o;ing code i!!+str tes +sing condition ! co /i!ingF

    Wcri//!edXQ Jis cri//!ed ?ersion

    N rint Goo Goo So(t; re cH1::3

    CNI, Wcri//!edXQ

    N rint DE* NSTRATI N 8ERSI NCELSE

    N rint REGISTERED 8ERSI NCENDJJ nd ! ter on in t e /rogr ...J.S ?eRo+tineCNI, Wcri//!edX0Jon!y i( not cri//!edJJdo s ?e ro+tine

    JCENDRet+rn

    T e &ene(it o?er +sing str ig t I( cri//!edX0..EndI( is t t t e cri//!ed ?ersion o( t e&o?e code ;i!! not cont in t e s ?ero+tine in t e o& ect code so t t t ere is no ; y it

    c n &e +n cri//!ed &y c'ers.

    Condition ! co /i!er directi?es co e into t eir o;n ; en doing cro /rogr ing.

    * cros

    * cros re (e t+re +s+ !!y on!y (o+nd in Asse &!ers or !o;er !e?e! /rogr ing! ng+ ges. T ey re +sed to s ?e ty/ing> to re/! ce si /!e /roced+res ;it ( ster4in!ine4 ?ersions> or t t eir ost /o;er(+! to gener te code t t ;o+!d &e i /r ctic !to re/resent ;it nor ! code.

    A cro is de(ined in * cro n e..End * cro str+ct+re. T e code &et;een t ese

    55

  • 8/9/2019 Blitz Basic

    56/247

    t;o co nds is not co /i!ed &+t /! ced in t e co /i!er4s e ory.9 en t e co /i!er re c es cron e it t en inserts t e code de(ined int e cro t t is /oint o( t e so+rce code.

    T e (o!!o;ing codeF

    * cro y croX V1

    N rint Good L+c'End * cro

    N rint Si!!y E$ /!e ?1.0y croy cro

    *o+se9 it

    is e$/ nded intern !!y &y t e t e co /i!er to re dF

    N rint Si!!y E$ /!e ?1.0X V1

    N rint Good L+c'X V1

    N rint Good L+c'*o+se9 it

    * cro r eters

    To 'e t ings !itt!e ore +se(+!> / r eters c n &e / ssed in cro c !! +sing t es-+ig!y &r c'ets \ nd ]. T ese / r eters> re (irst!y inserted into t e cro te$t>t en t e cro te$t is inserted into t e in code.

    9 en cro is de(ined t e +se o( t e & c' /ostro/ e &o?e TAB 'ey on A ig H&e(ore digit or !etter 1 :> "H r's t e /oint ; ere / r eter ;i!! &e inserted.

    T e (o!!o;in