bjb@pyramid.pyramid.com (Bruce Beare) (06/30/89)
I have been having a heck of a time trying to get a custom LDEF to work. I have tried both LSC and MPW Pascal. I believe that I am running into a problem with getting the stack frame correct (pascal arguments, etc). Rather then posting a piece of code that I know doesn't work and waiting for it to be torn apart, could someone post a well written LDEF? If it is MPW (C or Pascal), please also post the makefile. Thank you, Bruce Beare
amanda@intercon.uu.net (Amanda Walker) (07/01/89)
This is short enough that I'll just post it here. LDEFs are about the simplest kind of Mac code resources to write. Here's an LDEF that does the same thing as the default LDEF 0: (THINK C 3.0): ------------------------CUT HERE----------------------- /* Simple Custom LDEF Amanda Walker, InterCon Corporation 6 October 1988 This is a very simple custom LDEF. It acts just like LDEF 0. */ pascal void main(lMessage, lSelect, lRect, lCell, lDataOffset, lDataLen, lHandle) short lMessage; Boolean lSelect; Rect *lRect; Cell *lCell; short lDataOffset, lDataLen; ListHandle lHandle; { lMessage--; /* no initialization needed */ if (!lMessage--) { /* draw the cell */ MoveTo(lRect->left + 5, lRect->top + 12); HLock((**lHandle).cells); TextFont(0); TextSize(0); /* system font & size */ DrawText(*((**lHandle).cells), lDataOffset, lDataLen); HUnlock((**lHandle).cells); if (lSelect) { InvertRect(lRect); } } else if (!lMessage--) { /* toggle highlighting */ InvertRect(lRect); } } ------------------------CUT HERE----------------------- Compile this into a code resource of type LDEF, and off you go. Hope this helps, -- Amanda Walker <amanda@intercon.uu.net> InterCon Systems Corporation -- "Those preachers are right--there's more in these songs than meets the eye..." --Arlo Guthrie
oster@dewey.soe.berkeley.edu (David Phillip Oster) (07/01/89)
In article <75580@pyramid.pyramid.com> bjb@pyramid.pyramid.com (Bruce Beare) writes: >I have been having a heck of a time trying to get a >custom LDEF to work. I see your address is a commercial site. Presumably your request is work related, so my reply is also. I make my living by selling consulting. I charge $80/hour. You may view this as advertising for me, or you could send me a check, and I will reply with a backdated invoice. My address is: David Phillip Oster Mosaic Codes Suite 2036 2140 Shattuck Ave Berkeley, CA 94704 Here is the complete source of an LDEF, in LightSpeed C. It is so complete that you don't even need to include MacTraps in the project. --- David Phillip Oster --When you asked me to live in sin with you Arpa: oster@dewey.soe.berkeley.edu --I didn't know you meant sloth. Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu #include <OsterDefs.h> /* these next two functions are to avoid calling including macTraps in the project */ pascal void HLock(h)Handle h;{ asm{ move.l h,a0 _HLock } } pascal void HUnlock(h)Handle h;{ asm{ move.l h,a0 _HUnlock } } /* main - interface as an LDEF */ pascal void main(mesg, hilit, lrect, lcell, offset, len, list) Integer mesg;Boolean hilit;Rect *lrect;Cell lcell;Integer offset, len;ListHandle list;{ Handle h; if(mesg == lDrawMsg || mesg == lHiliteMsg){ h = (Handle) (**list).cells; HLock(h); DrawItem(lrect, hilit, len, &((*h)[offset])); HUnlock(h); } } /* DrawItem - actually do the work. This reponds to hiliting by drawing a leading checkmark. */ DrawItem(frame, hilit, len, p)Rect *frame;Boolean hilit;Integer len;Ptr p;{ Rect r; r = *frame; EraseRect(&r); TextFont(0); TextSize(12); if(hilit){ MoveTo(r.left, r.top + 11); DrawChar(checkMark); } MoveTo(r.left + 11, r.top + 11); DrawText(p, 0, len); }