PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: raymw on January 24, 2018, 12:32:35 PM

Title: passing variable names to a function
Post by: raymw on January 24, 2018, 12:32:35 PM
I want to write a simple function that on being passed a variable name, then it can print that name and its value. I've got into a tangle with byref and byval, and  I am not sure if the answer is that simple.  for example, the sort of thing I'm looking for

function displayit( aval as string) as string

will print something like  - 'string anystring = "content of string" '

if the function is called by displayit(anystring)     where anystring = "content of string"

I've got myself into a head-achy situation with this. Then of course I will want to be able to produce a similar result for any type of variable. Any one care to post some code? I expect the solution is obvious, once I see it. (I don't want to use anything like 'displayit("anystring",anystring)' )
Thanks
Title: Re: passing variable names to a function
Post by: SeaVipe on January 24, 2018, 04:17:21 PM
Hi Raymw,
For clarification, can you post your current code?
Clive
Title: Re: passing variable names to a function
Post by: raymw on January 24, 2018, 04:23:57 PM
OK, I'll have to find something to explain it better. My current code does not work, and most likely is going entirely in the wrong direction.
Title: Re: passing variable names to a function
Post by: José Roca on January 24, 2018, 05:09:49 PM
> I don't want to use anything like 'displayit("anystring",anystring)'

Then forget about it, because it would be the only way.
Title: Re: passing variable names to a function
Post by: raymw on January 24, 2018, 05:15:51 PM
Thanks, Jose. I was sort of coming to the same conclusion, but can always live in hope...