ByVal = data
ByRef = pointer
Basically, ByRef (PB pointer) will change the value of the passed external variable. ByVal will not, respecting the parameter as a local variable only, and leaving the passed external variable unchanged.
In VB (and other languages), specifying ByRef tells the compiler to treat the parameter as a pointer, thats all.
[Implemented] A few VB touches....
In PB it is all about how you used the data passed into the function. A pointer is still data. If you treat it like a pointer in PB, it is one (more or less)..
So technically speak passing a pointer and passing int 12345 is the same thing as far as *what* gets passed - an integer. All AFAIK, IANAL, FYI, etc
So technically speak passing a pointer and passing int 12345 is the same thing as far as *what* gets passed - an integer. All AFAIK, IANAL, FYI, etc
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
This is apptly put.traumatic wrote:Don't know.Kale wrote:Am i missing something here.
This is not a matter of VB (other languages allow you to chose how
to pass parameters as well **), it's a matter of design/concept/needs.
Using ByVal, only a copy of the parameter will be used inside the
procedure. This prevents the procedure from changing the passed
data. Values are being preserved.
(Using a copy obviously allocates memory when calling the procedure
and comes with a certain performance hit of course.)
With ByRef (PB's way) on the other hand you're passing a memory
location, thus allowing the procedure to change the passed data,
which may not always be wanted.
** think of C for example:[/size]Code: Select all
void ByVal(yourStruct var); void ByRef(yourStruct& var);
I used the word VB as I know only Visual Basic and nothing else. I left C when I saw VB 2 and from then on I have never used any other language till date except AutoHotKey and WinBatch.
Re: A few VB touches....
There should be implementation of almost all String Management functions like Left$, Right$, Mid$, ReverseStr, StringCompare, StringCovert (for converting between ANSI and UNICODE as well as for Case Conversion), etc. etc. etc.Yogi Yang wrote:A large set for Functions for manuplating Strings like those in VB and more, Arrays & such collections features as implemented in VB.NET would be great to have in PB.
I am learning VB.NET currently and like the features that are provided for Arrays and Collections. Implementing similar features would be a bonus for PB developers.
In fact there are many features in .NET Core Lib which are worth implementing as they will reduce a lot of error prone coding.....
well, i still claim pure is using byval instead of byref, look at the pseudo code below:
perhaps the above illustrates it better
it's not that i'm claiming pure cannot do it, it does it very well, actually, but it's using byval instead of byref for regular parameters being passed
i'm not referring to the CONCEPT of modifying the variables, just to the implementation in purebasic
Code: Select all
procedure x(byref a.l) ; not possible in pure
a = a+1
endprocedure
procedure y(*a.LONG)
*a\l = *a\l + 1
endprocedure
it's not that i'm claiming pure cannot do it, it does it very well, actually, but it's using byval instead of byref for regular parameters being passed
i'm not referring to the CONCEPT of modifying the variables, just to the implementation in purebasic

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )