• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AppleWorks fields on a layout
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleWorks fields on a layout


  • Subject: Re: AppleWorks fields on a layout
  • From: T&B <email@hidden>
  • Date: Sat, 7 Oct 2006 21:31:25 +1000

Hi all,

Following up:

I'm trying to get the location of each field in a layout in an AppleWorks database. I can get as far as locating where all the fields are on the layout, but just not which one is which.

I can't find a way to get the name of the database field that the graphic object field ... represents.

As far as I know there is no way thru official tools.
If you wish I may ask to a friend which has deep knowledge about some structures used by the pair AppleWorks + AppleScript.

Thank you Yvan for the info that you forwarded on. It basically involves getting AppleWorks to copy the field object on the layout, and reading the PICT data in the clipboard.


I had previously looked at whether copying a field object put anything useful on the clipboard, by attempting to paste it into an AppleWorks drawing document. That pasted nothing, so I had mistakenly dismissed that avenue. It turns out that pasting into another program, such as Mail or TextEdit, does actually paste in a PICT of the field, complete with font and border.

The relevant documentation for extracting data from a PICT object is at:
http://developer.apple.com/documentation/mac/pdf/ ImagingWithQuickDraw.pdf
pp. A1-A26, Picture Opcodes in "Imaging With QuickDraw"

If I copy a field object from a layout in my AppleWorks database, Yvan's friend suggests that I coerce the clipboard to a string and search for the opcode of x002B (ie hex 002B or decimal 00 43), then take the text length from the byte that is 4 bytes later, and the text starting 5 bytes later.


That worked for most field objects. But some fields, when copied to the clipboard, just don't contain the x002B opcode. So I can't get the text from them, using the above method. But they paste OK as PICTs (into Mail for instance), and I can see the text in the raw PICT data. For instance, here are a couple:

«data PICT00AC00000000001E0048001102FF0C00FFFE0000004800000048000000000000001E 004800000000001E001AFFFFFFFFFFFF0001000A00000000001E00480009000000000000 0000003100000000001D0048001A0000000000000009FFFFFFFFFFFFFFFF00380001000A 00000000001D0048002C00090004064D6F6E61636F0000030004000D000C002E00040000 00000028000CFFC81253746F636B20666C6F77207265636F7264730000FF»

which contains the field name text "Stock flow records"

and this one:

«data PICT00A40000000000100045001102FF0C00FFFE00000048000000480000000000000010 004500000000001E001AFFFFFFFFFFFF0001000A00000000001000450009000000000000 000000310000000000100044001A0000000000000009FFFFFFFFFFFFFFFF00380001000A 0000000000100044002C00090004064D6F6E61636F0000030004000D000C002E00040000 00000028000CFFFC0B4974656D20436F6465203100FF»

which contains the field name text "Item Code 1".

I had a look at the raw data and found that although they didn't contain the x002B opcode, they do contain the x0028 opcode. The relevant (I think) entries in the QuickDraw documentation are:

Opcode Name Description Bytes of additional data
$0028 LongText txLoc (Point), count (0..255), text 5 + text
$002B DHDVText dh (0..255), dv (0..255), count (0..255), text 3 + text


So, I modified my script to allow for either opcode. Now I can copy a field object from an AppleWorks database layout, then run this:

property x002B : (ASCII character 0) & (ASCII character 43) -- QuickDraw DHDVText opcode
property x0028 : (ASCII character 0) & (ASCII character 40) -- QuickDraw LongText opcode


ClipboardToText()

on ClipboardToText()
set theClipboard to the clipboard
set clipboardString to {{«class TEMP»:theClipboard}} as string
if clipboardString contains x002B then
set afterOpcode to last item in (TextToList of clipboardString between x002B)
set startByteN to 4
else if clipboardString contains x0028 then
set afterOpcode to last item in (TextToList of clipboardString between x0028)
set startByteN to 6
else
error "Can't find x002B or x0028 in clipboard data."
end if
set textLength to ASCII number (character (startByteN - 1) in afterOpcode)
set textFromPICT to text startByteN thru (startByteN + textLength - 1) in afterOpcode
return textFromPICT
end ClipboardToText


on TextToList of containerText between delimiter
	set oldDelims to AppleScript's text item delimiters
	set AppleScript's text item delimiters to delimiter
	set textItems to text items of containerText
	set AppleScript's text item delimiters to oldDelims
	return textItems
end TextToList

It works, with one exception so far. It only works if the name of the field actually appears in the field object. So where I have pop up menu fields without a label in the object itself, or where the whole label doesn't fit, I just get the text " " or "stoc..." instead of the field's actual full name.

Can any QuickDraw/PICT gurus tell me if this approach is safe? That is, is it OK to just search for the last occurrence of each opcode, or do I have to instead be parse the whole pict data into blocks of opcode and data length?

Thanks (especially to Yvan and his friend),
Tom

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: AppleWorks fields on a layout
      • From: Yvan KOENIG <email@hidden>
    • Re: AppleWorks fields on a layout
      • From: Yvan KOENIG <email@hidden>
References: 
 >AppleWorks fields on a layout (From: T&B <email@hidden>)
 >Re: AppleWorks fields on a layout (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re: Applescript equivalent of $0 in shell script
  • Next by Date: Re: AppleWorks fields on a layout
  • Previous by thread: Re: AppleWorks fields on a layout
  • Next by thread: Re: AppleWorks fields on a layout
  • Index(es):
    • Date
    • Thread