Path: csiph.com!usenet.pasdenom.info!aioe.org!.POSTED!not-for-mail From: Helpful Harry Newsgroups: comp.databases.filemaker Subject: Re: Applescript weirdnesses Date: Sat, 01 Feb 2014 12:57:09 +1300 Organization: Aioe.org NNTP Server Lines: 84 Message-ID: <010220141257094277%HelpfulHarry@BusyWorking.com> References: NNTP-Posting-Host: 6IUAYajmJReZqXGJcNgpVQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Thoth/1.5.4 (Carbon/OS X) X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.databases.filemaker:1706 In article , Bill Steele wrote: > In article , > Erik Appeldoorn 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)