[REBOL] Re: Imbedding rebol code in a dialect
From: al:bri:xtra at: 25-Sep-2002 16:24
Tim wrote:
> print ml compose/deep[
> form/action/method (cgl[get path thru "process"]) "POST"[
> (
> foreach field required-fields[
> value: cgl[get value field]
> ml[input/type/name/value "hidden" (field) (value)]
> ]
> )
> ]
> ] ;end 'ML
> My guess is that I am not using 'compose correctly or my parenthesis are
incorrectly placed. Any other ideas?
Just need to return a block! of:
input/type/name/value "hidden" (Field) (Value)
for each 'field, in the paren! just inside the 'form block! value.
I'd use my 'Map function here ('cause it returns a block!). Something like:
print ML compose/deep [
form/action/method (cgl[get path thru "process"]) "POST" [(
Map required-fields function [Field [string!] [Value] [
Value: cgl [get Value Field] ; This line seems a bit odd!
compose/deep [
input/type/name/value "hidden" (Field) (Value)
]
]
)] ; Note the _two_ closing brackets!
]
I've attached my very latest 'Map function, with the necessary 'Arguments
function.
Andrew Martin
ICQ: 26227169 http://valley.150m.com/
-><-
-- Attached file included as plaintext by Listar --
-- File: Map.r
Rebol [
Name: 'Map
Title: "Map"
File: %"Map.r"
Author: "Andrew Martin"
eMail: [Al--Bri--xtra--co--nz]
Web: http://valley.150m.com
Date: 24/September/2002
Version: 1.3.0
Purpose: {Maps or applies the function to all elements of the series.}
Category: [util 1]
Acknowledgements: [
"Joel Neely"
"Ladislav"
]
Example: [
Map func [n [number!]] [n * n] [1 2 3]
;== [1 4 9]
Map [1 2 3] func [n [number!]] [n * n]
;== [1 4 9]
Map [1 2 3 4 5 6] func [a] [print [a]]
;1
;2
;3
;4
;5
;6
;== []
Map [1 2 3 4 5 6] func [a b] [print [a b]]
;1 2
;3 4
;5 6
;== []
Map [1 2 3 4 5 6] func [a b c] [print [a b c]]
;1 2 3
;4 5 6
;== []
]
Requires: %Arguments.r
]
Map: function [
{Maps or applies the function to all elements of the series.} [catch]
Arg1 [any-function! series!]
Arg2 [any-function! series!]
/Only "Inserts the result of the function as a series."
][
Result Results Function Series
][
throw-on-error [
any [
all [
any-function? :Arg1 series? :Arg2
(Function: :Arg1 Series: :Arg2)
]
all [
any-function? :Arg2 series? :Arg1
(Function: :Arg2 Series: :Arg1)
]
throw make error! reduce [
'script 'cannot-use rejoin [
{"} mold 'Map " " mold type? :Arg1 {"}
]
rejoin [
{"} mold type? :Arg2 {"}
]
]
]
Results: make Series length? Series
do compose/deep [
foreach [(Arguments :Function)] Series [
if all [
not unset? set/any 'Result Function (Arguments :Function)
not none? Result
] [
(either Only ['insert/only] ['insert]) tail Results :Result
]
]
]
Results
]
]
-- Attached file included as plaintext by Listar --
-- File: Arguments.r
Rebol [
Name: 'Arguments
Title: "Arguments"
File: %"Arguments.r"
Author: "Andrew Martin"
eMail: [Al--Bri--xtra--co--nz]
Web: http://valley.150m.com
Date: 31/August/2002
Version: 1.0.1
Example: [
Arguments :Arguments
; [F]
]
Purpose: "Returns the arguments of the function as a block."
Category: [util script 5]
]
Arguments: function [
"Returns the arguments of the function as a block."
F [any-function!]
] [
Arguments
] [
Arguments: make block! 2
foreach Argument pick :F 1 [
if refinement? :Argument [
break
]
append Arguments :Argument
]
Arguments
]