PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
References and Values; Objects, Values and ByVal/ByRef

 
Post new topic   Reply to topic    PenUltima Online Forum Index -> POL Guides
Display posts from previous:   

Author Message
Marilla



Joined: 02 Feb 2006
Posts: 329

PostPosted: Sat Dec 02, 2006 1:14 am    Post subject: References and Values; Objects, Values and ByVal/ByRef Reply with quote

Guide removed. No longer available. Likely filled with factual errors, anyway Razz

Last edited by Marilla on Sun Dec 17, 2006 12:50 pm; edited 1 time in total

Author Message
Lagoon



Joined: 05 Mar 2006
Posts: 118
Location: Italy

PostPosted: Mon Dec 04, 2006 5:55 am    Post subject: Reply with quote

I'm adding a case where it's very good to use byref. Spometimes you need a function which returns more than a value. There are two ways to do this:

1) returning an array, a struct (I prefere to use a struct when returned variables have different types, but it's not mandatory) or (in some particular cases) a dictionary
2) passing any number of (uninitialized) variables by reference and setting their values inside the function

Author Message
Marilla



Joined: 02 Feb 2006
Posts: 329

PostPosted: Mon Dec 04, 2006 6:53 am    Post subject: Reply with quote

Lagoon wrote:
I'm adding a case where it's very good to use byref. Spometimes you need a function which returns more than a value. There are two ways to do this:

1) returning an array, a struct (I prefere to use a struct when returned variables have different types, but it's not mandatory) or (in some particular cases) a dictionary
2) passing any number of (uninitialized) variables by reference and setting their values inside the function


Yup, that can work too! COM programmers on Windows, for example, will recognize this as pretty much how everything is done. Since the return value is very often reserved for the 'HRESULT', or basically the status code, most values are gotten back by passing variables into reference parameters.

I personally don't like that way of doing things, because I think that returning a struct is usually a better option. For example, all of the Core functions that return multiple, but differing values do so as members of a struct (those that return multiple like values do so by returning an array).

However, this isn't at all an invalid use of this, and might come in handy for some folks; Thanks for adding it!

Cool

Author Message
Lagoon



Joined: 05 Mar 2006
Posts: 118
Location: Italy

PostPosted: Mon Dec 04, 2006 9:18 am    Post subject: Reply with quote

Recently I'm prefering the use of struct too ^_^

Author Message
Yukiko



Joined: 02 Feb 2006
Posts: 1081
Location: Southern Central USA

PostPosted: Tue Dec 05, 2006 1:29 am    Post subject: Reply with quote

*Copies thread to 'POL Knowledgebase folder'*

Post new topic   Reply to topic    PenUltima Online Forum Index -> POL Guides All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty