[Gambas-user] Return an array in a function
Matías Manuel Grandi
matiasgrandi at ...626...
Sat Aug 7 17:40:32 CEST 2010
Hi Guys!
I have a problem when calling a function, which receive an xmlreader and
returns an array.
The function is geturl and the error gambas give me is "Type Mismatch:
Wanted an Array, got an Array instead"
The code is (a bit simplified):
PUBLIC <http://gambasdoc.org/help/lang/public>
SUB<http://gambasdoc.org/help/lang/sub>
btnPopular_Click()
DIM <http://gambasdoc.org/help/lang/dim> GetUrlFromXml
AS<http://gambasdoc.org/help/lang/as>
Array<http://www.google.com/search?hl=en&q=array+site%3Ahttp://gambasdoc.org/&btnI=I%27m%20Feeling%20Lucky>
xml8tracks = NEW <http://gambasdoc.org/help/lang/new>
XmlReader<http://www.google.com/search?hl=en&q=xmlreader+site%3Ahttp://gambasdoc.org/&btnI=I%27m%20Feeling%20Lucky>
xml8tracks = urlDownload("http://8tracks.com/mixes.xml?sort=popular")
GetUrlFromXml = GetUrl(xml8tracks)
END <http://gambasdoc.org/help/lang/end>
PUBLIC <http://gambasdoc.org/help/lang/public>
FUNCTION<http://gambasdoc.org/help/lang/function>
GetUrl(reader AS <http://gambasdoc.org/help/lang/as>
XmlReader<http://www.google.com/search?hl=en&q=xmlreader+site%3Ahttp://gambasdoc.org/&btnI=I%27m%20Feeling%20Lucky>
) AS <http://gambasdoc.org/help/lang/as>
Array<http://www.google.com/search?hl=en&q=array+site%3Ahttp://gambasdoc.org/&btnI=I%27m%20Feeling%20Lucky>
DIM <http://gambasdoc.org/help/lang/dim> smix[10, 4]
AS<http://gambasdoc.org/help/lang/as>
String <http://gambasdoc.org/help/lang/type/string>
DIM <http://gambasdoc.org/help/lang/dim> id
AS<http://gambasdoc.org/help/lang/as>
Integer <http://gambasdoc.org/help/lang/type/integer>
DO <http://gambasdoc.org/help/lang/do>
WHILE<http://gambasdoc.org/help/lang/while>
TRUE <http://gambasdoc.org/help/lang/true>
TRY <http://gambasdoc.org/help/lang/try>
reader.Read<http://gambasdoc.org/help/lang/read>
()
IF <http://gambasdoc.org/help/lang/if>
reader.Eof<http://gambasdoc.org/help/lang/eof>
THEN <http://gambasdoc.org/help/lang/then>
BREAK<http://gambasdoc.org/help/lang/break>
IF <http://gambasdoc.org/help/lang/if> reader.Node.Type =
XmlReaderNodeType<http://www.google.com/search?hl=en&q=xmlreadernodetype+site%3Ahttp://gambasdoc.org/&btnI=I%27m%20Feeling%20Lucky>
.Element THEN <http://gambasdoc.org/help/lang/then>
SELECT <http://gambasdoc.org/help/lang/select>
CASE<http://gambasdoc.org/help/lang/case>
reader.Node.Name
CASE <http://gambasdoc.org/help/lang/case> "name"
id = id + 1
reader.Read <http://gambasdoc.org/help/lang/read>()
smix[id, 0] = reader.Node.Value
PRINT <http://gambasdoc.org/help/lang/print> id & "Nombre: " &
smix[0, 0]
CASE <http://gambasdoc.org/help/lang/case> "restful-url"
reader.Read <http://gambasdoc.org/help/lang/read>()
smix[id, 1] = reader.Node.Value
PRINT <http://gambasdoc.org/help/lang/print> id & "restful-url:
" & smix[id, 1]
END <http://gambasdoc.org/help/lang/end>
SELECT<http://gambasdoc.org/help/lang/select>
ENDIF <http://gambasdoc.org/help/lang/endif>
LOOP <http://gambasdoc.org/help/lang/loop>
reader.Close <http://gambasdoc.org/help/lang/close>()
IF <http://gambasdoc.org/help/lang/if>
ERROR<http://gambasdoc.org/help/lang/error>
THEN <http://gambasdoc.org/help/lang/then>
Message<http://www.google.com/search?hl=en&q=message+site%3Ahttp://gambasdoc.org/&btnI=I%27m%20Feeling%20Lucky>
.Error <http://gambasdoc.org/help/lang/error>("Error when trying to open the
Heroes.XML file!")
RETURN <http://gambasdoc.org/help/lang/return>
ENDIF <http://gambasdoc.org/help/lang/endif>
RETURN <http://gambasdoc.org/help/lang/return> smix
END <http://gambasdoc.org/help/lang/end>
Thanks!
Mato.-
More information about the User
mailing list