HELP ERROR FILE!!!

BlitzMax Forums/BlitzMax Beginners Area/HELP ERROR FILE!!!

Caton(Posted 2016) [#1]
file=ReadFile(filename$)
dataline1=ReadLine(file)
CloseFile(file)

error says
---------------
Compile Error

Unable to convert from 'String to 'Int"

Some Please Help!!!


Brucey(Posted 2016) [#2]
Better if you can post a complete example, instead of some code snippet.

You should consider using (at least) Strict in your app. It forces you to declare variables correctly - like what variable is a String, and so on.
SuperStrict

Local filename:String = "somefile.txt"

Local file:TStream=ReadFile(filename)
Local dataline1:String=ReadLine(file)
CloseFile(file)



Derron(Posted 2016) [#3]
Seems you both repeat yourself - see this Thread


file=ReadFile(filename$)
titlename$=ReadLine$(file)
CloseFile(file)

it keeps tell me I have to define file? PLEASE HELP!!!



...won't quote Brucey's reply about "Strict" :-)


bye
Ron


Brucey(Posted 2016) [#4]
Seems you both repeat yourself

Indeed.

But since he asked so nicely this time I replied in kind :-)


grable(Posted 2016) [#5]
I honestly hope he hasnt been stuck on this for 6 whole days :p


Floyd(Posted 2016) [#6]
If we accept those three lines of code as the entire program and try to compile then this line
dataline1=ReadLine(file)
is highlighted and the error message is Unable to convert from 'String' to 'Int'.

ReadLine() is a string. The error is that it cannot be converted to an Int, which is what dataline1 is by default.

But Brucey's "tutorial" advice is apt. Posting code snippets and getting us to fix individual errors will never teach you programming.