Qb64 is a good way to convert all of your old Q-basic programs into modern fast full-screen material.

    It converts them into C-language and compiles them into exe files. It works good, but I find it too tricky to use for new programs. Use C-language instead.

  Main site:                        http://qb64.net/


                                 KEYBOARD


INKEY$      A$ = INKEY$

INPUT ; " input a number " ; a (A$)

INPUT$      A$ = INPUT$(4)               (GETS 4 LETTERS)

SLEEP 2       ' sleeps 2 seconds or until key pressed

 


                                 ARRAYS  , VARIABLES and DATA


STRING$      INTEGER%   FLOAT  DOUBLEFLOAT#   SINGLEFLOAT!  LONGINTEGER&

DIM a AS INTEGER

DIM SHARED b AS INTEGER   ' global variable shared with subroutines


DIM Array(100) AS INTEGER    (same as)  DIM ARRAY%(100)

DIM ARRAY$(50)   'string array    ' 51 strings

DIM Array(12, 10)   ' 2 dimensional array

     A = Array(12,10)


                                LOOPS and LOGIC


DO

        .... do stuff

LOOP UNTIL  a>0


WHILE  A>0

        ..... do stuff

WEND


WHILE INKEY$ <> "" : WEND


IF a% > b% AND a% < 200 THEN PRINT "True"

IF (a% > b% AND b% > c%) AND (c% < d% AND d% < e%)  OR ( z%=q%) THEN

PRINT "True"

ELSE

PRINT "False"

END IF


NOT


FOR i = 10 TO 0 STEP -1

    PRINT i

NEXT  


                                 SUBROUTINES

n=10

CALL  dostuff (n)

PRINT n

END


SUB dostuff (n)   rem  "n" forced to Global

 n = n + 5

END SUB


                                          SCREEN AND GRAPHICS

 CIRCLE           CIRCLE (X,Y) , radius, color

CLS       clear screen    CLS 0  clear screen   CLS 1  clear graphics   CLS 2 clear text

COLOR      forground%,background%      'depends on graphics mode

DRAW        octagon$ =  "C12  R10 F10 D10 G10 L10 H10 U10 E10"   DRAW octagon$

GET

LINE (x,y)-(x2,y2)

PAINT (x,y)  fillcolor%, bordercolor%

PALETTE USING

PCOPY

PMAP

POINT       rgba = POINT (x,y)

PRESET (X,Y)   'sets point to background color

PSET (x,y),color      ' sets the color of a point

PUT

SCREEN 0         ' screen mode 0-3 7-13

STEP

VIEW

WINDOW (x,y)-(x2,y2)      ' custom size screen


_AUTODISPLAY

_CLIP

_COPYIMAGE

_COPYPALETTE

_DEST

_DISPLAY

_FULLSCREEN

_FREEIMAGE

_HEIGHT

_ICON

_LOADIMAGE

_PIXELSIZE

_PRINTSTRING

_PUTIMAGE

_SCREENIMAGE

_SOURCE

_WIDTH


                                                     MATH

 ABS (n)  returns positive value  

ATN (Radian angle)  arctangent  

CDBL (function) closest double rounding function 

CINT (function) closest integer rounding function 

CLNG (function) closest long integer rounding function 

COS (function) cosine of a radian angle 

CSNG (function) closest single rounding function 

EXP (function) returns the value of e to the power of the parameter used. 

FIX (function) rounds positive or negative values to integer values closer to 0 

INT (function) rounds to lower integer value 

LOG (function) natural logarithm of a specified numerical value. 

SIN (function) sine of a radian angle. 

SQR (function) square root of a positive number. 

TAN (function) returns the ratio of SINe to COSine or tangent value of an angle measured in radians. 


_ROUND (function) rounds to the closest EVEN INTEGER, LONG or _INTEGER64 numerical value. 

+ addition operation 

- subtraction or negation operation 

* multiplication operation 

/ decimal point division operation 

\ integer division operation 

^ exponential operation 

MOD integer remainder operation 


                                            FILES

Saving array data to a file:


 LB% = LBOUND(Array)

 bytes% = LEN(Array(LB%))

 filesize& = ((UBOUND(Array) - LB%) + 1) * bytes% 

 DEF SEG = VARSEG(Array(0))

  BSAVE filename$, VARPTR(Array(LB%)), filesize&  ' changeable index

 DEF SEG

 

OPEN file$ FOR OUTPUT AS #1    ' make new file or clear old one

CLOSE#1


OPEN file$ FOR BINARY AS #1

    PUT #1, , array()

CLOSE #1


OPEN "BINFILE.BIN" FOR BINARY AS #2

   GET #2, , array()

CLOSE #2


IF Exist%(file$) THEN 

                A = 1  ' files start at 1 

                OPEN file$ FOR INPUT AS #1

                     WHILE A<1000

                     GET #1, , value% : PRINT value%

   A=A+1

   WEND

                 CLOSE #1

END IF


 CLEAR   ' clear all variables and close all files





 
Make a Free Website with Yola.