PenUltima Online

It is currently Sun Sep 07, 2008 2:24 am

All times are UTC - 8 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: References and Values; Objects, Values and ByVal/ByRef
PostPosted: Fri Dec 01, 2006 9:14 pm 
Guide removed. No longer available. Likely filled with factual errors, anyway :razz:


Last edited by Marilla on Sun Dec 17, 2006 8:50 am, edited 1 time in total.

Top
  
 
 Post subject:
PostPosted: Mon Dec 04, 2006 1:55 am 
Offline

Joined: Sun Mar 05, 2006 7:25 am
Posts: 118
Location: Italy
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


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 04, 2006 2:53 am 
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!

8)


Top
  
 
 Post subject:
PostPosted: Mon Dec 04, 2006 5:18 am 
Offline

Joined: Sun Mar 05, 2006 7:25 am
Posts: 118
Location: Italy
Recently I'm prefering the use of struct too ^_^


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 04, 2006 9:29 pm 
Offline

Joined: Thu Feb 02, 2006 1:41 pm
Posts: 1129
Location: Southern Central USA
*Copies thread to 'POL Knowledgebase folder'*

_________________
Sincerely,
Yukiko

I know you think you understand what you thought I said but what you heard is not exactly what I meant.

Titus 2:13


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl