 |
 |
|
 |
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
iden( string )
Turns a string into an identifier.
For example:
#declare iden("ThisFloat") = ThatFloat*2;
or
#declare ThisFloat = iden("ThatFloat")*2;
I find myself often need such a feature *very* much!
Please, anyone? :)
Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated October 9)
/ Also visit http://www.povrayusers.org
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Rune wrote:
>
> iden( string )
>
> Turns a string into an identifier.
>
> For example:
>
> #declare iden("ThisFloat") = ThatFloat*2;
>
> or
>
> #declare ThisFloat = iden("ThatFloat")*2;
>
> I find myself often need such a feature *very* much!
>
> Please, anyone? :)
>
> Rune
I'm not sure if that's easy to implement, furthermore it's likely to
produce errors because the string can change during eveluation of the Pov
code.
BTW, i don't know any programming language that has such a function.
Christoph
--
Christoph Hormann <chr### [at] gmx de>
Homepage: http://www.schunter.etc.tu-bs.de/~chris/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
Christoph Hormann <chr### [at] gmx de> wrote:
> I'm not sure if that's easy to implement, furthermore it's likely to
> produce errors because the string can change during eveluation of the Pov
> code.
>
> BTW, i don't know any programming language that has such a function.
I would imagine that the ability to change the string dynamically during the
parsing of the script is precisely the reason Rune would like a function
like this! And it's not unheard of - PHP, for instance, allows variable
variables, i.e. you can have one variable $a = "name", then use $$a just as
if it were $name.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
The iden() feature would be perfect in situations where arrays aren't
flexible enough.
An array like this
FlexArray[X][Y]
could be made like this
iden( concat( "FlexArray", str(X,0,0), "x", str(Y,0,0) ) )
However, in arrays all the elements have to be of the same data type. Not so
with the iden solution.
Arrays are confined to the number of elements you initiate it with. Not so
with the iden solution.
With arrays you are limited to the dimensions you set. All rows and columns
must have the same number of elements. With the iden solution you can make
up a completely custom structure.
These are just some of the many possibilities with the iden() feature. Don't
hesitate, buy it today! Err, I mean, program it today! :)
Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated October 9)
/ Also visit http://www.povrayusers.org
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
This looks like a potentially powerful feature...I don't know how easily
it could be done, but it shouldn't be impossible or very difficult.
It might allow the creation of a kind of "OOP" system written entirely
in POV-Script...though that would be a very slow and clumsy way to do it.
--
Christopher James Huff
Personal: chr### [at] mac com, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tag povray org, http://tag.povray.org/
<><
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
On Sun, 26 Nov 2000 13:49:15 +0100, Rune wrote:
>iden( string )
>
>Turns a string into an identifier.
I think I'd rather see associative arrays a la perl.
--
Ron Parker http://www2.fwi.com/~parkerr/traces.html
My opinions. Mine. Not anyone else's.
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
#macro iden(String)
#fopen TmpFile "tmptmp.tmp" write
#write(TmpFile, String)
#fclose TmpFile
#include "tmptmp.tmp"
#end
You can then use it exactly as you wanted:
#declare iden("ThisFloat") = ThatFloat*2;
--
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
"Warp" wrote:
> #macro iden(String)
> #fopen TmpFile "tmptmp.tmp" write
> #write(TmpFile, String)
> #fclose TmpFile
> #include "tmptmp.tmp"
> #end
I had been thinking about using #write and #include some way or another to
solve my problem, but your solution is just perfect!
Thank you Warp, you have spared me for a lot a trouble. :)
Rune
--
\ Include files, tutorials, 3D images, raytracing jokes,
/ The POV Desktop Theme, and The POV-Ray Logo Contest can
\ all be found at http://rsj.mobilixnet.dk (updated October 9)
/ Also visit http://www.povrayusers.org
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
I had briefly considered writing to a file and then including it, but
didn't think it would work in all cases, because including a file or
calling a macro doesn't do a direct copy and paste...can you use it in
macro parameters?
That macro is a great way of getting it done now, but a built-in feature
wouldn't leave that temporary file hanging around...a minor
inconvenience, but annoying, especially if it conflicts with another
file, though that isn't likely...maybe something like "identinc.tmp"
would be better.
Anyway, another potential addition for the macros to be included with
POV 3.5, don't you think? It's going in my personal collection...
--
Christopher James Huff
Personal: chr### [at] mac com, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tag povray org, http://tag.povray.org/
<><
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |
|  |
|
 |
In article <slr### [at] fwi com>, ron### [at] povray org
wrote:
> I think I'd rather see associative arrays a la perl.
Maybe Warp can implement that as a macro... :-)
Could you give more information on what the syntax would be like? Aren't
associative arrays just structures that "associate" a string or hash
with a variable?
--
Christopher James Huff
Personal: chr### [at] mac com, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tag povray org, http://tag.povray.org/
<><
Post a reply to this message
|
 |
|  |
|  |
|
 |
|
 |
|  |