stylize port, but it was never merged and it likely very out of date now.view [style f: field-style-func] ...system/view/VID/styles, and then use it in different layouts.Red[
needs: view
]
extend system/view/VID/styles [
iosBtn: [
default-actor: on-down
template: [
type: 'base
size: 48x25
color: red
data: 0
actors: [
on-create: func [face][
face/extra: object [
fColor: snow
bColor: face/color
bSize: face/size
radius: to-integer bSize/y / 2
lCenter: as-pair radius radius
rCenter: as-pair bSize/x - radius radius
;--make default image (off)
blk: compose [
pen gray
line-join round
fill-pen fColor box 0x0 (bSize) (radius)
fill-pen fColor circle (lCenter) (radius - 1)
]
bDraw: draw bSize blk ;--call draw method
bClick: func [face][
either face/data = 0 [
face/data: 1 blk/6: bColor blk/14: rCenter
][face/data: 0 blk/6: fColor blk/14: lCenter]
;--update face image with draw
bDraw: draw bSize blk
face/image: face/extra/bDraw
]
];--end of object
];--end of create function
;--update face to off after creation
on-created: func [face][
face/color: face/extra/fColor
face/data: 0
face/image: face/extra/bDraw
]
];--end of actors
];--end of template
];--end of style
];--end of extend
;--for tests
comment [
view [
iosBtn red 48x24 [face/extra/bclick face]
iosBtn green 48x24 [face/extra/bclick face]
iosBtn blue 48x24 [face/extra/bclick face]
]
]%stretchy.red if I move a loose face and then resize the window it will re-assume its previous offset and size. How can I avoid this ?react? may help you retrieve relation block.loosecommon-style: [
; define your style or styles here
]
layout1: [
; blah blah
]
layout2: [
; whatever
]
insert layout1 common-style
insert layout2 common-style
; ...
either some-condition [
view layout layout1
][view layout layout2]system/view/VID/styles/new-style: [template: [type: 'base size: 100x25 color: blue]] layout1: [base beige new-style] layout2: [new-style base beige] show: func [cond][view either cond [layout1][layout2]] show true show false
show thoughsystem/words/showif show was redefined in some local context.Red [needs 'web] Is it possible? I tried but it didn't work. Is there some library that I don't know of?[new code] from experience and do ing it when needed. That's autonomy, I guess.'web in there because the prompt asked for a web app... [t/data: load ll] load dir and load list-dir with no avail.view [t: text-list data [] button [t/data: read %.]]
a: [1] message: object [ foo: 1 flag: either (not empty? a) [true] [ false] ; some complex condition ] to-json message
But I for passing it to function I need to convert it to map!:
`make-request syntax.set 'make-request func [ "Frontend for SEND-REQUEST using new format" data [block! object!] "Dialect block or request object" ][ if block? data [data: to-request data] send-request/data/with/verbose ; verbose is for testing data/url data/method data/data data/headers ]
make-request/url/data to-url some_url 'POST message
make-request is a front-end for send-request that uses dialect instead of ~10 refinements. So the correct syntax is:make-request [POST http://some.url data]
%client-tools.red so both make-request and send-request show work now. It's mostly abandonware as I was focusing on HTTP scheme for the IO branch which is superior to the send-request, however, IO branch is still not merged into master and I really don't know if my HTTP scheme is going to be used or not. make/send-request, so I can fix it.collect/keep like:data: [
aaa: [
foo: [test]
customers: []
]
bbb: [
bar: [some-text]
bar2: []
]
ccc: [
baz: []
]
]
gen-ui: function [] [
ui-items: collect [
foreach [key value] data [
keep compose/deep [
group-box (to-string key) [
; I want to iterate value with foreach here and add it to UI (with keep)
]
]
]
]
append ppp/pane layout/only ui-items
]
view [
size 800x600
ppp: panel 700x500 [below]
do [
gen-ui
]
]below in ppp VID is useless, as it is wasted already before layout is added to panel. Better maybe get rid of doand gen-ui, collect your items in (global) ui-items, insert below and set it directly as panel VID. Alternatively keep it as it is and insert below in gen-ui into ui-items before appending. Also you might consider using compose/only instead of compose/deep.collect but it's also do not work:ui-items: collect [
foreach [key value] data [
keep compose [
group-box (to-string key) 100x100 [
; foreach a [] [ ] ;
]
]
keep 'return
]
]
view [
size 900x600
ppp: panel ui-items
]ui-items: collect [ foreach [key value] data [ keep compose/only [ group-box (to-string key) ( collect [ foreach [k v] value [ keep 'text keep form k keep 'text keep mold v keep 'return ] ] ) ] ] ] insert ui-items 'below
keep compose [text (form k) text (mold v) return] index? of system/view/screens/1/pane, or system/console/gui?quit, use unviewsystem/console/gui? is always true, system/view/screens/1/pane does not seem "bullet-proof".unview/all ?do returns the last evaluation result from the script, you can check iteither early ['bad-result][do some code... 'good-result]break , return , halt , quit etc. that skips everything and exits.result: ...context for data you don't exportcontexts :) so the problem is now on "A". How can it distinguish if it was started from Red GUI console PROMPT and use halt or if not and use quit ?quit or halt then it must be a binary, or you must be the sole user of this script, otherwise you're creating headache for whoever runs ithalt, primarily a debugging function? What are you even trying to achieve? attempt [unset? get 'system/view/VID]system/view/VIDis not unsetwhether I run my script from the >> prompt or from gui-console.exequitquit a script started from the GUI console prompt it quits also the GUI console.area-plus but have trouble with this situation. That said I think that even "inventing various theoretical cases" could be quite useful since you do not know what will happen in the future.quit then. Or what's stopping you from leaving your script using normal control flow like if/either/unview/etc or using exceptions like catch/throw.if system/build/date < 26-11-2022 [alert "A more recent version of Red is required !" quit ]
either system/build/date < 26-11-2022 [alert "A more recent version of Red is required !"] [
normal execution...
]error! because of the missing feature or whatever the case, and then ? I can catch the error and then ?alert when closed resumes evaluation in the consolealert "abc" in consolegui-console-ctx/terminal context when it's shown, so you can compare it between GUI console run and shell run, and find values there that would hint you that it's runninggui-console-ctx/terminal ?? halt ?write %scriptA.red {
Red []
if unset? do %scriptB.red [halt]
; anything else here...
}
write %scriptB.red {
Red []
if system/build/date < 26-11-2024 [
alert "A more recent version of Red is required !" either system/options/script [quit][halt]
]
; anything else here...
}
do %scriptA.redif but I could hide it inside a function.--catch (an explicit intent *not* to close the console)>> ? system/options/script SYSTEM/OPTIONS/SCRIPT is a file! value: %/d/devel/red/init.red
catch and throw is by design solution to handle non local control flow ;)catch [if 'error [alert "message" throw 'oops]]button "Export" [
f: request-file/file %Tree.png
img: to-image canvas
save f img
]base object to paint on?img: draw canvas/size * 10 compose/only [scale 10.0 10.0 (canvas/draw)]]data during generation?face not exists at this moment, but do not how to access to it (if possible):ui-items: collect [
keep 'drop-down []
(
foreach el [aa bb cc] [
append face/data mold el
]
)
]
view [
size 1200x600
ppp: panel ui-items
] view [drop-down data [stuff...]]face in my exampleui-items: collect [
keep 'drop-down data compose [ ( "sdf" ) ]
]
view [
size 1200x600
ppp: panel ui-items
]datamy-drop-down: ui-items is just a blockto integer! #"c"ui-items: collect [
foreach key keys-of #(aaa: 1 bbb: 2 ccc: 3) [
keep compose/deep [
text (to-string key) return
pad 0x-10
(to set-word! rejoin ['ppp1- key]) panel (first random [red green olive blue]) [
(
foreach k [foo bar baz] [
keep button (to-string k)
]
)
]
]
keep 'return
]
]
view [
size 900x600
ppp: panel ui-items
]collect works... maybe you should build your data using classic append first. But to fix your code, in the last paren in the compose/deep block, use this instead:collect [
foreach k [foo bar baz] [
keep reduce ['button to string! k]
]
]button has no valueui-items: collect [
foreach key keys-of #(aaa: 1 bbb: 2 ccc: 3) [
keep compose [
text (to string! key) return
pad 0x-10
(to set-word! rejoin ['ppp1- key]) panel (first random [red green olive blue])
]
;; now build (collect) the panel's block and keep it...
keep/only collect [
foreach k [foo bar baz] [
keep compose [button (to string! k)]
]
]
keep 'return
]
]field and it's very strange that button change text, but field not. It's look like it's binded with last value:ui-items: collect [
foreach key keys-of #(aaa: 1 bbb: 2 ccc: 3) [
keep compose [
text (to string! key) return
pad 0x-10
(to set-word! rejoin ['ppp1- key]) panel (first random [red green olive blue])
]
;; now build (collect) the panel's block and keep it...
keep/only collect [
foreach k [foo bar baz] [
keep reduce ['button to string! k]
keep reduce ['field 'with [text: to-string k ]] ; here
]
]
keep 'return
]
]
view [
size 900x600
ppp: panel ui-items
]baz in every field.with should be used in another way...probe as it was recommended above, maybe you should use ? ui-items and see, what code you have!keep compose/deep [field with [text: (to-string k) ]]
keep reduce ['field 'with [text: to-string k ]] ; here
ui-items when it's completek from the foreach was local to the foreach code block, how it is in Rebol, he would not be so surprised.[foo bar baz] placed outside in word and I need way to modify their from field.copy here is break link to original datafield cannot modify a block, only textforeach-faceon-change to backpropagate changeshey there,probe system/script/args "'hey' 'there'"
probe system/script/args "hey there"
system/script/args and system/script/options. But don't worry, you're not alone, we all miss it! Red is still in alpha, it's just 12 years old language, so this will work eventually.main was preprocessed for you by C runtime (which is inconsistent with Windows' own command line processing by the way).view [radio on-change [face/data: not face/data] ]
system/options/args works like I expected so I went with that insteadface/text is none? ui-items: collect [ keep 'button "foo" keep/only [print face/text] ] view [ panel: panel ui-items ]
ui-items: collect [ keep 'button "foo" keep 'extra [ section: "My Foo" ] keep/only [print face/extra/section] ] view [ panel: panel ui-items ]
probe mantext there is emptyprobe ui-items[button [probe face]]keep :)keep should be? keep 'button "foo" keep/only [print face/text]ui-items: collect [ keep 'button keep "foo" keep/only [probe face/text] ] view [ panel: panel ui-items ]
help for dialects. No conclusions, and few experiments. For now, the docs are your best bet:collect. New problem. Can't understand how to attach extra to panel:ui-items: collect [
keep 'panel keep 'red [] keep 'extra [ section: "My Foo" ]
]
view [
panel: panel ui-items
]
probe ui-itemsui-items: collect [
keep 'panel keep 'red [] keep/only collect [ keep 'extra [ section: "My Foo" ] ]
]
view [
panel: panel ui-items
]
probe ui-itemskeep the blocks:>> ui-items: collect [ [ keep 'panel keep 'red [] keep 'extra [ section: "My Foo" ] [ ] == [panel red extra]
>> ui-items: collect [keep 'panel keep 'red keep/only [] keep 'extra keep/only [section: "My Foo"]] == [panel red [] extra [section: "My Foo"]]
>> ui-items: collect [keep [panel red [] extra [section: "My Foo"]]] == [panel red [] extra [section: "My Foo"]]
compose:>> ui-items: collect [keep compose/deep [panel (color) [] extra [section: (name)]]] == [panel red [] extra [section: "My Foo"]]
keep each value separatelycall-grow-rules-settings-ui: function [] [
grow-rules-settings-ui: collect [
foreach key keys-of #(a: 1 b: 2) [
keep compose [ ;
h5 (to-string key) return
]
]
]
append grow-rules-settings-ui-panel/pane grow-rules-settings-ui
]
view [
size 900x600
grow-rules-settings-ui-panel: panel []
button "add" [ call-grow-rules-settings-ui ]
](redview:297882): GLib-GObject-CRITICAL **: 15:58:04.951: g_object_set_qdata: assertion 'G_IS_OBJECT (object)' failed
layout/only append grow-rules-settings-ui-panel/pane layout/only grow-rules-settings-ui
increase is enough. If it's global that may not be precise enough.increase reads as something that is modifying some value to me.Incr (which I still want) could mod or not, based on the arg being literal or not. Same for increase.{'args': {},
'data': '',
'files': {'upload_image': 'data:application/octet-stream;base64, **base64 string here**},
'headers': {'Accept': '*/*',
'Content-Length': '9781',
'Content-Type': 'multipart/form-data; '
'boundary=xxxxxx,
}; img is enbased image data
r: write/info http://httpbin.org/post compose/deep [
post [
Content-Type: "multipart/form-data"
]
(rejoin ["{" {"files": } "{" {"upload_image": "data:octet-stream;base64,} img {"} "}}"])
]>> r: write/info http://httpbin.org/post [POST [Content-Type: "multipart/form-data; boundary=CUT"] {^/^/--CUT^/Content-Disposition: form-data; name="file1"; filename="file1"^/^/text1^/^/--CUT^/Content-Disposition: form-data; name="file2"; filename="file2"^/^/text2^/--CUT--^/}]== [200 #(
Connection: "keep-alive"
Date: "Tue, 24 Jan 2023 10:05:16 GMT"
...
>> probe load-json last r ()
#(
args: #()
data: ""
files: #(
file1: "text1^/"
file2: "text2"
)
form: #()
headers: #(
Accept: "*/*"
Content-Length: "163"
Content-Type: "multipart/form-data; boundary=CUT; Charset=UTF-8"
Host: "httpbin.org"
User-Agent: {Mozilla/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5)}
X-Amzn-Trace-Id: "Root=1-63cfad5c-1644b1c82ceeb6d36615a9c2"
)
json: none
origin: "157.230.123.237"
url: "http://httpbin.org/post"
)ui-items: collect [
foreach key [aa bb cc dd ee ff gg hh] [
keep compose [
panel (first random [red green olive blue brown]) 400x300
]
keep/only collect [
keep 'h5 keep mold key
]
keep 'return
]
]
view [
size 500x420
panel [
scroller 16x400 [
face/data: min .75 face/data
ui-panel/offset/y: to integer! negate 800 * face/data
]
on-created [face/selected: 25%]
ui-panel: panel ui-items
]
]with for scroller 0.6 of face size make it 90% of blue panel? I expected that 0.9 scale should make 90%view [
size 500x420
panel blue [
scroller [
face/data: min .75 face/data
ui-panel/offset/y: to integer! negate 800 * face/data
] with [react/later [size: to-pair compose [ 20 (parent/size/x * 0.6) ] ]]
on-created [face/selected: 25%]
ui-panel: panel ui-items
]
]ui-items: collect [
foreach key [aa bb cc dd ee ff gg hh] [
keep compose [
panel (first random [red green olive blue brown]) 400x300
]
keep/only collect [
keep 'h5 keep mold key
]
keep 'return
]
]
view [
size 500x420
scrollpanel blue [
ui-panel: panel ui-items
]
]ui-items of course)foo: function [] [
ui-items: collect [
foreach key [aa bb cc dd ee ff gg hh] [
keep compose [
panel (first random [red green olive blue brown]) 400x300
]
keep/only collect [
keep 'h5 keep mold key
]
keep 'return
]
]
clear ppp/pane
append ppp/pane ui-items ; ?
]
view [
size 500x420
button "load" [foo]
ppp: scrollpanel []
]>> view [ [ size 500x420 [ button "load" [foo] [ ppp: scrollpanel ; also I tried scrollpanel [] [ [ [ ] *** Script Error: move does not allow none! for its origin argument *** Where: / *** Near : move find/same pane hsc tail pane *** Stack: view do-events do-actor do-safe error? foo on-face-deep-change* check-pane *** Near: [[panel/pane] check-pane panel] *** Script Error: move does not allow none! for its origin argument *** Where: move *** Near : move find/same pane hsc tail pane *** Stack: view do-events do-actor do-safe error? foo on-face-deep-change* check-pane *** Near: [[panel/pane] check-pane panel] *** Script Error: move does not allow none! for its origin argument *** Where: move *** Near : move find/same pane hsc tail pane *** Stack: view do-events do-actor do-safe error? foo on-face-deep-change* check-pane *** Near: [[panel/pane] check-pane panel] *** Script Error: none! type is not allowed here
foo: function [] [
ui-items: collect [
foreach key [aa bb cc dd ee ff gg hh] [
keep compose [
panel (first random [red green olive blue brown]) 400x300
]
keep/only collect [
keep 'h5 keep mold key
]
keep 'return
]
]
clear ppp/pane
append ppp/pane layout/only ui-items ;
]
view [
size 500x420
button "load" [foo]
ppp: scrollpanel []
]foo: function [] [
ui-items: collect [
foreach key [aa bb cc dd ee ff gg hh] [
keep compose [
panel (first random [red green olive blue brown]) 400x300
]
keep/only collect [
keep 'h5 keep mold key
]
keep 'return
]
]
clear ppp/pane
append ppp/pane layout/only ui-items ;
]
view [
; size 500x420
button "load" [foo]
ppp: scrollpanel []
]*** Script Error: f2s: needs a value *** Where: f2s *** Near : f2s: :face-to-screen ofs: f2s ev/offset *** Stack: ask ask do-events do-safe *** Script Error: f2s: needs a value *** Where: f2s *** Near : f2s: :face-to-screen ofs: f2s ev/offset *** Stack: ask ask do-events do-safe *** Script Error: f2s: needs a value
%relativity.red>>
>> foo: function [] [
[
[ ui-items: collect [
[ foreach key [aa bb cc dd ee ff gg hh] [
[
[ keep compose [
[ panel (first random [red green olive blue brown]) 400x300
[ ]
[
[ keep/only collect [
[ keep 'h5 keep mold key
[ ]
[
[ keep 'return
[
[ ]
[ ]
[
[ clear ppp/pane
[ append ppp/pane layout/only ui-items ;
[ ]
== func [/local ui-items key][
ui-items: collect [
foreach key [aa bb cc dd ee ff gg hh] [
...
>>
>>
>>
>> view [
[ ; size 500x420
[ button "load" [foo]
[ ppp: scrollpanel
[
[
[ ]
*** Script Error: quietly has no value
*** Where: +
*** Near :
*** Stack: view layout context react update-total
>>
*** Script Error: none! type is not allowed here
*** Where: op
*** Near : xy: xy op fa/offset fa: fa/parent #assert
*** Stack: ask ask do-events do-safe within? translate
*** Script Error: none! type is not allowed here
*** Where: opdo load app/source/scrollpanel.red before pasting code to console (maybe I should run other imports explicitly?) do load %/d/code/app/source/scrollpanel.red
do load %/d/code/app/source/shallow-trace.red
do load %/d/code/app/source/do-atomic.red
do load %/d/code/app/source/do-unseen.red
do load %/d/code/app/source/relativity.red
do load %/d/code/app/source/setters.red
do load %/d/code/app/source/show-trace.red
foo: function [] [
ui-items: collect [
foreach key [aa bb cc dd ee ff gg hh] [
keep compose [
panel (first random [red green olive blue brown]) 400x300
]
keep/only collect [
keep 'h5 keep mold key
]
keep 'return
]
]
clear ppp/pane
append ppp/pane layout/only ui-items ;
]
view [
; size 500x420
button "load" [foo]
ppp: scrollpanel []
]doquietly macrocd %/d/red-common/ do %/d/red-common/scrollpanel.red view [scrollpanel 100x100 [base 200x200]]
cd#include %/d/code/app/source/do-atomic.red #include %/d/code/app/source/scrollpanel.red view [scrollpanel 100x100 [base 200x200]]
pos: 0x0 view [ ppp: scrollpanel green [] button "add" [ append ppp/pane layout/only [ at (pos: pos + 0x30) button "test" ] ] ]
Red []
do %scrollpanel.red
pos: 20x0
view [
scrollpanel green [
ppp: panel cyan [] react [
all [
f1: first face/pane
f2: last face/pane
face/size: f1/offset + f2/offset + f2/size
]
]
]
button "add" focus [
append ppp/pane layout/only [
at (pos: pos + 0x30) button "test"
]
]
]scrollpanel. >> do %/d/123/app.red
do/args %red.r "-c -e %/d/123/app.red"
*** Script Error: updates has no value *** Where: in *** Near : set-quiet in panel updates 0 *** Stack: view do-events do-actor do-safe error? on-face-deep-change* check-pane update-total *** Near: [[panel/pane] check-pane panel] *** Script Error: updates has no value *** Where: in *** Near : *** Stack: view do-events do-actor do-safe error? on-face-deep-change* update-total *** Near: [[panel/updates] update-total panel]
Red [] #include %/d/123/do-atomic.red #include %/d/123/scrollpanel.red #include %/d/123/do-unseen.red #include %/d/123/relativity.red #include %/d/123/setters.red pos: 0x0 view [ ppp: scrollpanel green [] button "add" [ append ppp/pane layout/only [ at (pos: pos + 0x30) button "test" ] ] ]
Red [needs 'view] f: function['way][ compose/deep[ radio[(to-set-word way) 1] gg: field "field" ] ] view f myway
gg gets collected by function. Red [needs 'view] f: function['way /extern gg][ compose/deep[ radio[(to-set-word way) 1] gg: field "field" ] ] view f myway
*** Script Error: func [panel face][[face/offset face/size] if panel =? select face 'parent [panel *** Where: try *** Near : func [panel face][[face/offset face/size] ] *** Stack: open-project do-events do-actor do-safe error? add-new-section-to-data-templates save-new-sections-struct-and-content add-data-template-or-stat-sections-to-panel on-face-deep-change* *** Near: [func [panel face][[face/offset face/size] if panel =? select face 'parent [pane *** Script Error: func [panel face][[face/offset face/size] if panel =? select face 'parent [panel *** Where: try *** Near : func [panel face][[face/offset face/size] ] *** Stack: open-project do-events do-actor do-safe error? add-new-section-to-data-templates save-new-sections-struct-and-content add-data-template-or-stat-sections-to-panel on-face-deep-change* *** Near: [func [panel face][[face/offset face/size] if panel =? select face 'parent [pane *** Script Error: func [panel face][[face/offset face/size] if panel =? select face 'parent [panel *** Where: try *** Near : func [panel face][[face/offset face/size] ] *** Stack: open-project do-events do-actor do-safe error? add-new-section-to-data-templates save-new-sections-struct-and-content add-data-template-or-stat-sections-to-panel on-face-deep-change* *** Near: [func [panel face][[face/offset face/size] if panel =? select face 'parent [pane *** Script Error: func [panel face][[face/offset face/size] if panel =? select face 'parent [panel *** Where: try
> >> do %/d/123/app.red >
> do/args %red.r "-c -e %/d/123/app.red" >
> *** Script Error: updates has no value > *** Where: in > *** Near : set-quiet in panel updates 0 > *** Stack: view do-events do-actor do-safe error? on-face-deep-change* check-pane update-total > *** Near: [[panel/pane] check-pane panel] > *** Script Error: updates has no value > *** Where: in > *** Near : > *** Stack: view do-events do-actor do-safe error? on-face-deep-change* update-total > *** Near: [[panel/updates] update-total panel] > >
> Red [] > > #include %/d/123/do-atomic.red > #include %/d/123/scrollpanel.red > #include %/d/123/do-unseen.red > #include %/d/123/relativity.red > #include %/d/123/setters.red > > pos: 0x0 > view [ > ppp: scrollpanel green [] > button "add" [ > append ppp/pane layout/only [ > at (pos: pos + 0x30) button "test" > ] > ] > ] >
*** Script Error: quietly has no value *** Where: update-total *** Near : quietly panel/updates: 0 *** Stack: view do-events do-actor do-safe error? on-face-deep-change* check-pane update-total *** Near: [[panel/pane] check-pane panel] *** Script Error: quietly has no value *** Where: update-total *** Near : *** Stack: view do-events do-actor do-safe error? on-face-deep-change* update-total *** Near: [[panel/updates] update-total panel]
do/args %red.r "-c -e %/d/123/app.red"
do/expand in these cases. *** Stack: open-project do-events do-actor do-safe error? view do-events do-actor do-safe error? open-project call-db-uniq-keys-rules on-face-deep-change* *** Near: [func [panel face][[face/offset face/size] if panel =? select face 'parent [pane Connection to database... redefine-config-by-cmd-args No args passed. Use "-proj=name -job=1" for project name *** Runtime Error 1: access violation *** at: 68277D31h
pos: 0x0
foo: func [] [
clear ppp/pane
foreach el [aa bb cc dd] [
append ppp/pane layout/only [
at (pos: pos + 0x30) button "test1"
]
]
]
view [
panel [
ppp: scrollpanel green []
]
button [foo]
]access violate crush! (on real project)panel no crashes?clear them outredres_nmkqueryopen/lines or open/direct aren't supported in Red.%tests/IO directory, there's a lot of very simple examples.runtime/platform/definitions/POSIX.reds, you need to change __res_nmkquery to res_nmkquery. Some distros need one version, some need the other.Access Error: cannot open: %-cq: [
[base table: "default.test.solar"]
[sel value: "orbits='Sun'"]
[link [whatever]]
[sort col: "dist"]]
xml-attrs: function [elem [block!]] [
collect compose [ o: next head elem
while [set-word? o/1] [keep rejoin [" " o/1 "=" mold to-string o/2]
o: next next o] ]]
xml-tail: function [el [block!]] [
end: last el
either (block! = type? end)
[rejoin [">" (to-xml end) "</" el/1 ">"]]
["/>"]]
to-xml: function [ops [block!]] [
rejoin collect [foreach op ops [
keep rejoin ["<" (op/1) (xml-attrs op) (xml-tail op)]]]]to-xml end in xml-tail except i don't get any child elements... but with that call, previously-working references to op/1 and such suddenly break. I know op isn't exactly a variable, and the to-xml function doesn't exactly have a "scope"... but I don't know how to fix this. What am I missing? :D[block! block! ... etc] your recursive call gets [word!] instead. Try changing [link [whatever]] to [link [[whatever]]]
Red 0.6.4 for Windows built 18-Jan-2023/13:38:47-05:00 commit #ced7dc0 ... But I don't see anything about xml when I try probe system/codecs ... Also, I don't know what to do with the codecs I do see. :)str: {touch /home/test.txt}
call/output str data: ""str: {date > /home/test.txt}
call/output str data: ""str: {echo 'test' > /home/test.txt}
call/output str data: ""str: {mv /home/test.txt /home/test2.txt}
call/output str data: ""wait before repeating some operation. Am I right that wait is blocking operation?f: function [] [ print "hello" wait 10 print "world" ] f
? call.view [base rate 0:0:10 on-time [print "10 sec elapsed"]]load-xml find the-xml " works around the problem for now, but i'm willing to contribute if you'd like )0 or fractions of 1 of course. Even if in block, number is still loaded and typed. As [documentation](https://github.com/red/docs/blob/master/en/datatypes/integer.adoc) states:do block for the time being?>> sqlite: import 'sqlite [REBOL] Downloading: https://github.com/Siskin-framework/Rebol-SQLite/releases/download/3.38.5.0/sqlite-windows-x64.rebx [REBOL] Importing extension: /D/gear/rebol/sqlite-windows-x64.rebx >> ? sqlite SQLITE is a module of value: lib-base handle! #[handle! extension] lib-file file! %/D/gear/rebol/sqlite-windows-x64.rebx lib-local object! [] words block! length: 0 [] info command! Returns info about SQLite extension library open command! Opens a new database connection exec command! Runs zero or more semicolon-separate SQL statements finalize command! Deletes prepared statement trace command! Traces debug output prepare command! Prepares SQL statement reset command! Resets prepared statement step command! Executes prepared statement close command! Closes a database connection initialize command! Initializes the SQLite library shutdown command! Deallocate any resources that were allocated >> sqlite/initialize == true
--== Red 0.6.4 ==-- Type HELP for starting information. >> parse "🍩🕳️" [set hole ahead [2 skip] set donut [to end] (probe hole probe donut)] none #"🍩" == true >>
replace/all ? or something like [this](https://www.red-lang.org/2016/06/061-reactive-programming.html#:~:text=Syntax%20for%20change%20command) ?parseahead ? Isn't it enough to do as in the examples provided in the link above ?; surrogate-pair code points
scp: charset [#"^(010000)" - #"^(10ffff)"]
parse data [
some [ to scp a-char: scp change a-char (encode-to-surrogate-pair a-char)]
]txt face fills itself with some value from a function whenever the layout is view (not only on created). I know there's no on-show. How can I do it? Thanks>> f: does [return "some text"] == func [][return "some text"] >> lyo: [txt: h5 on-show [face/text: f]] == [txt: h5 on-show [face/text: f]] >> view lyo *** Script Error: VID - invalid syntax at: [on-show [face/text: f]] *** Where: do *** Near : throw-error spec *** Stack: view layout throw-error cause-error
== func [][return random/only ["ana" "beth" "carl"]] lyo: [txt: h5 do [txt/text: f]] == [txt: h5 do [txt/text: f]] >> view lyo >> view lyo
do. I thought do worked only the first time the layout is viewed, but it works every time. Thanks anywayon-created works in this case where I do not re-layout every time>> lyo: layout [txt: h5 on-created [txt/text: f]] ;... >> view lyo >> view lyo
do. I thought do worked only the first time the layout is viewed, but it works every time.layout result (window) and a block (your lyo)face! is linked to an OS window when you view (show) it, and that OS window is freed once you close itlyo: layout [f: field] then I show it with view lyo and type some info in the field then close the window, then show it again it still has the info in the field! I guess OS frees the window but not destroy it. Am I right?area face, so you can do that only using WinAPI and other OS APIcaret.area for [Spaces](https://codeberg.org/hiiamboris/red-spaces/)rich-text facerich-tex dialect and see... But I'm afraid I'm too new to Red to do hard things of any kind... I'd rather release an alpha version of my program with 'lots of little bugs' now and wait for the implementation of caret for area. If it's just a matter of some months, I'm not in a hurry.│ char|on-key events in the field face, calculate offset based on that (normal char +1, backspace -1, arrow keys ..., on ctrl+v +length of clipboard)on-key for input and on-mouse-* for mouse actions,basically you just divide mouse position by font size to get text position.abcd efgh ijkg lmno
area[this](https://gist.github.com/toomasv/0085fd7c61e53dc9cedb45ae98f777e9) might be of use.[piotr@fedora-37 Tikueditor]$ redc -r rtbox.red
-=== Red Compiler 0.6.4 ===-
Compiling /var/home/piotr/Documents/programs/Tikueditor/rtbox.red ...
Compiling compression library...
*** Compilation Error: undefined word help-string
*** in file: /var/home/piotr/Documents/programs/Tikueditor/rtbox.red
*** near: [help-string tuple! 2 [glass] context [transparent: #~000000FE]
pallette: [
title "Select color" origin 1x1 space 1x1
style clr: base 15x15 on-down [dn?: true] on-up [
if dn? [env/color: face/extra unview]
]
]
]caret for area or perhaps give a try another programming language. :'(-e option in compiler*** Script Error: help-string has no value *** Where: load *** Near : bind colors: exclude sort extract load help-string *** Stack: context extract load
*** Compilation Error: undefined word caret-to-offset
button "ã" font [color: black name: "Gentium Plus" size: 12] [
replace/all input/text "|" "ã"
]view [
title "Title"
input: area font [name: "Gentium Plus" size: 14] 725x650 "/"
button "ã" font [color: black name: "Gentium Plus" size: 12] [
replace input/text "/" "ã/"
]> *** Compilation Error: undefined word caret-to-offset >
needs: view :)button "convert" font [color: black name: "Gentium Plus" size: 12] [ replace/all input/text "a1" "ã" replace/all input/text "a2" "a̰" replace/all input/text "a3" "ã̰" ]
acentos-etc: func [face /local ndx] [
; v-r pairs, v is what the user types in, r is the replacement
foreach [v r]["a'" "á" "e'" "é" "i'" "í" "o'" "ó" "u'" "ú" "??" "¿" "!!" "¡" "n~" "ñ" "n'" "ñ" {u"} "ü" {u:} "ü"][
if find face/text v [
replace face/text v r
ndx: 1 + length? face/text
face/selected: as-pair ndx ndx
break
]
]
]
view [field on-change [acentos-etc face]]face/selected multiple times ;)st: parse {??Quie'n me librara' de la vergu:enza y la muerte? Cada man~ana alabare' al Sen'or. !!Aleluya!} [some [string! | change "a'" "á" | change "e'" "é" | change "i'" "í" | change "o'" "ó" | change "u'" "ú" | change "n'" "ñ" | change "n~" "ñ" | change "u:" "ü" | change {u"} "ü" | change "??" "¿" | change "!!" "¡" ]]*** Script Error: PARSE - matching by datatype not supported for any-string! input
*** Where: parse
*** Near : st: parse {??Quie'n me librara' de la ver}
*** Stack:ndx: 1 + length? face/text face/selected: as-pair ndx ndx part is to force the caret to the end of the line (where the user is probably typing) because replace... was moving it to the beggining IIRC. The problem is when the user is editing what he/she already typed, and the caret is in the middle of the line, for example. I know it is not good enough but I give it so anyone can improve it.copy it to some variable. st: "??Que? a'!!" parse st [ any [ change "??" #"¿" | change "a'" #"á" | change "!!" #"¡" | skip ] ] ? st ;== ST is a string! value: "¿Que? á¡"
skip-ch: complement charset "?a!" changes: #( "??" #"¿" "a'" #"á" "!!" #"¡" ) parse st [ any [ s: copy x [ "??" | "a'" | "!!" ] e: ( print ["Replacing:" x] e: change/part s changes/:x e ) :e | thru skip-ch ] ]
skip-ch: complement charset "?a!" ;; ignored characters parse st [ any [ change "??" #"¿" | change "a'" #"á" | change "!!" #"¡" | thru skip-ch ;; finds next ?, a or ! char ] ]
complement but the ignored chars would be the whole alphabet A - Z a - z, so the first solution is the bestskip, else you will force the code to do a lot of useless checksskip-ch: complement charset "?a!" parse st [ any [ s: [ "??" (n: #"¿") | "a'" (n: #"á") | "!!" (n: #"!") ] e: ( print ["Replacing:" copy/part s e "to:" n] e: change/part s n e ) :e | some skip-ch ] ]
truest: "? ??Que? a'!!"a (for instance) is not followed by those symbols? how parse does not return false in that case?>> skip-ch: complement charset "aeioun?!"
== make bitset! [not #{000000004000000100000000444304}]
>> st: {??Quie'n me librara' de la vergu:enza y la muerte? Cada man~ana alabare' al Sen'or. !!Aleluya!}
== {??Quie'n me librara' de la vergu:enza y la muerte? Cada man~ana alabare' al Sen'or. !!Aleluya!}
>> parse st [any [change "a'" #"á" | change "e'" #"é" | change "i'" #"í" | change "o'" #"ó" | change "u'" #"ú" | change "??" #"¿" | change "!!" #"¡" | change "u:" #"ü" | change {u"} #"ü" | change "n'" #"ñ" | change "n~" #"ñ" | thru skip-ch]]
== false
>> st
== {¿Quie'n me librará de la vergüenza y la muerte? Cada man~ana alabaré al Sen'or. ¡Aleluya!}
>>skip from the first version.>> st
== {¿Quie'n me librará de la vergüenza y la muerte? Cada man~ana alabaré al Sen'or. ¡Aleluya!}
>> parse st [
[ any [
[ change "??" #"¿"
[ | change "a'" #"á"
[ | change "!!" #"¡"
[ | skip
[ ]
[ ]
== true
>> st
== {¿Quie'n me librará de la vergüenza y la muerte? Cada man~ana alabaré al Sen'or. ¡Aleluya!}
>>>> st: {??Quie'n me librara' de la vergu:enza y la muerte? Cada man~ana alabare' al Sen'or. !!Aleluya!}
== {??Quie'n me librara' de la vergu:enza y la muerte? Cada man~ana alabare' al Sen'or. !!Aleluya!}
>>>> parse st [
[ any [
[ change "??" #"¿"
[ | change "!!" #"¡"
[ | change "a'" #"á"
[ | change "e'" #"é"
[ | change "i'" #"í"
[ | change "o'" #"ó"
[ | change "u'" #"ú"
[ | change "u:" #"ü"
[ | change {u"} #"ü"
[ | change "n'" #"ñ"
[ | change "n~" #"ñ"
[ | skip
[ ]
[ ]
== true
>> st
== {¿Quién me librará de la vergüenza y la muerte? Cada mañana alabaré al Señor. ¡Aleluya!}
>>Ctrl ' a and it shows á, but elsewhere you must type Alt 160. It has been always this way in Windows and MS-DOS, I guessstart-ch: charset "?!aeioun"
parse st [
any [
to start-ch [ ;; skip any char that does not start replaceable combination
change "??" #"¿"
| change "!!" #"¡"
| change "a'" #"á"
| change "e'" #"é"
| change "i'" #"í"
| change "o'" #"ó"
| change "u'" #"ú"
| change "u:" #"ü"
| change {u"} #"ü"
| change "n'" #"ñ"
| change "n~" #"ñ"
| skip ;; no variation above, so just skip this char
]
| to end ;; just to have true from parse
]
]change and replace methods?button "Conv. carácteres" font [name: "Gentium Plus" size: 13] [
replace/all input/text "a1" "ã"
replace/all input/text "a2" "a̰"
replace/all input/text "a3" "ã̰"
]change modifies series at its current position (index), while replace goes thru the series and modifies first found needle (if not used with /all).>> change s: "abcd" "X" :s == "Xbcd" >> replace s: "abcd" "b" "X" :s == "aXcd"
find returns position of the needle, replace can be replaced with:>> s: "abcd" change find s "b" "X" :s == "aXcd"
parse itself is not fast as I fought... for the best results you would probably want to collect results in a new series instead of modifying the input...using-replace: func[str][
replace/all str "??" #"¿"
replace/all str "!!" #"¡"
replace/all str "a'" #"á"
replace/all str "e'" #"é"
replace/all str "i'" #"í"
replace/all str "o'" #"ó"
replace/all str "u'" #"ú"
replace/all str "u:" #"ü"
replace/all str {u"} #"ü"
replace/all str "n'" #"ñ"
replace/all str "n~" #"ñ"
str
]
start-ch: charset "?!aeioun"
using-parse-collect: func[str /local out][
out: make string! length? str
parse str [
collect into out any [
keep to start-ch [
"??" keep (#"¿")
| "!!" keep (#"¡")
| "a'" keep (#"á")
| "e'" keep (#"é")
| "i'" keep (#"í")
| "o'" keep (#"ó")
| "u'" keep (#"ú")
| "u:" keep (#"ü")
| {u"} keep (#"ü")
| "n'" keep (#"ñ")
| "n~" keep (#"ñ")
| keep 1 skip
]
keep to end
]
]
out
]
;; With some longer input data...
st: {??Quie'n me librara' de la vergu:enza y la muerte? Cada man~ana alabare' al Sen'or. !!Aleluya!}
st1000: make string! 1000 * length? st
insert/dup st1000 st 1000
dt [using-replace copy st1000]
;== 0:00:00.815511
dt [using-parse-collect st1000] ;; no need to use copy, as it makes new series itself
;== 0:00:00.508658>> dt [using-replace copy st1000] == 0:00:00.051885 >> dt [using-parse-collect st1000] == 0:00:00.013872
dt contributes a lot too>> profile/times [[using-parse-collect st1000]] 500 Running 1 code blocks 500 times. ------------------------------------------------------------------------------------------- Time | Evals | S.made | S.expa | Memory | Code 1.0x (26μs) | 27 | 3 | 1 | 356352 | [using-parse-collect st1000] -------------------------------------------------------------------------------------------
clock is using another measure.profile with clock... The profile is using loop, but the result is divided by the loop count, where clock is reporting the time of the whole loop.?? clockif find... and the break, it is a litlle less inefficient. And last but not least, I never though that this would bring so much scrutiny about Red itself compared to Rebol. I hope it contributes to improve Red. My recognition for both Carl and Nenad, and all you guys who keep alive this piece of art called Rebol/Red.D:\devel\red\spaces>red "1.red" 143 ms [using-replace copy st1000] 7.81 ms [using-parse-collect st1000] D:\devel\red\spaces>r3 1.red Running 1 code blocks 100 times. ------------------------------------------------------------------------------------------- Time | Evals | S.made | S.expa | Memory | Code 1.0x (21ms) | 112575 | 2 | 0 | 282624 | [using-replace copy st1000] ------------------------------------------------------------------------------------------- Running 1 code blocks 1000 times. ------------------------------------------------------------------------------------------- Time | Evals | S.made | S.expa | Memory | Code 1.0x (23μs) | 27 | 3 | 1 | 356352 | [using-parse-collect st1000] -------------------------------------------------------------------------------------------
102 ms [using-replace copy st1000] 4.41 ms [using-parse-collect st1000]
replace is meant to be easy to use, not fast. Especially for interactive use on smaller data, as long as it's faster than a human cares about, we each have to weigh dev time and potential bugs. For cases like this, rather than suggesting hand-rolling parse solutions, what we may really want is a transliterate function, to replace a table of values. Higher level, declarative, and only @hiiamboris and @Oldes have to spend time getting it right. :^)using-parse-collect 8μs on ARM64 build and 18μs on x64 build under Rosetta emulation. So I don't see any problem with it.delta-time is not precise enough.>> nonzero: complement zero: charset "^@"
== make bitset! [not bits #{80}]
;; R3 could use some work too:
>> profile/times [[parse s [some zero]] [parse s [to nonzero]] [parse s [some #"^@"]]] 1000
Running 3 code blocks 1000 times.
--------------------------------------------------------------------------------------------
Time | Evals | S.made | S.expa | Memory | Code
1.0x (814μs) | 4 | 0 | 0 | 0 | [parse s [to nonzero]]
1.17x (950μs) | 5 | 0 | 0 | 0 | [parse s [some #"^@"]]
1.86x (2ms) | 5 | 0 | 0 | 0 | [parse s [some zero]]
--------------------------------------------------------------------------------------------
;; Red, esp. surprising is the TO vs SOME difference:
>> clock/times [parse s [to nonzero]] 100
8.74 ms [parse s [to nonzero]]
>> clock/times [parse s [some #"^@"]] 1000
6.21 ms [parse s [some #"^@"]]
>> clock/times [parse s [some zero]] 1000
654 μs [parse s [some zero]]call itMicrosoft Windows [Version 10.0.19043.962] (c) Microsoft Corporation. All rights reserved. C:\Users\cosacam>ldapsearch 'ldapsearch' is not recognized as an internal or external command, operable program or batch file. C:\Users\cosacam>
switch mytype [ 1 [v: (val and FFFFh)] ;vendor id 2 [v: ((val >>> 16) and FFFFh)] ;product id ]
and FFFFh is not needed btw for product idlfred?