Outputting Custom Type Object to String

Blitz3D Forums/Blitz3D Programming/Outputting Custom Type Object to String

_PJ_(Posted 2014) [#1]
I was sure that it used to be possible to encapsulate Custom Type Object instances as a data string of the format:

Str( Str(Field f1 Value), Str(Field f2 value), ... Str(Field fn Value) )

By similar to the following (summarised example):

Type T
Field f1
Field f2
Field f3
End Type

Instance.MyType = New MyType

Str (Instance)



However, revently I have tried using this method (for debugging purposes) yet the Str(Instance.mytype) always comes out as "[OBJECT]"

Of course this can be achieved by using Str(Instance\f1)+", "+Str(Instance\f2)+", "... etc. but that's rather long winded

I just wondered if this was due to a change in B3D code, a bug or that I am mistaken.


Charrua(Posted 2014) [#2]
ummm... it sound to me...


from "type" help:

A cunning trick for debug purposes, or for saving data from types to a file, is to use the Str$ command. Print Str$() will print the values of each field of the type in turn, comma separated, within square brackets, e.g. [15,42,"Fluffy",500].


i test the following code and works ok for me
For texobj.tTexture = Each tTexture
	DebugLog Str(texobj)
Next


this is the type declaration:

Type tTexture
	Field file$
	Field flags
	Field b3dTexIdx
End Type



and this is the debuglog output:

["tex.jpg",1,0]
["tex1.jpg",1,1]


i'm using BB V1.106


Juan


_PJ_(Posted 2014) [#3]
Hey thanks for looking at this Charrua.

I am running B3D 1.108 and I made a quick test in the default Blitz IDE and it seemed to work as expected.

HOWEVER

When I use IDEal (which is my preferred IDE) the debuglog output is just [OBJECT]

So it seems to be an error in IDEal rather than B3D.

Thanks for helping clear this up!


_PJ_(Posted 2014) [#4]
I am an idiot.

At first I was even more puzzled when running tests in IDEal and finding it all worked as expected, but every time I ran my current project via IDEal I got the "[OBJECT]" result.

Finally I saw the reason for this issue:
I was running IDE with the BlitzPLUS compiler!

Compiling with BlitzPlus returns "[Object]" when using Str(Instance.MyType)
but Blitz3D of course is able to give the details of the type instance!