Why is the translate-message/markup-data function "reusable" in the
following code....
translate-message: make object! [
markup-data: func [
data [object!]
][
xml-tags: [
["author" "/author"]
["subject" "/subject"]
["date" "/date"]
["content" "/content"]
["messageID" "/messageID"]
]
data-object: make data []
object-data: next first data-object
output: ""
for x 1 (length? xml-tags) 1 [
item: reform [rejoin ["data-object" "/" (first object-data)]]
made-tag: rejoin ["" (build-tag [(xml-tags/1/1)]) (do item)
(build-tag [(xml-tags/1/2)])]
xml-tags: next xml-tags
object-data: next object-data
append output made-tag
output
]
]
]
BUT not in the following code...
translate-message: make object! [
xml-tags: [
["author" "/author"]
["subject" "/subject"]
["date" "/date"]
["content" "/content"]
["messageID" "/messageID"]
]
markup-data: func [
data [object!]
][
data-object: make data []
object-data: next first data-object
output: ""
for x 1 (length? xml-tags) 1 [
item: reform [rejoin ["data-object" "/" (first object-data)]]
made-tag: rejoin ["" (build-tag [(xml-tags/1/1)]) (do item)
(build-tag [(xml-tags/1/2)])]
xml-tags: next xml-tags
object-data: next object-data
append output made-tag
output
]
]
]
-Ryan
> I've created an object with a function which converts data in another
> object into XML. But the function will only work ONCE. Why? Here is the
> console session...
>
> >> translate-message: make object! [
> [
> [ xml-tags: [
> [ ["author" "/author"]
> [ ["subject" "/subject"]
> [ ["date" "/date"]
> [ ["content" "/content"]
> [ ["messageID" "/messageID"]
> [ ]
> [
> [ markup-data: func [
> [ data [object!]
> [ ][
> [ data-object: make data []
> [ object-data: next first data-object
> [ output: ""
> [ for x 1 (length? xml-tags) 1 [
> [ item: reform [rejoin ["data-object" "/" (first o
> bject-data)]] [ made-tag: rejoin ["" (build-tag
> [(xml-tags/1/1)] ) (do item) (build-tag [(xml-tags/1/2)])] [
> xml-tags: next xml-tags [ object-data: next object-data [
> append output made-tag [ output [
> ] [ ] [ ] >> >> >> >> >> message: make object! [ [
> author: "Ryan C. Christiansen" [ subject: "This is the Subject
> of the Message" [ date: 27-Oct-2000/17:27:43-5:00 [ content:
> {This is the main body of the message} [ messageID: 20001027172734
> [ ] >> >> >> >> >> translate-message/markup-data message ==
> {<author>Ryan C. Christiansen</author><subject>This is the Subject of the
> Message</subject><date>27-Oct-2000/17:27:43-5:00</date... >>
> translate-message/markup-data message == none >> -- To unsubscribe from
> this list, please send an email to [EMAIL PROTECTED] with
> "unsubscribe" in the subject, without the quotes.
>
--
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the
subject, without the quotes.