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


Groups > comp.databases.filemaker > #1666 > unrolled thread

Applescript weirdnesses

Started byBill Steele <ws21@cornel.edu>
First post2014-01-23 16:15 -0500
Last post2014-02-01 12:57 +1300
Articles 7 — 5 participants

Back to article view | Back to comp.databases.filemaker


Contents

  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

#1666 — Applescript weirdnesses

FromBill Steele <ws21@cornel.edu>
Date2014-01-23 16:15 -0500
SubjectApplescript weirdnesses
Message-ID<ws21-16E223.16155623012014@70-3-168-216.pools.spcsdns.net>
Several things driving me up the wall today...

1. usually this works: 

tell layout "whatever"
repeat with i from 1 to (count of records)
set foo to cell "name" of record i
...etc.

Worked yesterday, in fact.  Today I get "object not found" with "count 
of records" highlighted.

2.

tell app "Filemaker Pro"
    tell database "MyData"
        tell layout "layout 1"
            set foo to cell "stuff"
    end tell
        end tell
(do some processing on foo to get bars)
        tell layout "layout 2"
        create new records with data {bar1, bar2}
        end tell

        tell layout "layout 3"
    (do some stuff and create a new record)
        end tell

Two problems: 
    a. Layout 2 appears while being processed. I don't want the user to 
see this. 

    b. Layout 3 does not appear, and instead of making its new record, 
the new record is added to layout 2. Why doesn't the tell process work 
the same for each layout?
        
Should be noted that each layout is in a different table.

[toc] | [next] | [standalone]


#1668

FromBill Steele <ws21@cornel.edu>
Date2014-01-24 11:37 -0500
Message-ID<ws21-936F55.11375524012014@70-3-168-216.pools.spcsdns.net>
In reply to#1666
In article <ws21-16E223.16155623012014@70-3-168-216.pools.spcsdns.net>,
 Bill Steele <ws21@cornel.edu> wrote:

> Several things driving me up the wall today...
> 
> 1. usually this works: 
> 
> tell layout "whatever"
> repeat with i from 1 to (count of records)
> set foo to cell "name" of record i
> ...etc.
> 
> Worked yesterday, in fact.  Today I get "object not found" with "count 
> of records" highlighted.
> 
> 2.
> 
> tell app "Filemaker Pro"
>     tell database "MyData"
>         tell layout "layout 1"
>             set foo to cell "stuff"
>     end tell
>         end tell
> (do some processing on foo to get bars)
>         tell layout "layout 2"
>         create new records with data {bar1, bar2}
>         end tell
> 
>         tell layout "layout 3"
>     (do some stuff and create a new record)
>         end tell
> 
> Two problems: 
>     a. Layout 2 appears while being processed. I don't want the user to 
> see this. 
> 
>     b. Layout 3 does not appear, and instead of making its new record, 
> the new record is added to layout 2. Why doesn't the tell process work 
> the same for each layout?
>         
> Should be noted that each layout is in a different table.

After a bit more experimenting, it seems that whatever instruction is in 
the script is applied to whatever layout happens to be in front, no 
matter what object you;re telling it to. I would classify this as a bug 
in a supposedly object-oriented language.

So the ideal would be to have a way to direct an instruction to a 
particular layout while it's behind the scenes. The one kluge I've 
thought of is to open it in a new window that's one or two pixels square.

[toc] | [prev] | [next] | [standalone]


#1669

