Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.filemaker > #1706

Re: Applescript weirdnesses

From Helpful Harry <HelpfulHarry@BusyWorking.com>
Newsgroups comp.databases.filemaker
Subject Re: Applescript weirdnesses
Date 2014-02-01 12:57 +1300
Organization Aioe.org NNTP Server
Message-ID <010220141257094277%HelpfulHarry@BusyWorking.com> (permalink)
References <ws21-16E223.16155623012014@70-3-168-216.pools.spcsdns.net> <ws21-936F55.11375524012014@70-3-168-216.pools.spcsdns.net> <lbu59v$qmd$1@dont-email.me> <ws21-82C212.16312831012014@70-3-168-216.pools.spcsdns.net>

Show all headers | View raw


In article <ws21-82C212.16312831012014@70-3-168-216.pools.spcsdns.net>,
Bill Steele <ws21@cornel.edu> wrote:
> In article <lbu59v$qmd$1@dont-email.me>,
>  Erik Appeldoorn <ursus.kirk@gmail.com> wrote:
> > 
> > Is there any special reason you are opting for applescript? Everything 
> > you are showing here can be done natively in FMP. so you don't need to 
> > rewrite your scripts again when apple decides to change applescript.
> 
> There's a lot of text processing involved, basically converting a block 
> of text to a list.
> 
> A native way to do it might get what I want, so I'm open to suggestions. 
> 
> In pseudocode:
> 
> List1 = read field 1
> 
> Tom
> Dick
> Harry
> 
> List2 = read field 2
> 
> Sawyer
> Nixon
> Langdon
> 
> Open layout "names"
> 
> repeat with i from 1 to 3
> create new record with data item i of List1, item i of list 2

If it's a one-off or only occasionally, then I'd simply copy-paste the
lists in two columns in Excel and then import the new records from
that.

If it's an on-going task, then the FileMaker script should be basically
the same process as an AppleScript one.


I see Erik has already replied with a script using variables and the
Item function, but if you (or anyone else) is using an older version of
FileMaker without these abilities, then probably the easiest way, off
the top of my head, is:

   - copy the data from List1 and List2 to Global temporary
     fields, adding an extra carriage return character to ensure
     every data value has one
   - loop through creating new records for the first line of 
     data in each List field (i.e. all the characters up to the
     first carriage return character) 
   - remove those value from the lists
   - keep looping around until the List is empty (or just a 
     carriage return character)

e.g.

    Set Field [g_List1; List1 & "RET"]
    Set Field [g_List2; List2 & "RET"]
    Loop
      New Record
      Set Field [Data1; Left(g_List1; Position(g_List1; "RET"; 1; 1)-1)]
      Set Field [Data2; Left(g_List2; Position(g_List2; "RET"; 1; 1)-1)]
      Set Field [g_List1; Substitute(g_List1; Data1 & "RET"; "")]
      Set Field [g_List2; Substitute(g_List2; Data2 & "RET"; "")]
      End Loop If [(g_List1 = "") or (g_List1="RET")]
    End Loop

where:
    - "RET" is really the 'backwards P' / Pilcrow / carriage
      return character (in case the symbol doesn't come through
      the newsserver/  newsreader corruption)
    - g_List1 and g_List2 are Global fields
    - Data1 and Data2 are the record fields

A quick test seems to show this works, but you may need to add extra
eror checking in case List1 is shorter than List2, and deleting any
extra "empty" records created by blank lines in the lists.

You could possibly use Value Lists as an alternative, but I haven't
tested it.

Helpful Harry   :o)

Back to comp.databases.filemaker | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

Applescript weirdnesses Bill Steele <ws21@cornel.edu> - 2014-01-23 16:15 -0500
  Re: Applescript weirdnesses Bill Steele <ws21@cornel.edu> - 2014-01-24 11:37 -0500
    Re: Applescript weirdnesses Erik Appeldoorn <ursus.kirk@gmail.com> - 2014-01-24 17:44 +0100
      Re: Applescript weirdnesses Bill Steele <ws21@cornel.edu> - 2014-01-31 16:31 -0500
        Re: Applescript weirdnesses "E. Appeldoorn" <ursus.kirk@ziggo.nl> - 2014-02-01 00:09 +0100
          Re: Applescript weirdnesses Howard Schlossberg <howard@nospam.fmprosolutions.com> - 2014-01-31 17:03 -0800
        Re: Applescript weirdnesses Helpful Harry <HelpfulHarry@BusyWorking.com> - 2014-02-01 12:57 +1300

csiph-web