World: r3wp
[Core] Discuss core issues
older newer | first last |
Terry 8-Jan-2010 [15414] | so.. the result is a button that alerts.. \'hello\'s {Worlds \'; ...and prints... 'and {so "on'; after the button |
Steeve 8-Jan-2010 [15415] | I see nothing you can't do with rebol, so what ? |
Terry 8-Jan-2010 [15416x2] | um.. i don't think that was the point |
Show me the 'simpler way' | |
Steeve 8-Jan-2010 [15418x2] | I just can't figure the exact string output you want. |
don't mess it with escaping characters or comments. | |
Terry 8-Jan-2010 [15420] | no comments.. that's functioning php.. and if you don't escape it, it doesn't function as JS |
Gregg 8-Jan-2010 [15421] | There has been talk in the past of including a substituion function, REWORD being the R3 func for it. In R2 we have build-markup, which shouldn't be hard to hack, but I don't know of a version that anyone has done for a given substitution syntax. |
Steeve 8-Jan-2010 [15422] | Terry, i don't think your output must be { \'hello\'s {Worlds \'; ...and prints... 'and {so "on'; } And yet, that's what you show us actually |
Gregg 8-Jan-2010 [15423x2] | build: func [ {Return text replacing $tags with their evaluated results.} content [string! file! url!] /quiet "Do not show errors in the output." /local out eval value ][ content: either string? content [copy content] [read content] out: make string! 126 eval: func [val /local tmp] [ either error? set/any 'tmp try [do val] [ if not quiet [ tmp: disarm :tmp append out reform ["***ERROR" tmp/id "in:" val] ] ] [ if not unset? get/any 'tmp [append out :tmp] ] ] parse/all content [ any [ end break | " $" [copy value to " " | copy value to end] (eval value) | copy value [to " $" | to end] (append out value) ] ] out ] |
Now, that's norribly naive, and doesn't work because of that. e.g. it needs a space before the $ marker, so a var at the beginning of the text gets missed. | |
Steeve 8-Jan-2010 [15425] | yes seems a little messy Greg ;-) |
Gregg 8-Jan-2010 [15426] | Well, what do you in five minutes? ;-) |
Terry 8-Jan-2010 [15427] | Spend 6 :) |
Gregg 8-Jan-2010 [15428x2] | Needs a different name too, as Ladislav has a nice BUILD func that works on blocks. |
I need a spec first. ;-) | |
Terry 8-Jan-2010 [15430x3] | Although, i would be impressed if it didn't choke while trying to escape stuff. |
If it was a smple matter of replacing variables with values.. i have some °7° code that does that. The problem is well formed javascript to send back to the DOM. | |
via AJAX | |
Steeve 8-Jan-2010 [15433] | I say it again, you didn't give us the real output. Doing some assumptions, i got this. varA: { \'hello\'s ^{Worlds \';} varB: { 'and ^{so "on'; } print rejoin [{<button onclick="alert('} varA {');">CLICK ME</button>} varB ] <button onclick="alert(' \'hello\'s {Worlds \';');">CLICK ME</button> 'and {so "on'; So where is the burden ? i don't see one |
Terry 9-Jan-2010 [15434x2] | Should probably put this in rant.. but just spent the last hour wondering why my function wasn't working result: sofp 'firstname' the solution? change the single quotes to double.. aye carumba |
Steeve, it's cumbersome.. I spend more time joining and escaping than anything else. | |
Henrik 9-Jan-2010 [15436x2] | From all this, the easiest way would be to produce a dialect that does its own escaping, so you don't have to write JS at all. |
rephrasing that: not "easiest way", but easiest to use in the end. | |
Janko 9-Jan-2010 [15438] | as anyone tried to run cheyenne or rebol on sheevaplug ( http://www.globalscaletechnologies.com/t-sheevaplugdetails.aspx ) |
WuJian 9-Jan-2010 [15439] | Good stufff |
Henrik 13-Jan-2010 [15440] | does anyone have a rebol based bracket checking tool? preferrably something that can be integrated into a diagnostic tool. |
Steeve 13-Jan-2010 [15441] | hey ? |
WuJian 14-Jan-2010 [15442] | e ) |
BenBran 14-Jan-2010 [15443] | I have the code: case equal? length? find myLine "text" 4 [...] It fails on ==none I can do it in more lines of code but was wondering the shortest way to get past this. Any suggestions? tia |
Graham 14-Jan-2010 [15444] | what happens if you don't find the text ?? It gives none |
BenBran 14-Jan-2010 [15445x2] | yes that is correct |
I'd like to ignore if it gets 'none' | |
Graham 14-Jan-2010 [15447] | so you have multiple conditions but you're only checking for one |
BenBran 14-Jan-2010 [15448x2] | yes have numerouse cases |
numerous | |
Graham 14-Jan-2010 [15450x2] | I mean you have mulitiple outcomes in that code you have written but you're only checking for one |
if mark: find myline "text" [ ... ] | |
BenBran 14-Jan-2010 [15452] | I don't follow what you mean. |
Graham 14-Jan-2010 [15453] | if all [ mark: find myline "text" 4 = length? mark ][ case [ ] ] |
Maxim 14-Jan-2010 [15454] | the if isn't required here. |
Graham 14-Jan-2010 [15455] | true |
Maxim 14-Jan-2010 [15456] | this is exactly the same: all [ mark: find myline "text" 4 = length? mark case [ ] ] |
Graham 14-Jan-2010 [15457] | all [ mark: find myline "text" 4 = length? mark case [ ] ] |
Maxim 14-Jan-2010 [15458] | hehe |
Graham 14-Jan-2010 [15459] | snap |
BenBran 14-Jan-2010 [15460] | the power of rebol will never cease to amaze me. |
Maxim 14-Jan-2010 [15461] | after a decade I still find new language tricks. I call it the "temporary newbie moment" phenomenon... I've never had these moments in other languages. its like finding a new trick to make your lego stuff stronger while having the same shape ;-) |
Steeve 15-Jan-2010 [15462] | case [ not mark: find myline "text" [none] 4 <> length? mark [none] ... ] |
Graham 15-Jan-2010 [15463] | not so easily read ;) |
older newer | first last |