I'm new to this forum. I've used BASIC and QBASIC long time ago, when I was in college. I've discovered a floppy disk with programs I wrote years ago, and I want to improve them a little. Most of these programs are math ones. I've always been a big fan of Pocket Computers, back in the 90s. I still like them today, and I recently bought, among others, a Casio fx-850p with its RP33 memory extension (with its 40 kb of memory, I'm the King of the World ! ). It was the 1st time I was using Casio BASIC, and I like it very much. I've downloaded QB64 on my PC, and I see there are some differences between the two languages. And that's why I'm here.

I've numerous math programs, and today, I'm working on a one that allows me to draw functions. It's simple and runs quite nice. The program asks me minimum and maximum values of the x and y axis, then draws the function I've stored in a routine. I'd like to be able to let the program ask me to input the function. For now, I must edit the program to type the function I want to work with. On my Casio, there is a function name VALF which is interesting. I store the function in an alphanumeric variable (for exemple F$), and VALF calculate its numeric value and store it in a numeric variable (for example Z : Z=VALF(f$)). Here is the code I have for an integration program :

Code: Select all

`10 CLS:PRINT "Calcul d'aires - Méthode des trapèzes :"`

20 INPUT "Fonction f(x) "; F$

30 INPUT "a "; A : INPUT "b "; B

40 INPUT "Nombre d'iterations "; N

50 H=(B-A)/N

60 X=A : Z1=VALF(F$) : X=B : Z2=VALF(F$) : S=.5*(Z1+Z2)

70 X=A

80 FOR I=1 TO N-1

90 X=X+H

100 Z=VALF(F$) : S=S+Z

110 NEXT I

120 S=S*H

130 PRINT CHR$(129); "f(x) dx ="; S

140 END

And now, here is the code of the drawing program I'm working with today (in QB64) :

Code: Select all

`'Draw Function`

1

SCREEN 12

COLOR 11

CLEAR

CLS

DEFDBL A-Z

PRINT

PRINT TAB(20); " Tracé d'une fonction"

PRINT

PRINT " Echelle :"

INPUT " Valeur minimale de x "; xmin

INPUT " Valeur maximale de x "; xmax

INPUT " Valeur minimale de y "; ymin

INPUT " Valeur maximale de y "; ymax

CLS

WINDOW (xmin + xmin / 10, ymin + ymin / 10)-(xmax + xmax / 10, ymax + ymax / 10)

LINE (xmin, 0)-(xmax, 0)

LINE (0, ymin)-(0, ymax)

FOR i = xmin TO xmax STEP 1

PSET (i, .125)

NEXT i

FOR j = ymin TO ymax STEP 1

PSET (.125, j)

NEXT j

FOR x = xmin TO xmax STEP 1 / 128

IF x = xmin THEN PSET (x, f(x)), 14

LINE -(x, f(x)), 14

NEXT x

LOCATE 28, 1

INPUT " Encore (o/n) "; z$

IF z$ = "o" THEN 1 ELSE END

FUNCTION f (x)

f = x ^ 3 - 3 * x ^ 2 + 2

END FUNCTION

English is not my native language, I hope you have understood what I want to know. In a few words, I want an equivalent to the VALF function of my Casio in the QB64 i use on my computer.

Thank you very much !

W.