Real Software Forums
http://forums.realsoftware.com/

Changing values of vars passed as a paramarray
http://forums.realsoftware.com/viewtopic.php?f=21&t=47177
Page 1 of 1

Author:  wedgesan [ Wed Mar 06, 2013 4:39 am ]
Post subject:  Changing values of vars passed as a paramarray

Hello to all of you. I'm new in the Real Software community, and still learning how to get the best of it.

While reading about databases and recordsets, I've written a Method quite similar to this:

Method SQLExec (SQL as string, paramarray a as variant)

SQL is select sentence, something like "select person_id, first_name, secon_name from persons where person_id = '01'"

The purpose of this method is to assign the values of the fields to a number of variables. Because the select sentence passed as the SQL parameter can retrieve any number of fields, I thought I could include these variables as a paramarray.

The problem is that "Paramarray" and "ByRef" cannot be used together, so no matter what happens inside this method, outside its scope, this vars keep its original values.

Have any of you had tried something similar, and has found a workable workaround? Any kind of help will be much appreciated.

Thank you very much

Author:  timhare [ Wed Mar 06, 2013 5:29 am ]
Post subject:  Re: Changing values of vars passed as a paramarray

Use a dictionary instead. It can hold name/value pairs. Populate the dictionary (or array of dictionaries if you want the entire result set) and return it from the function.

Author:  wedgesan [ Thu Mar 07, 2013 2:54 am ]
Post subject:  Re: Changing values of vars passed as a paramarray

Not exactly what I had in mind, but it will do just fine. I also got to know the dictionary class because of your reply.

Thank you very much, timhare.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/