FileMaker ARGH!!!!
FileMaker ARGH!!!!
- Subject: FileMaker ARGH!!!!
- From: Xandra Lee <email@hidden>
- Date: Sun, 18 Mar 2001 18:33:33 -0500
For Months Ive been calling the script below (embedded as a perform
Applescript step) from an Applet without any problems. TODAY it starts to
blow... entering data in the wrong fields. It enters them correctly if I
run the script from Scripter but not from Filemaker's script menu, or
when called from the Applet.
I can't tell you how .... this annoys me. Any ideas? Since it still runs
correctly independantly, I've no way to test. And feel I'll have to
resort to my usual copout (making it into an Applet).
Thanks in advance,
xandra
Notes:
--"Store Relation Data" Script (this embedded in FMP "Save Database Info"
scriptmaker script step)
--Its called (via do Filemaker script) by all of the create report
Applets (except Create Field Report)
--The script parses relationship and value List data from FMP unstored
calc fields into useable form &
--Creates a record for each Relationship in the desired DB., put Value
List stuff in repeating Fields
--REQUIRES: Akua Sweets "munge"
---SCRIPT BEGINS HERE --Watch LineBreaks!!-----------------
property DBReporterName : "DB Reporter"
property RelationsDBName : "Relations.fp3"
set p to ASCII character 13
set t to ASCII character 9
set l to ASCII character 11 --FMP's character for par's within fields
set theDelim to "" --bullet chars to delim desired repeatbreak within
FMP calc fields
--tell application "FileMaker Pro"
set curRec to current record of database DBReporterName
set dbName to cell "DBName" of curRec
if exists window dbName then
do script FileMaker script "Refresh" of database DBReporterName --necc to
update relationship info
-->>Parse Relationship Names:<<
set rNames to cell "RN List" of curRec --the parDelim list created by
calcField
if rNames is not "" then --only do stuff, IF there are relationships in
the DB:
set rNameRepeat to {"", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", ""} -- clear old data --cell "RNamesRepeat" of curRec --will be
blanks at this point (a field with 16 repeats)
set repID to cell "ReportID" of curRec
set deleteDupIDs to cell "deleteDupRecIDs" of curRec --a preference to
delete all previous rec's in Relations WITH same RepID
set RNamesList to my (pars2Items(rNames, p))
set rCount to count of items of RNamesList --this will be the count of
relationships in the db
repeat with i from 1 to rCount
set item i of rNameRepeat to item i of RNamesList
end repeat
set cell "RNamesRepeat" of curRec to contents of RNamesList -->sets the
repeats so that FMPF will compute "allRInfo" calc field
set cell "RelCount" of curRec to rCount
-->>Parse Relationship Info<<
--Now that info should be in "allRInfo", parse data
set allRInfo to cell "allRInfo" of curRec
--Parse the calcField:
--set theDelim to "" --the chars decided on to sep recs
set enTabbed to munge allRInfo from p to t --change pars to tabmarks
set enParrd to munge enTabbed from theDelim to p --par delim the list
using desired char
set rTabbedList to my (pars2Items(enParrd, p)) --Convert each para to a
list item
set infoList to {}
set i to 1
repeat with i from 1 to rCount
set anR to (item i of rTabbedList)
set RList to my (pars2Items(anR, t))
copy (item i of RNamesList) to beginning of RList
copy repID to beginning of RList
copy RList to end of infoList
end repeat
if deleteDupIDs is "1" then
try
delete (every record of database RelationsDBName whose cell
"ReportID" = repID)
on error
end try
end if
-->>CREATE RELATION RECS<<
tell window RelationsDBName
repeat with z from 1 to rCount
set z to (item z of infoList)
create new record at layout "ASDataIn" with data z
end repeat
end tell
--------------------------------
--create tab delim vers in "DB Reporter":
set rData to "" -- this is text that will stay in DB
set outPutText to "" -- this will be exported
set oneR to ""
repeat with anR from 1 to rCount
set oneR to (item anR of RNamesList) & t & (item anR of rTabbedList) &
p -- should -> "RName tab PK tab etc"
set oneOut to repID & t & oneR --prepend w/report id so relation ship
works (this is the match field for lookups)
set rData to rData & oneR
set outPutText to outPutText & oneOut
end repeat
set cell "Relationships" of curRec to rData -->a tabbed delim
description of all relationships
else --(if there weren't any relationships)
set cell "RelCount" of curRec to 0 --This allows one to check if there
are no relationships clearly.
end if --(if there weren't any relationships)
-----------------------------------
-->>Grab ValueList Data<<
--parse Value List names to a repeat field
set valueNames to cell "ValueNames_c" of curRec
if valueNames is not "" then --only do stuff, IF there are value Lists
in the DB:
set repeatList to {"", "", "", "", "", "", "", "", "", "", "", "", "",
"", "", ""} --set up list for 16 repeats
set cell "ValueNamesRep" of curRec to repeatList --clear old data
--Takes paragraph returned List --> AS List for insertion into
RepeatField:
set VNamesList to my (pars2Items(valueNames, p))
set vCount to count of items of VNamesList
repeat with v from 1 to vCount
set (item v of repeatList) to (item v of VNamesList)
end repeat
set cell "ValueNamesRep" of curRec to repeatList -->Repeating Field
with Value List Names
--now FMP will set "Value
--Now FMP will have set calcField of valueList Items, so parse data to
a repeatfield
set vItems to cell "ValueListItems_c" of curRec
set vList to my (pars2Items(vItems, theDelim))
-->{"", "DB Reporter Feb17", "", "1", "23", "applespearskumquatts",
"", "",...}
set cell "ValueItemsRep" of curRec to contents of vList
end if --(if there were no value lists)
-----------------------------------
else -- (if file wasn't opened)
display dialog dbName & " needs to be open to run this script." buttons
{"Cancel"} default button 1 giving up after 5 with icon caution
end if -- (if file wasn't opened)
--end tell
--Converts each paragraph (or other delim) to a list item
on pars2Items(theText, p) --(theText is paragraph delim
try
set origDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to p
set theList to every text item of theText
set AppleScript's text item delimiters to origDelims
on error
set AppleScript's text item delimiters to {""}
end try
return theList
end pars2Items
Alixandra Leigh
AceDesign
email@hidden
------------------------------------------
Furniture:
><
http://home.rochester.rr.com/alexleighs/furniture/furniture.htm>
Renderings:
><
http://home.rochester.rr.com/alexleighs/interiors/interiors.htm>