Hi Ryan

Same gotcha as the one I just answered.  To initialize an empty block or
string within a function body or more generally within another block, you
need to use 'copy.  In your code

change    content-parts: []     to    content-part: copy []

HTH

Larry

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 22, 2000 4:38 PM
Subject: [REBOL] variable not local?


> Loading the following functions and then using the expression...
>
> convert-email-object msg
>
> ...where "msg" is an e-mail object loaded from a mailbox...
>
> produces too many values for the "body" word in the resultant object...
>
> make object! [
>     headline: "Nixon said he will run again"
>     subheadline: "Aides said his health is of no concern"
>     body: ["first paragraph first article" "" "" "second paragraph second
article"
> "" "first paragraph second article" "" "" "second paragraph second
article" ""]
> ]
>
> Somehow, the "content-parts" variable in the breakdown-content function
> carries over from one operation to a second operation. Why is this
> happening?
>
> Thanks.
>
> -Ryan
>
>
>
> functions used...
>
>
> ; -- BREAKDOWN-SUBJECT --
>
> breakdown-subject: func [
> "breakdown an e-mail subject field into its parts"
> msg [object!] "e-mail message"
> /local
> subject-info [string!] "the Subject line of the e-mail"
> subject-parts [block!] "the parts of the Subject line of the e-mail"
> ][
> subject-info: msg/subject
> subject-parts: []
> foreach part parse/all subject-info ":" [
> append subject-parts part
> ]
> ]
>
>
> ; -- BREAKDOWN-CONTENT --
>
> breakdown-content: func [
> "breakdown an e-mail content field into its parts"
> msg [object!] "e-mail message"
> /local
> article-info [string!] "the body text of the e-mail"
> content-parts [block!] "the paragraphs of the body text of the e-mail"
> ][
> article-info: msg/content
> end-of-paragraph: rejoin [{.} newline]
> content-parts: []
> foreach part parse/all article-info end-of-paragraph [ append
content-parts part ]
> ]
>
>
> ; -- BREAKDOWN-EMAIL --
>
> breakdown-email: func [
> "breakdown an e-mail message object and convert it to an article object"
> msg [object!] "e-mail message"
> /local
> subject-pieces [block!] "a block containing the parts of the Subject line
of the e-mail"
> content-pieces [block!] "a block containing the paragraphs of the body
text of the e-mail"
> article [object!] "an object containing the parts of a news article"
> ][
>
> subject-pieces: breakdown-subject msg
> content-pieces: breakdown-content msg
>
> make object! [
> headline: subject-pieces/1
> subheadline: subject-pieces/2
> body: content-pieces
> ]
> ]
>
>
> ; -- TIME-IN-DIGITS --
>
> time-in-digits: func [
> "convert the date and time from 'now' into a string of digits"
> sun-dial [date!] "the current date and time from 'now'"
> ][
> year: to-string sun-dial/year
> month: to-string sun-dial/month
> if (length? month) < 2 [insert month "0"]
> day: to-string sun-dial/day
> if (length? day) < 2 [insert day "0"]
>
> current-time: sun-dial/time
> hour: to-string current-time/hour
> if (length? hour) < 2 [insert hour "0"]
> minutes: to-string current-time/minute
> if (length? minutes) < 2 [insert minutes "0"]
> seconds: to-string current-time/second
> if (length? seconds) < 2 [insert seconds "0"]
>
> rejoin [year month day hour minutes seconds]
> ]
>
>
> ; -- CONVERT-EMAIL-OBJECT --
>
> convert-email-object: func [
> "convert an email object into an object a news article object and write it
as a file"
> msg [object!] "e-mail message"
> /local
> file-name [string!] "a string of digits used to name a file"
> complete-file-name [string!] "a file name using a string of digits and an
extension"
> ][
>
> now-digits: time-in-digits now
>
> object-name: rejoin ["article" now-digits]
>
> generate-object: rejoin [ reform [ "save" rejoin
[{%absolute/path/articles/} object-name {.r}] ] " " reform [rejoin
[object-name ":"] "breakdown-email msg"] ]
>
> do generate-object
>
> ;temp-one: find person 'full.name
> ;set in article 'byline temp-one/2
>
> ;temp-two: find person 'reporter.title
> ;set in article 'title temp-two/2
>
> wait 1
> ]

Reply via email to