Could anyone explain why Red behaves like this:
Red []
csvtext: "first,second,third"
b: split csvtext ","
print b/1
print b/2
repeat i 3 [prin i print b/i]
first
second
1none
2none
3none
In the last line, i
is incremented as an integer, but would need a to integer!
conversion to work as a proper index.
integer!
): bl: [11 22 33 44] bl/2; 22
word!
- here the Red will look for given word and returns next element: bl: [a 1 b 2] bl/a; 1
get-word!
- here it will evaluate it (e.g. into number): bl: [11 22 33 44] ind: 1 bl/:ind
paren!
- it will evaluate it but you can look for anything: bl: [1.2 a 3.14 b] bl/(1.2); a
t
. E.g. here t
-s position is changed. You might do it with react
I suppose.view [
p: tab-panel [
"size" [
x: field "200"
y: field "200"
button "set size" [
b/size/x: x/data
b/size/y: y/data
t/offset/x: b/offset/x + b/size/x + 10
]
]
"image" [
b: base 50x50
t: text "some text"
]
]
]
@Ungaretti If you haven't used this feature you may forget about it. The Red has many types for key-value things map!
for associative arrays, and object!
for immutable (keys) container. Not everyone used Lua to know that feature.
@toomasv It is easy but I have to use it many times. I have many 1 more tab and there might be more elements in each tab. It is not a problem but I am just looking for conveniences as vid
taught me.
view/no-wait [
p: tab-panel [
"size" [
x: field "200"
y: field "200"
button "set size" [
b/size/x: x/data
b/size/y: y/data
]
]
"image" [
b: base 50x50
t: text "some text"
]
]
]
react [t/offset/x: b/offset/x + b/size/x + 10]
do-events
@nedzadarek I'm curious if this might do the automatization?
view [
p: tab-panel [
"size" [
x: field "200"
y: field "200"
button "set size" [
b/size/x: x/data
b/size/y: y/data
]
]
"image" [
b: base 50x50
t: text "some text"
]
]
do [
foreach pan pane/1/pane [
foreach [bas txt] pan/pane [
if all [bas/type = 'base txt/type = 'text] [
react [txt/offset/x: bas/offset/x + bas/size/x + 10]
]
]
]
]
]
Of course, this is only for consecutive base
and text
faces. But still?
I'm resuming my documentation of Red at helpin.red , and working on the parse chapters. There is a lot to be done there.
Since I can't find information about many keywords, I'm learning by trial-and-error, but I stumble on some inexplicable behaviours, for example: Red blog says that break
should "break out of a matching loop, returning success". I try it but it returns false (failure?):
block: [1 2 3 4]
print parse block [
integer! (print 1)
integer! (print 2)
break
integer! (print 3)
integer! (print 4)
]
1
2
false
It seems to me as the same as ´fail´ or ´reject´. How come?
I think I have checked all the available online documentation. Is there any hidden or unknown document that explain parse's keywords?
break
breaks the outer loop, that's it.
any
, some
and while
. That is the information I was missing. I thought of a "matching loop" as the parsing itself. It is a matching loop after all. Hence my surprise when a parse with break
returned false.
layout [tb: box wrap 10x1000 ". . . . . . . . ."]
size-text tb
== 6x171
== 51x15