| View previous topic :: View next topic |
| Author |
Message |
dmonckton Contributor


Joined: 09 Aug 2002 Posts: 117 Location: Lewes, U.K.
|
Posted: Tue Oct 16, 2012 9:12 am Post subject: Random variable name |
|
|
Hi all
Does anyone know how to create a random variable name?
For example...
| Code: | | %%@random(1024) = foo |
Does not work.
Thanks
David... |
|
| Back to top |
|
 |
Rubes_sw Valued Contributor


Joined: 11 Jun 2001 Posts: 625 Location: Northern Ireland
|
Posted: Tue Oct 16, 2012 2:24 pm Post subject: |
|
|
# %%len lenght of the variable you want
%%len = 10
%x = 0
# The string containing the characters you want included in the variable name
%a = abcdefghijklmnopqrstuvwxyz
# Will hold the final variable name
%%tmp =
# You should seed the random, otherwise you will prob get the same word
RANDOM @datetime(shn)
repeat
%b = @random(1,@len(%a))
%c = @substr(%A,%b,%b)
%%tmp = %%tmp%c
%x = @fadd(%x,1)
until @equal(%x,%%len)
INFO Your Tmp word is: %%tmp |
|
| Back to top |
|
 |
LiquidCode Moderator Team
Joined: 05 Dec 2000 Posts: 1753 Location: Space and Time
|
Posted: Tue Oct 16, 2012 2:55 pm Post subject: |
|
|
I think he wants the variable name itself to be random. There is no way to have a random variable name created. _________________ Chris
Http://theblindhouse.com |
|
| Back to top |
|
 |
Rubes_sw Valued Contributor


Joined: 11 Jun 2001 Posts: 625 Location: Northern Ireland
|
Posted: Tue Oct 16, 2012 3:16 pm Post subject: |
|
|
oops... should have read it correctly !.... my bad !
aw well it give me 10 mins of thinking about it !  |
|
| Back to top |
|
 |
uvedese Contributor


Joined: 21 Jan 2006 Posts: 169 Location: Spain
|
Posted: Tue Oct 16, 2012 4:13 pm Post subject: |
|
|
Hi guys:
There is no way to create a random variable name... Anyway, it's not useful.
I think ... can create a list where to save a random name associated with a value. This way:
"randomname"|value
"randomname"|value
"randomname"|value
etc.
I hope that will be useful
_____________
uVeDeSe
_____________ |
|
| Back to top |
|
 |
dmonckton Contributor


Joined: 09 Aug 2002 Posts: 117 Location: Lewes, U.K.
|
Posted: Thu Oct 25, 2012 8:08 am Post subject: |
|
|
Thanks for your help, shame you can't do random variables.
David... |
|
| Back to top |
|
 |
cnodnarb Professional Member


Joined: 11 Sep 2002 Posts: 766 Location: Eastman, GA
|
Posted: Thu Oct 25, 2012 5:44 pm Post subject: |
|
|
Didn't solve your problem...but I did learn something from trying!!
| Code: |
%%r@random(1024) = foo
info %%r@random(1024)
%%s@sum(1,2) = ""
info %%s@sum(1,2) |
|
|
| Back to top |
|
 |
cnodnarb Professional Member


Joined: 11 Sep 2002 Posts: 766 Location: Eastman, GA
|
Posted: Thu Oct 25, 2012 5:48 pm Post subject: |
|
|
Now if I could only figure out WHY I find this interesting...
| Code: |
dialog create,_
%%filedlg@filedlg() = ""
info %%filedlg@filedlg()
|
|
|
| Back to top |
|
 |
cnodnarb Professional Member


Joined: 11 Sep 2002 Posts: 766 Location: Eastman, GA
|
Posted: Thu Oct 25, 2012 6:00 pm Post subject: |
|
|
Approach cautiously. Not all parameters to functions translate well using this um.. err.. whatever it is.
| Code: | dialog create,_
%%filedlg@filedlg(Bitmap|*.bmp) = Who's throwing Handles!
info %%filedlg@filedlg()
%%filedlg = @filedlg(Bitmap|*.bmp)
info Who's throwing Handles!%%filedlg |
|
|
| Back to top |
|
 |
cnodnarb Professional Member


Joined: 11 Sep 2002 Posts: 766 Location: Eastman, GA
|
Posted: Thu Oct 25, 2012 6:10 pm Post subject: |
|
|
OK, figured this one out.
VDS is dumping the function, and the function is refreshed when trying to call it.
so in the case of
%%filedlg@filedlg() = "foo"
%%filedlg is equal to foo. The @filedlg() piece is dropped.
When referencing back it's confusing, because you make the call
info %%filedlg@filedlg() the @filedlg() piece is actually called/referenced to where in the declaration it is not.
So, as we were. |
|
| Back to top |
|
 |
|