FromErik Appeldoorn <ursus.kirk@gmail.com>
Date2014-01-24 17:44 +0100
Message-ID<lbu59v$qmd$1@dont-email.me>
In reply to#1668
Bill Steele schreef op 24-1-2014 17:37:
> In article <ws21-16E223.16155623012014@70-3-168-216.pools.spcsdns.net>,
>   Bill Steele <ws21@cornel.edu> wrote:
>
>> Several things driving me up the wall today...
>>
>> 1. usually this works:
>>
>> tell layout "whatever"
>> repeat with i from 1 to (count of records)
>> set foo to cell "name" of record i
>> ...etc.
>>
>> Worked yesterday, in fact.  Today I get "object not found" with "count
>> of records" highlighted.
>>
>> 2.
>>
>> tell app "Filemaker Pro"
>>      tell database "MyData"
>>          tell layout "layout 1"
>>              set foo to cell "stuff"
>>      end tell
>>          end tell
>> (do some processing on foo to get bars)
>>          tell layout "layout 2"
>>          create new records with data {bar1, bar2}
>>          end tell
>>
>>          tell layout "layout 3"
>>      (do some stuff and create a new record)
>>          end tell
>>
>> Two problems:
>>      a. Layout 2 appears while being processed. I don't want the user to
>> see this.
>>
>>      b. Layout 3 does not appear, and instead of making its new record,
>> the new record is added to layout 2. Why doesn't the tell process work
>> the same for each layout?
>>
>> Should be noted that each layout is in a different table.
>
> After a bit more experimenting, it seems that whatever instruction is in
> the script is applied to whatever layout happens to be in front, no
> matter what object you;re telling it to. I would classify this as a bug
> in a supposedly object-oriented language.
>
> So the ideal would be to have a way to direct an instruction to a
> particular layout while it's behind the scenes. The one kluge I've
> thought of is to open it in a new window that's one or two pixels square.
>

Don't know much about apple script. But it is default FMP behaviour that 
you can either access a field through a relationship OR it has to be on 
a layout somewhere. Shrinking won't help you much because of all the 
extra stuff (close/maximize etc)

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.

-- 
met vriendelijke groeten,
Erik Appeldoorn

[toc] | [prev] | [next] | [standalone]


#1704

FromBill Steele <ws21@cornel.edu>
Date2014-01-31 16:31 -0500
Message-ID<ws21-82C212.16312831012014@70-3-168-216.pools.spcsdns.net>
In reply to#1669
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

[toc] | [prev] | [next] | [standalone]


#1705

From"E. Appeldoorn" <ursus.kirk@ziggo.nl>
Date2014-02-01 00:09 +0100
Message-ID<66c1a$52ec2d2d$52d97d7f$26704@cache1.tilbu1.nb.home.nl>
In reply to#1704
Bill Steele schreef op 31-1-2014 22:31:
> 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
>

I see no reason for not using native scripting. I have worked with quite 
large text-blocks. Instead of fields I also would suggest using 
variables. It might look something like (pseudo code)

setvariable $List1 = field1
setvariable $List2 = field2
setvariable $countItems = itemcount ($list1)
setvariable $counter = 1
goto other layout
loop
new record
set field1 = item($List1;$counter)
Set field2 = item($list2;$counter)
setvariable $counter=$counter+1
exit loop if $counter=$countItems+1
end loop

Of course this would need tweaking and adapting, but that are the basics.

-- 
met vriendelijke groeten,
Erik Appeldoorn

[toc] | [prev] | [next] | [standalone]


#1709

FromHoward Schlossberg <howard@nospam.fmprosolutions.com>
Date2014-01-31 17:03 -0800
Message-ID<lchh4l$hun$3@news.motzarella.org>
In reply to#1705
On 1/31/2014 3:09 PM, E. Appeldoorn wrote:
>
> setvariable $List1 = field1
> setvariable $List2 = field2
> setvariable $countItems = itemcount ($list1)
> setvariable $counter = 1
> goto other layout
> loop
> new record
> set field1 = item($List1;$counter)
> Set field2 = item($list2;$counter)
> setvariable $counter=$counter+1
> exit loop if $counter=$countItems+1
> end loop

Erik's got the basics here to get you started.  One note is that his 
Item() function is an incorrect translation.  In the English version of 
FileMaker, the correct function name is GetValue() (with the same 
parameters).

[toc] | [prev] | [next] | [standalone]


#1706

FromHelpful Harry <HelpfulHarry@BusyWorking.com>
Date2014-02-01 12:57 +1300
Message-ID<010220141257094277%HelpfulHarry@BusyWorking.com>
In reply to#1704
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)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.databases.filemaker


csiph-web