On Mon, 20 Oct 2003, Tim Johnson wrote:

>
> Hello REBOLS:
> I need some advice :-)
> I've written a function that converts a delimited string into
> an associative list.
> Code and example console session is below:
> ;; =============================================================
> make-al: function[ {Builds an associative list from a delimited string}
>       str[string!]   {delimited string}
>       /with delimiter[string! char!] {custom delimiter (TAB is default)}
>       /default _dval[any-type!]      {custom default value (NONE is default)}
>       ][tmp al-block sep dval][
>       sep: either with[to-string delimiter][to-string TAB]
>       dval: either default[_dval][none]
>       al-block: copy []
>       tmp: parse/all str sep
>       if not even? length? tmp[append tmp dval]
>       foreach [name value] tmp[
>               append al-block to-word name
>               append al-block value
>               ]
>       al-block
>       ]
> test: "age^-54^-name^-Tim Johnson^-occuptation^-coder"
> probe make-al test
> ;; = Console session ===========================================
> == [age "54" name "Tim Johnson" occuptation "coder"]
> ;; Now, so far it is a piece of cake, but this is where
> ;; I falter:
> I would like to employ a strategy that converts any value
> to the best guess for a rebol datatype. IOWS, "54"[string!]
> would become 54[integer!]
>
> It occurs to me that a brute-force method would be to process
> via a nested attempt[any[]] loop.
>
> Any more "elegant" ideas?
> thanks
> tim
> --
> Tim Johnson <[EMAIL PROTECTED]>
>       http://www.alaska-internet-solutions.com
> --
> To unsubscribe from this list, just send an email to
> [EMAIL PROTECTED] with unsubscribe as the subject.



could try


append al-block load value

-- 
To unsubscribe from this list, just send an email to
[EMAIL PROTECTED] with unsubscribe as the subject.

Reply via email to