Hi,
I have some modules apps created in Asoc that require to works or not, that user mac address machine is enabled on pList file that reside on web server.
To manage the database where I have my users and related app that user can be launch, I use FileMaker Pro.
The verification is based on every Asoc app that, at launch, read the pList and enable or not the use of the App.
The question is: there is a short way to write the pList using a list of dictionary?
I need to to this from FileMaker menu, so I cannot use Asoc.
I think to something like default write passing a list of records. Any input?
set pLista to {}
tell application "FileMaker Pro Advanced"
set numRecUtenti to count records of table "Users"
repeat with j from 1 to numRecUtenti
tell record j of table "Users"
set keyUtente to cell "Key User"
set nominativo to cell "Fullname"
set redazione to cell "Area"
set TCP to cell "TCP"
set ethernetAddress to cell "Ethernet Address"
end tell
set numRecApp to count (records of table "Applications" whose cell "Key Application" is keyUtente)
set listaRecords to (records of table "Applications" whose cell "Key Application" is keyUtente)
set listaApplicazioni to {}
repeat with a from 1 to numRecApp
if numRecApp = 1 then
copy (item 2 of listaRecords) to end of listaApplicazioni
else
copy (item 2 of item a of listaRecords) to end of listaApplicazioni
end if
end repeat
copy {nominativo, redazione, TCP, ethernetAddress, listaApplicazioni} to end of pLista
end repeat
end tell
-- Generate the pList
set sharedPath to "/Users/Shared/"
set sharedClassicPath to ((POSIX file sharedPath) as string) & "abilitazioni.plist"
set fileRef to open for access file sharedClassicPath with write permission
set eof of fileRef to 0
write "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" & linefeed to fileRef starting at eof as «class utf8»
write "<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">" & linefeed to fileRef starting at eof as «class utf8»
write "<plist version=\"1.0\">" & linefeed to fileRef starting at eof as «class utf8»
write "<dict>" & linefeed to fileRef starting at eof as «class utf8»
repeat with j from 1 to count pLista
set recordObject to item j of pLista
write "<key>" & item 4 of recordObject & "</key>" & linefeed to fileRef starting at eof as «class utf8»
write "<dict>" & linefeed to fileRef starting at eof as «class utf8»
write "<key>fullname</key>" & linefeed to fileRef starting at eof as «class utf8»
write "<string>" & item 1 of recordObject & "</string>" & linefeed to fileRef starting at eof as «class utf8»
write "<key>area</key>" & linefeed to fileRef starting at eof as «class utf8»
write "<string>" & item 2 of recordObject & "</string>" & linefeed to fileRef starting at eof as «class utf8»
write "<key>ip</key>" & linefeed to fileRef starting at eof as «class utf8»
write "<string>" & item 3 of recordObject & "</string>" & linefeed to fileRef starting at eof as «class utf8»
write "<key>apps</key>" & linefeed to fileRef starting at eof as «class utf8»
write "<array>" & linefeed to fileRef starting at eof as «class utf8»
repeat with a from 1 to count (item 5 of recordObject)
write "<string>" & item a of (item 5 of recordObject) & "</string>" & linefeed to fileRef starting at eof as «class utf8»
end repeat
write "</array>" & linefeed to fileRef starting at eof as «class utf8»
write "</dict>" & linefeed to fileRef starting at eof as «class utf8»
end repeat
write "</dict>" & linefeed to fileRef starting at eof as «class utf8»
write "</plist>" to fileRef starting at eof as «class utf8»
close access fileRef
display dialog "Export complete." buttons {"OK"} default button 1