Hi Folks... I hope this isn't asking too much. I have found using the docs to be less than satisfying when trying an alternative coding technique. I guess I fall into the old dog, actually the old Hypercard dog, trying to learn the new Rev tricks.

I just wrote a quick and dirty script to parse out an iCal calendar saved as a text file to feed my car expense calculator which was published a few months ago in a Rev newsletter. The script is very slow and I was intrigued to know how to speed it up as I am aware that I am using very archaic scripting techniques.

Here is my script. It's relatively short and contains almost all of my favourite coding patterns. If anyone has the inclination, perhaps you could point out how I might make use of Revs improvements over Hypercard...

It has to do with better ways to handle repeating actions and better ways to handle lists... Thanks in advance... Jim

--> all handlers

on mouseUp
put 0 into eventMark -- didn't end up using this for anything by a switch
    put 1 into j
    put empty into eventLine
    put empty into field 2
    repeat with i = 1 to the number of lines of field 1
if line i of field 1 contains "BEGIN:VEVENT" then -- found an event
            put 1 into eventMark
            next repeat
        end if
        if eventMark > 0 then -- we are parsing an event now
            breakpoint
if line i of field 1 contains "SUMMARY:" then -- found the event name
                put 2 into eventMark
                set the itemdelimiter to ":"
put item 2 of line i of field 1 into eventName -- hold event name
                next repeat
            end if
if line i of field 1 contains "LOCATION:" then -- found the event location
                put 3 into eventMark
if line i of field 1 contains "\," then replace "\, " with " " in line i of field 1
                set the itemdelimiter to ":"
put item 2 of line i of field 1 into locationName -- hold event location
                next repeat
            end if
if line i of field 1 contains "DTSTART;" then -- found the event location
                put 4 into eventMark
                set the itemdelimiter to ":"
put char 1 to 4 of item 2 of line i of field 1 into eventYear -- hold event year - yyyymmdd put char 5 to 6 of item 2 of line i of field 1 into eventMonth -- hold event month - yyyymmdd put char 7 to 8 of item 2 of line i of field 1 into eventDay -- hold event day - yyyymmdd put char 10 to 13 of item 2 of line i of field 1 into eventTime -- hold event time
                next repeat
            end if
        end if
if line i of field 1 contains "END:VEVENT" then -- found an event ending
            set itemdelimiter to ","
            if eventYear = "2007" then
                -- if eventMonth ≥ "10" then
put eventMonth & "/" & eventDay & "/" & eventYear into eventDate
                put 1 into holdLine
                -- else put 0 into holdLine
            else put 0 into holdLine

            if holdLine is 1 then
                put eventDate into item 2 of line j of field 2
if locationName is empty then put "Halifax" into locationName
                put locationName into item 5 of line j of field 2
                put " - " & eventName after item 5 of line j of field 2
                put empty into item 6 of line j of field 2
if item 5 of line j of field 2 contains "Dartmouth" then put "Dartmouth" into item 6 of line j of field 2 if item 5 of line j of field 2 contains "Burnside" then put "Burnside" into item 6 of line j of field 2 if item 5 of line j of field 2 contains "Bedford" then put "Bedford" into item 6 of line j of field 2 if item 5 of line j of field 2 contains "Sackville" then put "Sackville" into item 6 of line j of field 2 if item 5 of line j of field 2 contains "Kentville" then put "Kentville" into item 6 of line j of field 2 if item 5 of line j of field 2 contains "Port Hawksbury" then put "Port Hawksbury" into item 6 of line j of field 2 if item 5 of line j of field 2 contains "Truro" then put "Truro" into item 6 of line j of field 2 if item 5 of line j of field 2 contains "Bridgewater" then put "Bridgewater" into item 6 of line j of field 2 if item 5 of line j of field 2 contains "Tantallon" then put "Tantallon" into item 6 of line j of field 2 if item 5 of line j of field 2 contains "Glen Haven" then put "Glen Haven" into item 6 of line j of field 2 if item 5 of line j of field 2 contains "Hubbards" then put "Hubbards" into item 6 of line j of field 2 if item 5 of line j of field 2 contains "Bayers Lake" then put "Bayers Lake" into item 6 of line j of field 2 if item 5 of line j of field 2 contains "Cole Harbour" then put "Cole Harbour" into item 6 of line j of field 2 if item 5 of line j of field 2 contains "airport" then put "airport" into item 6 of line j of field 2
                put eventTime into item 7 of line j of field 2
if line j of field 2 contains "\" then replace "\" with empty in line j of field 2
                put return after line j of field 2
                add 1 to j
                put empty into eventDate
                put empty into locationName
                put empty into eventName
                put empty into eventYear
                put empty into eventMonth
                put empty into eventDay
                put empty into eventTime
            end if
            put 0 into eventMark
            -- end if
        end if
        if the optionkey is "down" then exit repeat
    end repeat
    set the itemdelimiter to ","
    sort lines of field 2 by item 7 of each
    sort lines of field 2 dateTime by item 2 of each
end mouseUp
Jim Carwardine,
President & CEO
OYF Consulting
Ph. 902.823.2339 / 866.601.2339
Fx. 902.823-2139
<www.StrategicDoing.com>
StrategicDoing™: Execution depends on employees.
Strategic Partner with HiringSmart Canada Ltd.
--



_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to