Hi Gregg,

Thanks for the code and structure. I'm going to try it. I just used a text
file because it's similar to a BASIC array, which I know how to manipulate
already. I haven't yet caught on to REBOL's objects and blocks of objects
and how to manipulate those. You've given me a start.

Meanwhile, I managed to get the loop to work. Instead of putting all I
wanted to do in one operation, I separated the assignment and the conversion
to-money and the addition into three operations. Now everything adds up!

    button blue "Calculate" [
        total: 0
        total-exp-1: 0
        for count 5 last-line rec-len [
            if my-data/:count > to-string newline [
                total: pick my-data count
                total: to-money total
            ]
            total-exp-1: total-exp-1 + total
        ]
        exp-1/text: total-exp-1
        show [exp-1]
    ]

Thanks again,
Jim


----- Original Message -----
From: Gregg Irwin <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 22, 2002 10:14 AM
Subject: [REBOL] Re: my-data


> Hi Jim,
>
> There are times when I like to spin through a text file and just do the
work
> as I go. Most times, though, I tend to load the data into structures that
I
> can work with more easily, especially in apps that have a UI of some kind
as
> opposed to batch processing type apps. Anyway, I went a different
direction
> because I didn't quite grok your example, so you can ignore this if it's
not
> to your liking.
>
> ; Create a prototype object
> ; TO and FOR are keywords we don't want to conflict with
> exp-rec: make object! [
>     date: check-number: to*: for*: exp-1: exp-2: exp-3: none
> ]
> records: copy []
> fields: next first exp-rec
>
> my-data: read/lines %2002.exp
>
> ; Load the data into a block of objects.
> ; You could also just make a block of blocks if you want.
> foreach :fields my-data [
>     new-rec: make exp-rec []
>     new-rec/date: date
>     new-rec/check-number: check-number
>     new-rec/to*: to*
>     new-rec/for*: for*
>     new-rec/exp-1: to money! either not empty? exp-1 [exp-1][0]
>     new-rec/exp-2: to money! either not empty? exp-2 [exp-2][0]
>     new-rec/exp-3: to money! either not empty? exp-3 [exp-3][0]
>     append records new-rec
> ]
>
> ; Now you can work with the objects to do whatever you want.
> total: $0.00
> foreach rec records [
>     total: total + rec/exp-1
> ]
>
> print total
>
> halt
>
> HTH!
>
> --Gregg
>
> --
> 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.

Reply via email to