Question 
Author Message
 Question

Here's a piece of Clipper code for reference:

 sVar := 'GiANAKOD_LEN';
 &sVar := 3;
 sVar := 'GiANAKOD_LEN_2';
 &sVar := 2;

 I'm not sure if the code is exactly correct but the idea is that you can
use a variable name as string ('GiANAKOD_LEN', in this case) as a value to
another variable ('sVar', in this case) and then using & operator on sVar
you can assign value '3' to variable 'GiANAKOD_LEN'.

 I know I could use a method with single pointer to access different
variables but in this case i'm looking for something like this. Is there
anything similar to this '&' operator in Pascal?



Fri, 28 Oct 2005 21:59:27 GMT  
 Question
Hi Rhollie,

Unfortunately, this feature is not available in Pascal.

The feature is called macro substitution.  Only Clipper has it...believe me
I've tried and looked for this feature long and hard myself :-).

Likewise, you could use macro substitution to avoid create arrays for small
lists.  for example

Var1 = "This"
Var 2 = " Is"
Var3 = " A"
Var4 = " Test"

For counter = 1 to 4
      Say Var&&Counter
Next

Not 100% clipper syntax  but you get the idea :-).

Needless to say this feature was coded in C, ,so perhaps it would be
conceivable to reproduce in C and link to it in Pascal.

Stephane Richard
Software Developer


Quote:
> Here's a piece of Clipper code for reference:

>  sVar := 'GiANAKOD_LEN';
>  &sVar := 3;
>  sVar := 'GiANAKOD_LEN_2';
>  &sVar := 2;

>  I'm not sure if the code is exactly correct but the idea is that you can
> use a variable name as string ('GiANAKOD_LEN', in this case) as a value to
> another variable ('sVar', in this case) and then using & operator on sVar
> you can assign value '3' to variable 'GiANAKOD_LEN'.

>  I know I could use a method with single pointer to access different
> variables but in this case i'm looking for something like this. Is there
> anything similar to this '&' operator in Pascal?



Fri, 28 Oct 2005 22:48:36 GMT  
 Question


Wed, 18 Jun 1902 08:00:00 GMT  
 Question


Fri, 28 Oct 2005 23:30:05 GMT  
 Question


Wed, 18 Jun 1902 08:00:00 GMT  
 Question
[using a variable as variable name]

Quote:

>  I know I could use a method with single pointer to access different
> variables but in this case i'm looking for something like this. Is there
> anything similar to this '&' operator in Pascal?

No there isn't. And that's good!
One "modern" language which has this feature is Perl.

Although Perl, the following link might be interesting for you because
it also explains why you shouldn't use that feature:
http://www.perldoc.com/perl5.8.0/pod/perlfaq7.html#How-can-I-use-a-va...

What to do instead: use a hashing algorithm. I've written a small "Hash"
unit for Pascal (FPC and Delphi only) which you might want to use. Have
a look at http://www.behrenhoff.de/pascal/hash.zip

Wolf



Fri, 28 Oct 2005 23:49:51 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Questions, questions, questions....So many questions...Help me please...

2. Questions, questions ...

3. Question on passing pointer to procedure - question.zip (0/1)

4. Question on passing pointer to procedure - question.zip (0/1)

5. Timo Salvi's FAQ Question #73 Questioned!

6. Question and answer lost on a SQL query (answer from avegaart)

7. SQL question

8. DatabaseName question

9. Two questions

10. SQL question

11. DataBase Question

12. ado save question

 

 
Powered by phpBB® Forum Software