ReadLine???
Blitz3D Forums/Blitz3D Beginners Area/ReadLine???
| ||
Hello! I've a Problem with ReadLine! here ist my text file: d-BATTLE 640 480 32 1 here ist the code: path$ = CommandLine$()+"\" gfile = ReadFile(path$+"DATA\main.cfg") AppTitle ReadLine$(gfile) Graphics3D Int(ReadLine(gfile)), Int(ReadLine(gfile)), Int(ReadLine(gfile)), Int(ReadLine(gfile)) WaitKey I get the error: Illegal Graphics3D Mode Can you help me? |
| ||
The order that Blitz calls ReadLine for each of the 4 arguments for the Graphics3D command like other programming languages is not guaranteed (you are incorrectly assuming blitz will evaluate your 4 arguments from left to right). You must ReadLine into variables in order to guarantee the correct order as in the following (note blitz's automatic string to int conversion): w%=ReadLine(gfile) h%=ReadLine(gfile) d%=ReadLine(gfile) m%=ReadLine(gfile) Graphics3D w,h,d,m |
| ||
thanks it works |
| ||
Also, you might want to look into using currentdir$() |
| ||
The order that Blitz calls ReadLine for each of the 4 arguments for the Graphics3D command like other programming languages is not guaranteed (you are incorrectly assuming blitz will evaluate your 4 arguments from left to right). The never-ending discussion. You must not assume that a compiler will evaluate the operands of a expression from left to right, but you can be sure that different expressions will be evaluated in a sequential order. The arguments of a function should be considered different expressions.The book 'C. Reference Manual. 4th edition', by Herbert Schildt, says the following about the comma operator (translated from spanish): When used as an operator, the comma is used to concatenate several expressions. [...] In the example 'x = (y=3, y+1);', the first element in the comma separated list must be evaluated, so '3' is assigned to 'y'. Then the result of 'y+1' is added to 'x'. |