not working!

BlitzMax Forums/BlitzMax Beginners Area/not working!

Caton(Posted 2015) [#1]
file=ReadFile(filename$)
header$=ReadString$(file)
CloseFile(file)


Floyd(Posted 2015) [#2]
ReadString in BlitzMax is not the same as in Blitz3D.

Blitz3D WriteString writes a 4-byte integer ( length of string ) followed by the actual string and reads back appropriately with ReadString.

BlitzMax Write/ReadString omit the length "header". You have to handle it yourself.

So assuming your file was built with Blitz3D you need to ReadInt the string length and then supply that to ReadString.


Kryzon(Posted 2015) [#3]
Maybe you're looking for ReadLine:
http://www.blitzbasic.com/bmdocs/command.php?name=ReadLine&ref=2d_cat


Caton(Posted 2015) [#4]
can you please show me how to do it in code?
not even sure how this works.


Brucey(Posted 2015) [#5]
can you please show me how to do it in code?

Sure...
file=ReadFile(filename$)
header$=ReadLine(file)
CloseFile(file)



Caton(Posted 2015) [#6]
not readline I'm trying to do readstring it's not a txt file it's a data file. but when I use readstring I get a error. I'm new to blitzmax.


Brucey(Posted 2015) [#7]
You never mentioned anything about a data file in any of your previous posts.

Your previous answer to Kryzon suggesting the use of ReadLine also didn't mention that you were not interested in reading a text file, only to see an example of ReadLine.

Most of us are unable to read your mind to find out what you are actually trying to do...

So, perhaps if you explain exactly what you are trying to achieve, you may get some answers that can help you solve your problem.


Floyd(Posted 2015) [#8]
I can't read his mind, but I can read his previous Blitz3D posts. This is confusion about ReadString.

On the other hand he could have just used WriteLine and ReadLine and avoided the issue.


Caton(Posted 2015) [#9]
What I'm trying to do is readstring and writestring to a data file like data.dat


Caton(Posted 2015) [#10]
how do I even do this?

type tobj
field obj
end type

For o.tobj=each tobj
next

each doesn't work.


xlsior(Posted 2015) [#11]
What I'm trying to do is readstring and writestring to a data file like data.dat


...Which means nothing, since a datafile can contains anything and everything.

did you create the datafile yourself? Do you have a format description?

If you're writing it out to disk with things like writeline, use the reverse commands (readline) in the same order to read back the contents of the file.

If the datafile is a a 3rd party binary blob then all bets are off without knowing more about the contents of the file.


Caton(Posted 2015) [#12]
I found why it won't work.
header$=readstring$(file,5)
---------------------
But now how do I use
For o.tobj=each tobj
next

in blitzmax?


Kimor(Posted 2015) [#13]
I think itīs just that for some reason BlitzMAX gone for another syntax.

for T:Obj = eachin ObjList
next


MikeHart(Posted 2015) [#14]
It really helps sometimes to study the documentation of a new tool when you start using it. But what doi know :-)


Kimor(Posted 2015) [#15]
I don't blame you though, the documentation is such a tedious bore.
There are good and there are bad documentation.

Only Java documentation would be worse.


Henri(Posted 2015) [#16]
Throughout every Blitz-product that I have used the IDE that came with the product has had one common functionality: You can move your cursor on top of a function and press F1-key to see a short description of that function. And if you press again you see a small example of that function on action.

-Henri


Kimor(Posted 2015) [#17]
Thatīs a nice feature when you have a bad memory, but not when you know what you want to do but you donīt know how to get there.

But hey manuals are what keeps the programming profession going ;)
If manuals where readable to anyone then everyone could be a programmer.

I mean people in general are great at solving problems, itīs not that
programmers are more clever at solving things or anything.

It is that becoming programmers actually (well barely) have the strength
to actually read the manuals. Most ppl donīt know programming
and these manuals make sure that will be the case, preserving the profession intact.

Programmers are "the people who had the strength to read boring books".

But you ned to be able to read boring books to be a programmer. Let the passion lead you !!!!!!!


degac(Posted 2015) [#18]
type tobj
field obj
end type

For o.tobj=each tobj
next


Hi

I invite you to read the syntax/language documentation available in MaxIDE (not the one related to F1 key, but the one in the treeview...): it's quite basic, but it has the base.

In BMAX objects are not-linked to a list.
You can create an object (type) and 'add' it to a Map or a List or an Array.

To iterate in a List (following your example) there is another operator 'similar' to Each EachIn
So your example should be something like

type tobj
field obj
end type

Local myObj:Tobj=New Tobj
Local myList:Tlist=New Tlist'create a new list where add my objects

myList.AddLast myObj'add at the end of the list

For o.tobj=EachIn myList'iterate through the list
Print o.obj
next


Cheers


Caton(Posted 2015) [#19]
about ios if it compiles for ios will it load assets from inside the game file or just folders I'm going to test the game on ios. so I would like to know.


Derron(Posted 2015) [#20]
You are writing in the BlitzMax beginners forum.

BlitzMax does not compile for iOS.


bye
Ron


Brucey(Posted 2015) [#21]
BlitzMax currently creates binaries for 32-bit Windows, OS X and Linux.
You need to use BlitzMax on each of those platforms to build for it.