ERROR!

BlitzMax Forums/BlitzMax Beginners Area/ERROR!

Caton(Posted 2016) [#1]
file=WriteFile("test.cfg")
WriteLine(TextFieldText$(TestBox),file)
CloseFile(file)

Error says unable to convert String to TStream

Guys Please Help!


Cocopino(Posted 2016) [#2]
Hmmmm...
I've seen this question a couple of times now from you. Maybe you should read the other answers?
- Always put "Superstrict" above your code.
- WriteFile is a function that returns a TStream object.
- WriteLine needs parameters (stream:TStream,str$)


Brucey(Posted 2016) [#3]
Maybe you should read the other answers?

Good suggestion :-)


Caton(Posted 2016) [#4]
file:TStream=WriteFile("test.cfg")
WriteLine(TextFieldText$(UsernameBox),file)
CloseFile(file)
didn't WORK!


Derron(Posted 2016) [#5]
Someone should report you for senseless spamming.

You asked the exact same question multiple times, you do not respond to the responses given there.


bye
Ron


Brucey(Posted 2016) [#6]
Maybe he doesn't understand English?

Caton, what's your native language? :-)


H&K(Posted 2016) [#7]
Maybe its a non human intelligence and it is we who are misunderstanding the question.

Or... maybe its a secret "spy" message, and the correct answer will be something innocuous but the nest day the eiffel tower gets bombed.


dw817(Posted 2016) [#8]
Caton, please post the ENTIRE program you are working on. Maybe then we'll understand what the real question is here you are asking.


Matty(Posted 2016) [#9]
I don't use Max but I am guessing looking at your briefest of code snippets that you simply have the parameters around the wrong way?

http://www.blitzbasic.com/bmdocs/command.php?name=writeline&ref=goto

Stream comes first, not the string....


The other guy at the first response already told you this.....


grable(Posted 2016) [#10]
After so many posts with the same code snippet with only minor tweaks each time.
And the fact that he doesnt answer except with the same snippet again, leads me to believe he is trolling.


Caton(Posted 2016) [#11]
Thanks Matty for helping me with that error.


Caton(Posted 2016) [#12]
Hey not function doesn't work see code.

Global Username$,Password$

Function LoadLogin(filename$)
file=ReadFile(filename$)
Username$=ReadLine$(file)
Password$=ReadLine$(file)
CloseFile(file)
End Function

LoadLogin("login.txt")

If Not Username$="admin" Then End
If Not Password$="password" Then End

txt file=================
admin1
password1
=================
if won't do anything if username and password are incorrent!


Cocopino(Posted 2016) [#13]
if won't do anything if username and password are incorrent!


Well...
If Not Username$="admin" Then End
tells the program to shut down, because "admin" does not equal "admin1".
If you want a program to "do something" you'll need to program it, like
If Not Username$="admin" Then notify "Incorrect username"; End



Caton(Posted 2016) [#14]
If Not Username$="admin" Then Notify "Incorrect username"; End
Still didn't work could this be a bug in blitzmax?


xlsior(Posted 2016) [#15]
If Not Username$="admin" Then Notify "Incorrect username"; End
Still didn't work could this be a bug in blitzmax?


No, it's just a bad example.

This works:

username$="a"
If Not (Username$="admin") Then Notify "Incorrect username"; End


And so does this:

username$="a"
If Username$<>"admin" Then Notify "Incorrect username"; End



Cocopino(Posted 2016) [#16]

This works:
username$="a"
If Not (Username$="admin") Then Notify "Incorrect username"; End




What's the point of setting a string manually and then running another manual check on it the next line?
The way I read post #12, a user has saved his login to a file named login.txt. The program will then set variable username$ to "admin1" according to these file contents:

txt file=================
admin1
password1
=================



And "admin1" does not equal "admin".
So I assume what happens next is "the program doesn't work", which it shouldn't. But many of the posts by Caton are a little cryptic as to what "does not work" really means :)


grable(Posted 2016) [#17]
What's the point of setting a string manually and then running another manual check on it the next line?
I read it as a sample to show how it works, runable by its own.
Which is a better fit really, when we dont know the real contents of his files.


Cocopino(Posted 2016) [#18]

when we dont know the real contents of his files.


True.

Caton, run your program in debug mode and use commands:
Debuglog "Username: " + username$
Debuglog "Password: " + password$
etc...

when things don't work as expected.