• Welcome to PlanetSquires Forums.
 

passing variable names to a function

Started by raymw, January 24, 2018, 12:32:35 PM

Previous topic - Next topic

raymw

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

SeaVipe

Hi Raymw,
For clarification, can you post your current code?
Clive
Clive Richey

raymw

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.

José Roca

> I don't want to use anything like 'displayit("anystring",anystring)'

Then forget about it, because it would be the only way.

raymw

Thanks, Jose. I was sort of coming to the same conclusion, but can always live in hope...