1.14: Compile Error: Unable to convert from 'TImag

BlitzMax Forums/BlitzMax Beginners Area/1.14: Compile Error: Unable to convert from 'TImag

DannyD(Posted 2005) [#1]
I COMPILED this earlier with 1.12 just fine.Using 1.14 I get
Unable to convert from 'TImage' to 'Int'
Global bob = LoadImage("incbin::media/pic.png")

What am I doing wrong ? Thanks in advance


Diablo(Posted 2005) [#2]
global bob:TImage = loadimage("incbin::media/pic.png")

you need to declare it as a Timage now days.


DannyD(Posted 2005) [#3]
Thanks for the prompt reply.


DannyD(Posted 2005) [#4]
Next problem :)
bobim[1]=bobimagetriangle
bobim[2]=bobimagebox

Unable to convert from 'TImage' to 'Int'

tried
bobim[1]=bobimagetriangle:Timage
bobim[2]=bobimagebox:Timage

and
bobim[1]:timage=bobimagetriangle
bobim[2]:Timage=bobimagebox

but to no avail.


Ferminho(Posted 2005) [#5]
go back where you declared bobim[n] so it's like

bobim:TImage[n]

where the array is declared - not in the lines you mention


DannyD(Posted 2005) [#6]
Thanks , Is it similar with TSound ?

Global beep = LoadSound ("incbin::media/beep.ogg",False)
unable to convert TSound to int.


I changed the abouve by adding TSOUND


but I still get "unable to convert TSound to int." Are the changes documented anywhere ? Thanks in advance


Yan(Posted 2005) [#7]
If you go to the doc entry for any command, you will see that they show you what type of object they return.
For instance...
Function LoadSound:TSound( url:Object,loop_flag=False )
See that :TSound? This is telling you that the LoadSound() command returns a TSound object, so, you must declare any sound object as a TSound object...
Local sound:TSound = LoadSound("mysound.wav")

The PlaySound() command looks like this...
Function PlaySound:TChannel( sound:TSound,channel:TChannel=Null )
You should be able to spot the error in your code now. :o)

[edit]
I should probably explain that any command that doesn't show a return type...
Function ResumeChannel( channel:TChannel )
Is returning an integer (:Int).
[/edit]


Diablo(Posted 2005) [#8]
also you might want to know the short hand
% = int
$ = string
! = double (i think)
# = single (or real)

not sure of any others cause i only use $,% and # short hand

I should probably explain that any command that doesn't show a return type...

this is the reson why you are getting errors :D - cause int is the default type for a var


Yan(Posted 2005) [#9]
He's getting errors because BMax no longer does an auto HandleFromObject() / HandleToObject() in either of the strict modes.


DannyD(Posted 2005) [#10]
Thanks alot for all you help.I'm learning every day :)