PlanetSquires Forums

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: passing variable names to a function  (Read 649 times)

raymw

  • FireFly3 User
  • Senior Member
  • *
  • Posts: 219
passing variable names to a function
« 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
Logged

SeaVipe

  • FireFly3 User
  • Junior Member
  • *
  • Posts: 129
  • Windows 10
Re: passing variable names to a function
« Reply #1 on: January 24, 2018, 04:17:21 PM »

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

raymw

  • FireFly3 User
  • Senior Member
  • *
  • Posts: 219
Re: passing variable names to a function
« Reply #2 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.
Logged

Josť Roca

  • FireFly3 Registered User
  • Master Member
  • *
  • Posts: 3109
    • Jos
Re: passing variable names to a function
« Reply #3 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.

raymw

  • FireFly3 User
  • Senior Member
  • *
  • Posts: 219
Re: passing variable names to a function
« Reply #4 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...
Logged