Posts: 28
Threads: 5
Joined: Apr 2005
I can't get either of these commands to work. Example:
dim a as integer
OPEN "poop.txt" for binary as #ff
a = cvi(input$(2, #ff))
print a
close #ff
It worked just fine in QB, but FB shows a as being equal to zero, no matter what the file contains. I also tried the following:
dim k as string * 2
get #ff, , k
a = cvi(k)
print k
Same thing. It won't work. What's going on?
Posts: 3,522
Threads: 189
Joined: Dec 2003
Code:
dim a as short
ff = freefile
OPEN "poop.txt" for binary as #ff
get #ff, a
print a
close #ff
short = 16bit
integer = 32bit
Strings have an extra byte, a NULL terminator.
Best advice, dont use strings, you dont need them anymore.
Posts: 28
Threads: 5
Joined: Apr 2005
Thanks, that made it work.
I'm new to FB, so I didn't know about shorts. Now to see if I can get the rest of the program working...
Posts: 3,522
Threads: 189
Joined: Dec 2003
np, need more help just ask.
Posts: 28
Threads: 5
Joined: Apr 2005
Ok, now I have another problem. The following code creates an asm error (invalid operand for 'mov' instruction, or something similar). It's probably just a data type error, but I can't seem to find it. The relevent code is posted below.
Code:
TYPE POINT3D
X AS GLfloat
Y AS GLfloat
Z AS GLfloat
END TYPE
TYPE POLY
P1 AS integer
P2 AS integer
P3 AS integer
COLOUR AS GLfloat
END TYPE
type object3d
pts(MAX_PTS) as point3d
p(MAX_POLY) as poly
num_pts as integer
num_poly as integer
r1 as single
r2 as single
r3 as single
xyz as point3d
scale as single
end type
dim shared obj(MAX_OBJ) as object3d
dim shared num_objects as integer
num_objects = -1
'---------
'buncha stuff in between
'---------
Sub draw_object(o as object3d)
dim i as integer
glBegin GL_QUADS
for i = 0 to o.num_poly - 1
glColor3f o.p(i).colour, o.p(i).colour, o.p(i).colour
glVertex3f o.pts(o.p(i).p1).x, o.pts(o.p(i).p1).y, o.pts(o.p(i).p1).z
glColor3f o.p(i).colour, o.p(i).colour, o.p(i).colour
glVertex3f o.pts(o.p(i).p2).x, o.pts(o.p(i).p2).y, o.pts(o.p(i).p2).z
glColor3f o.p(i).colour, o.p(i).colour, o.p(i).colour
glVertex3f o.pts(o.p(i).p3).x, o.pts(o.p(i).p3).y, o.pts(o.p(i).p3).z
next i
glEnd
End Sub
Please help. :-?
yes, thats the same problem im getting on a prog im making, i have to stay at .12 for now i guess :(
"error: suffix or operands invalid for 'mov'"
Posts: 922
Threads: 15
Joined: Jun 2003
I couldn't reproduce the error, were you using 0.13? Did you use a DEF###? $DYNAMIC? etc..
Please, staying with old versions because the current one has some bug won't help improving the compiler, report the errors with some example code, so a patch can be released.. thanks.
EDIT: tested your code with 0.12, that's the same bug as reported by marzec at
http://forum.qbasicnews.com/viewtopic.php?t=9145, it was fixed in 0.13, get it ;)
well, i would send you code... except the fact that its about 3.5k lines as of right now. and its also an error about 20k lines into the asm code, and i have no idea about asm, really..
its not that i dont want to make it better its that i figure you have better things to do than wade through my 3.5k lines of code :P if you feel otherwise, i can pm you the source or whatever...