auto id's for vid objects
[1/9] from: inetw3::mindspring::com at: 15-Feb-2004 21:34
Hey (smaller&smaller)List,
x: {button "one" button "two" text "browser"}
x marked strings are changed when
there found like this; {button one text "browser" button two}
but not when found like this;
{button one button two text "browser" }
notice the repeat "button" strings one
after another.
{button one button two}
code: -------------------------------------------
x: {button "one" button "two" text "browser"}
{then try this: button "one" text "browser" button "two"}
button_count: 0
txt_count: 0
btn: to-string reduce [ to-set-word 'id ": " to-set-word 'btn]
txt: to-string reduce [ to-set-word 'id ": " to-set-word 'txt]
parse x [any [
to "button" mark:(
remove/part mark 6 insert mark reduce [btn button_count: button_count + 1
:
{ }"button"])
:mark
to "text" mark:(
remove/part mark 4 insert mark reduce [txt txt_count: txt_count + 1
:
{ }"text"])
:mark
]skip
]
Does not *any and *skip find all occurrences of the marked string?
Or do I have to use a while loop?
[2/9] from: tomc:darkwing:uoregon at: 15-Feb-2004 20:57
Howdy,
when using mark: (...) :mark
it only makes sense if you are changing 'mark in the paren section
otherwise the :mark can be ommited and the effect will be the same.
your any [to "button" ... to "text" ...]
is doing what you asked , not what you want
to "button" is skipping to the first button doing its thing OK
then to "text"
skipping over the secong button because the rule is asking it to skip till
it finds "text" which it slso does OK then it is back too the top of the
'any and since there ate no more "button" after the "text" it is done.
my guess is you want to wrap the to "button" ... rule in its own 'any
but be careful as nested anys are awfully easy to please (infinite loops)
something like this will work as long as all your widget types are
clustered together
rule: [
any[
to "button" mark:
(insert :mark reduce [btn button_count: button_count + 1":"{ }]
mark: skip mark 16):mark
]
any[
to "text" mark:
(insert :mark reduce [txt txt_count: txt_count + 1":"{ }]
mark: skip mark 14) :mark
]
]
HTH
On Sun, 15 Feb 2004, iNetW3 wrote:
[3/9] from: inetw3:mindspring at: 16-Feb-2004 1:15
Hi Tom,
Thanks for the quick help, and i realize know
where i went wrong.
drop the *skip.....
I did, and the code worked like a charm.
I dropped the *remove/part also.
thanks.
[4/9] from: inetw3:mindspring at: 16-Feb-2004 22:30
Hey ML,
I spoke too soon.
If any know how to make this code work,
or demo some code that does the same thing,
it would be well appreciated.
code: -------------------------------------------
x: {button "one" button "two" text "browser"}
{then try this: button "one" text "browser" button "two"}
button_count: 0
txt_count: 0
btn: to-string reduce [ to-set-word 'id ": " to-set-word 'btn]
txt: to-string reduce [ to-set-word 'id ": " to-set-word 'txt]
parse x [any [
to "button" mark:(
remove/part mark 6 insert mark reduce [btn button_count: button_count + 1
":"{ }"button"])
:mark
to "text" mark:(
remove/part mark 4 insert mark reduce [txt txt_count: txt_count + 1
":"{ }"text"])
:mark
]
]
[5/9] from: brett:codeconscious at: 17-Feb-2004 16:54
> If any know how to make this code work,
> or demo some code that does the same thing,
> it would be well appreciated.
What are you trying to achieve?
For example, I see that you are doing string manipulations on what might be
VID code but then you don't Load it at all - leaving it as a string.
Also the special sequence rule of repeated button is not clear, can you
provide some more explanation?
Brett.
[6/9] from: tomc:darkwing:uoregon at: 17-Feb-2004 0:38
maybe if this is not what you expect you could give examples of what
output you expect from your input.
this is the same rule as I sent yesterday with the resy of the program
wrapped around it.
rebol[]
x: {button "one" button "two" text "browser"}
y: {then try this: button "one" text "browser" button "two"}
button_count: 0
txt_count: 0
btn: to-string reduce [to-set-word 'id ": " to-set-word 'btn]
txt: to-string reduce [to-set-word 'id ": " to-set-word 'txt]
rule: [
any[
to "button" mark:
(insert :mark reduce [btn button_count: button_count + 1":"{ }]
mark: skip mark 16):mark
]
any[
to "text" mark:
(insert :mark reduce [txt txt_count: txt_count + 1":"{ }]
mark: skip mark 14) :mark
]
]
parse/all x rule
probe x
button_count: txt_count: 0
parse/all y rule
probe y
halt
On Mon, 16 Feb 2004, iNetW3 wrote:
[7/9] from: ingo:2b1 at: 17-Feb-2004 10:34
Hi iNetW3,
maybe the following does what you want, but beware: it's not elegant, I
just parse the whole string for all buttons first, and then restart to
find all texts.
x: {button "one" button "two" text "browser"}
;x: {button "one" text "browser" button "two"}
button_count: 0
txt_count: 0
btn: to-string reduce [ to-set-word 'id ": " to-set-word 'btn]
txt: to-string reduce [ to-set-word 'id ": " to-set-word 'txt]
parse x [
home-mark:
any [
to "button" mark:(
remove/part mark 6 insert mark reduce [btn button_count:
button_count + 1
":"{ }"button"])
:mark 12 skip
]
:home-mark
any [
to "text" mark:(
remove/part mark 4 insert mark reduce [txt txt_count: txt_count + 1
":"{ }"text"])
:mark 12 skip
]
]
I hope that helps,
Ingo
iNetW3 wrote:
[8/9] from: inetw3:mindspring at: 17-Feb-2004 9:23
Thanks Tom, Brett, Ingo,
I have a browser/viewer that reads HTML and views
it as VID.
The code in question is an update of an auto-identifier
script that gives general ID references to HTML-to-VID
code. After the HTML is loaded, the ID's are added to
the HTML and VID in block form which then is layed out
and viewed
These variable ID's allow the HTML and viewed VID to be
updated/changed as soon as it's created in the browser
even if no ID's are found in the HTML tag. It's a part of the
browser's DOM.
The DOM and HTML are changed with either in-line
rebol/script, or xmlnode parsing.
.....<p id=p1 bgcolor=red color=blue
onclick="p1/text({Now i'm changed}).show.p1">
watch me change</p>
<p id=p1 bgcolor=red color=blue
onclick="getattribute.{p1}.setnodevalue.{Now i'm changed}
</p>
So thanks for helping with this simple but testy piece of code,
it either would endless-loop or not catch all the objects.
[9/9] from: inetw3:mindspring at: 17-Feb-2004 9:27
By the way, Thanks Ingo, you got it right.
I can stop hitting my head now.