|
Pages: [1]
|
 |
|
Author
|
Topic: string to native (?) (Read 982 times)
|
|
Smokey
|
I have an script containing a block + function and am passing a value to the object from another .r file -- the intent is to pass the value and then use it to select from the block (used as a simple database) and output it. I'm querying another varible and then wanting to select '../../on' or '../../off' from the block as appropriate. I've been trying as such: ... handle: func [ parm ] [ result: rejoin [ "id/" parm "/on" ] out: result ] Output is "id/valueofparm/on" -- I get the appropriate output when hard coding the xx/xx/xx selection. Is it possible to piece together like I am trying somehow? I've nearly tossed out this approach and went to a file but it would be nice if I could avoid the file and keep this as an all in one since it's only a tiny bit of the larger CGI, a dynascript for Vanilla. Smokey
|
|
|
|
|
Logged
|
|
|
|
|
Graham
|
Not clear to me at least what you're trying to achieve.
|
|
|
|
|
Logged
|
|
|
|
|
Smokey
|
Hi, maybe I can explain it more clearly. I have a block: make object! [ id: [ one [ on { \ <center> \ ..markup if 'on' </center> \ }
off { \ <center> \ ..markup if 'off' </center> \ } ] ]
..and a function: handle: func [ num /local user ] [ either admin? user [ result: copy rejoin [ "id/" num "/off" ] ; result: id/one/off ] [ result: copy rejoin [ "id/" num "/on" ] ; result: id/one/on ] out: result ] ]
The two commented lines will work but the two using 'copy rejoin' will not. I am wanting to pass to the script the 'one' part -- EG: the block contains additional data that can be referenced by id/two/on, id/three/off, etc. The value of 'num' is correct, in that it is set with "one" after I envoke the script but I expected to be able to have the appropriate string retrieved from the block, which isn't happening. Does that make more sense? Smokey
|
|
|
|
|
Logged
|
|
|
|
|
DideC
|
Try :
result: copy id/:num/on
|
|
|
|
|
Logged
|
|
|
|
|
Smokey
|
Hi DideC, ..results in a 500 error. Different mutations trying ":num" vary in their result. EG: result: copy "id/" num "/on" == "id/" -- seems evident the rejoin is needed. I've banged around trying mold, remold and so forth but no real progress. I read an old DDJ article by Carl about code-data duality and it seems what I am trying to do is similar to what the article is discussing. Smokey
|
|
|
|
« Last Edit: October 17, 2006, 02:37:46 PM by Smokey »
|
Logged
|
|
|
|
|
Graham
|
Try this id: make object! [ one: make object! [ on: { on markup } off: { off markup } ] two: make object! [ on: { on markup } off: { off markup } ] ]
handle: func [ num [string!] /local ob ][ either admin? user [ ob: get in id to-word num ob/on ][ ob: get in id to-word num ob/off ] ]
|
|
|
|
|
Logged
|
|
|
|
|
Smokey
|
I gave it a try and worked with the script for a few hours more to see if I could get it working but finally ended up using files to hold the html and some if statements. After this long and no success with the first approach it was time to try something new. I needed something to start working.  Although I am not sure, I think the inability of my trial and error using your suggestion may have been related to the nested objects or some requirement or limitation of a vanilla dynasnip (or vanilla) that I don't understand fully. The .r file that all this was going into is being called as a script and the whole thing being an object to vanilla. EG: after the header it begins with handle: make object! [.. with everything else as a part of the object. I am glad though that I was able to get the results I was hoping for by an alternate method. It's a bit messy right now though in that I have two separate files for each 'num' -- one file with the "on" html and one with the "off" html. I imagine the overhead for the file access must be slower than if I could get the self contained block working. The big thing is that I finally got some positive movement. While trying to integrate your approach into the code I was able to produce some non-fatal errors, where vanilla was saying it was having problems loading the dynasnip. I plugged away at it some but was alternating back and forth from that message to server errors before I finally decided that I had to try a new approach. It would still be very interesting if Carl could explain why what I've been trying is apparently so difficult or impossible. Granted I have not tried the same sort of thing with a 'normal' rebol program.. I might fiddle with that when I have time to see if it works with vanilla out of the picture. Smokey
|
|
|
|
|
Logged
|
|
|
|
|
Graham
|
I tested the code before I uploaded it .. so it does work.
There must be some other conditions at work here. I have done quite a fair bit of work on vanilla in the past and don't recall off hand any show stoppers like this.
|
|
|
|
|
Logged
|
|
|
|
|
Smokey
|
I'll send you what I have if you like. Maybe in complete context you'll see something that I have not been able to properly communicate.
Basically I borrowed from the logio.r script to decide if master was logged in or not, I didn't see or who of another way to determine this.
From there what I am doing is making it so with master logged in the adsense code does not get inserted into the vanilla-template.
Just something I got in the habit of doing with other sites I run so my frequent visits do not get counted as adsense impressions (at least after I log in).
Smokey
|
|
|
|
|
Logged
|
|
|
|
|
|
|
Smokey
|
I'll do that. Last time I checked the mailing list it seemed dated, stalled like vanilla. Things may start buzzing again as a REBOL 3.0 release draws closer.
Thank you for the help and suggestions.
|
|
|
|
|
Logged
|
|
|
|
|
Smokey
|
..list appears to be stalled. I suppose it's the best chance for active vanilla discussions, but does anyone happen to know any other vanilla resource that shows signs of life?
|
|
|
|
|
Logged
|
|
|
|
|
|
Pages: [1]
|
|
|
 |
News: 01-09-08 Alpha version of REBOL 3 has been released!
2311 Posts in 595 Topics by 4143 Members
Latest Member: pobbennaFex
|