In a post on the PB/CC forum you explained the purpose of BYVAL
by stating:
Wondering if this works in PB/DOS and being the flexable
programmer that I am, I made up the small test program as
follows:
and come to find out, it works.
My question is this: Why would you need a statement like this?
The purpose of passing a variable and/or the contents of a
variable is to do something with it. Either change its contents
or use it to process other data.
To my way of thinking, if you don't want the contents of a
variable altered, don't.
------------------
by stating:
-------------------------
Now when a string is passed to that SUB, the content of the
string is passed, not the original variable, so any changes to
X$ within the SUB are not reflected back to the calling code.
-------------------------
Now when a string is passed to that SUB, the content of the
string is passed, not the original variable, so any changes to
X$ within the SUB are not reflected back to the calling code.
-------------------------
programmer that I am, I made up the small test program as
follows:
Code:
$lib all off color 14,1 cls m$ = "Now is the time" locate 1,1 : print;m$; call mysub(m$) locate 3,1 : print;m$; end sub mysub(byval m$) m$ = "The quick brown fox" locate 2,1 : print;m$; end sub
My question is this: Why would you need a statement like this?
The purpose of passing a variable and/or the contents of a
variable is to do something with it. Either change its contents
or use it to process other data.
To my way of thinking, if you don't want the contents of a
variable altered, don't.
------------------
Comment