[Gambas-user] Passing objects by reference
Chris Wilson
blixtra at ...626...
Thu Dec 16 01:14:56 CET 2004
Ok, I think I figured out the problem with the Array. I was trying to
call the Add method of the array outside a statment(sub or
function/method). Even when I get the Result in an Array however, I'm
not getting it to pass as reference. The code should explain.
db AS NEW Connection
myRS AS Result
myRSArray AS Object[]
'''The second line gave me problems
'''Seems as if you can't call methods outside statments
'''just declare variables, right?
'myRSArray = NEW Object[]
'myRSArray.Add(myRS) '''Always get "missing AS" error
PUBLIC SUB Form_Open()
IF MakeConnection("localhost","user","password","test") THEN
'''moved the above to here and I don't get the "missing AS"
error anymore
myRSArray = NEW Object[]
myRSArray.Add(myRS) ''' works here
'''I'm still not getting it to pass as reference,
'''even when I get the result into an Array
getData(myRSArray[0], "select * from student")
TextBox1.Text = myRSArray[0]!id ''this gives me "NULL Object" Error
TextBox2.Text = myRSArray[0]!name
END IF
END
PUBLIC SUB getData(rs AS Result, qry AS String)
rs = db.Exec(qry)
PRINT rs!id & " - " & rs!name ''works here
END
PUBLIC FUNCTION MakeConnection(host AS String, lgn AS String, pass AS
String, database AS String) AS Boolean
db.close
db.Type = "mysql"
db.Name = database
db.Host = host
db.Login = lgn
db.Password = pass
db.Open
RETURN TRUE
CATCH
Message.error(ERROR.text)
RETURN FALSE
END
The mysql table has 2 columns "id" and "name"
Thanks for the help
Chris
On Tue, 14 Dec 2004 08:27:59 -0500, Rob <sourceforge-raindog2 at ...94...> wrote:
> On Monday 13 December 2004 07:26, Chris Wilson wrote:
> > I still haven't been able to get the Result object into an
> > Array as described below . Could someone please enlighten me?
>
> I don't suppose you could post your project and a create script
> for your database. Could you?
>
> Rob
More information about the User
mailing list