America Online APPLE II DEVELOPMENT FORUM CONFERENCE LOG Tuesday, August 18, 1992 10:00 p.m. Eastern Time Topic: Programming with Resources Forum Leader: Gary Jacobson (AFL GaryJ) AFL GaryJ Welcome to the Apple II Development Forum! AFL GaryJ Tonight's topic (as you've all guessed already :) AFL GaryJ ...is Programming with Resources! AFL GaryJ Let's use forum protocol, so if you have a question, type a "?" on a line AFL GaryJ by itself, or if you have a comment on the current topic, type a "!" on a AFL GaryJ line by itself. AFL GaryJ We have some rather experienced Resource programming people here tonight... AFA Jay Maybe we can get a live Foundation update? :) AFL GaryJ Yes, I was thinking that I'd like to get a Foundation update! M Wolfgram Yes... buy it :) M Wolfgram We released 1.0 at KansasFest... 1.0.1 will be shipping the end of this month (or early Sept) M Wolfgram In other words... Foundation is DONE (at last)... next task: writing a bunch of native editors! AFL GaryJ Great! Foundation is an impressive program... AFL Marty Which editors are first on your list of "things to do"? M Wolfgram First is relative... we're completing a sample editor for rPascal strings (which will be online) M Wolfgram here sooner or later. The real work begins with the window/control/menu suite - which are so M Wolfgram interdependent they all have to be done together. GA AFL GaryJ Sounds good. Do you have any others on your list to get done? AFL Marty You have plans for icon, picture editors, right? M Wolfgram Right... Actually Paul Elseth has an Icon editor that 90% complete - we'll be finishing that up as M Wolfgram soon as I can get Paul to stop being so busy. GA AFC DYAJim Can you paste color icons into the cursor editor? AFC DYAJim (You can't with Genesys and it drives me up a wall when I'm working with AFC DYAJim cursors:) M Wolfgram What cursor editor? When we complete the Icon editor it will do cursors to - colored ones - Yes! AFL GaryJ Does that mean you can paste with it too? AFL GaryJ (or will be able to paste with it) M Wolfgram Yes - The beta versions online did not have the clipboard inplace - Foundation supports full resource M Wolfgram dependency cop/paste - other clipboard support is up to the individual editors. AFL GaryJ Thanks. M Wolfgram Thank you! AFL GaryJ Ok, anyone else have a question about resources or Foundation? AFL GaryJ We're talking about resource programming in general, and are also asking AFL GaryJ questions about the Foundation resource editor. M Wolfgram We did a session at KFest on Programming with resources... M Wolfgram and thought you might like a few words of advice. M Wolfgram Like using the same resource for several things, etc. M Wolfgram If yo happen to use, say a pascal string as the title for two different windows, or perhaps the same M Wolfgram window more than once - so it can appear at the same time - you are asking for problems GNO Jawaid Resources can't be shared? M Wolfgram when you close the first window, it's resources are released, and may dissapear out from under the M Wolfgram second one. Barnabas What about controls in a window? GNO Jawaid How should the resource manager behave in order to fix this problem? M Wolfgram They CAN be shared IF there will not be multiple uses at the same time.or they stay around as in a M Wolfgram menubar with say a divider item that's used multiply. M Wolfgram The resource manager really doesn't know that a resource may already be in use by another toolcall. GNO Jawaid The RM keeps a list of currently loaded resources, right? Why not have it, GNO Jawaid instead of only allowing one load at once, allow multiple loads per resource? M Wolfgram It doesn't keep track of individual resources... it knows if the handle's in memory, but that may be a M Wolfgram transitory thing. Released resources stay in memory until the memory is needed by something else. M Wolfgram The new LoadResource2 call returns the state of a resource (handle attributes or -1) bu no info on the M Wolfgram state as in active or just loaded. GA GNO Jawaid Looks like I'll have to prevent multiple copies of the same app from being GNO Jawaid loaded into SwitchIt. M Wolfgram We hav a monster routine in Foundation that loads and resolves resources to handle reference. That is M Wolfgram pretty much the only way we can have multiple file and type windows coming and going sanely. GA M Wolfgram the callback fSpecialMagic uses that routine and another one to manage handle locl/unlock/dump. M Wolfgram sanely... btw that's the ONLY way editors can use resources for their stuff (no there resource tool M Wolfgram with modules can do that :) GA AFL GaryJ What other "tips" did you cover at KansasFest? M Wolfgram Another tip... make sure all Menu/MenuItem/ItemStruct and menu Pascal strings are locked, fixed M Wolfgram and can't cross bank boundaries. Bad news fro the Menu Manager otherwise. Matt DTS The Menu Manager does not care if your resources cross bank boundaries. Back in 5.0.2 days, it used Matt DTS to care if menu _strings_ crossed bank boundaries, but this is long since fixed. GA. AFC DYAJim Do you still have to lock and fix menu resources then? Matt DTS You never had to. GA. AFC DYAJim So you can just set the attributes to NIL.. cool:) M Wolfgram I've seen problems with unlocked rMenuItem and rPStrings floating out from under the Menu Manager. Matt DTS What kind of problems? M Wolfgram There was - somewhere in the TBR III I believe - a warning on attributes for resourced menu parts. Matt DTS It shouldn't make a whit of difference because the standard menu defproc calls LoadResource every time Matt DTS it needs one of them. That makes it pretty bullet-proof against such things. Can you tell me Matt DTS a chapter and page number? M Wolfgram The only time I've had menu insanity has been with resources that aren't tied down. AFL GaryJ Ok, while we're waiting, let's let Jim ask his question. GA, Jim AFC DYAJim on 28-65 (tbr 3) it states that you specify the initial value of a popup AFC DYAJim control by passing its menu id which it defines as "its relative position AFC DYAJim within the array of items for the menu".. but in practice, isn't it the AFC DYAJim ID in the menu item template? Jim Murphy No, that's simply an item ID number. A technote addressed that one. AFL GaryJ Are you waiting for more answers, or did Jim M. answer to your satisfaction, Jim? GNO Jawaid That one confused me but good for a while. AFC DYAJim I didn't know it was fixed already in a tn.. I just knew it was wrong :) Jim Murphy Jim: One your question, check out IIgs technical note #24, "Apple IIgs Toolbox Reference Updates". Jim Murphy Er, _on_ your question... AFC DYAJim Oh, logical technote, eh :) AFC DYAJim I'll dig it out GNO Jawaid How about a new automatic error dialog from the Menu Manager? If an invalid GNO Jawaid menu ID is entered in the popup record, have the SS say "Please read TN #24" GNO Jawaid :-) GNO Jawaid SS6.0 is user friendly; it's time to make it programmer-friendly :) AFC DYAJim Lol.. have it put a note like that as the default menu item :) Jim Murphy Hey, it's already quite nice. It simply doesn't draw anything in the pop-up. I think that's a big... Jim Murphy flag to the programmer. At least it is for me. GNO Jawaid I had no clue what was wrong when I got the blank entry. GNO Jawaid (I do now, of course). GNO Jawaid Perhaps a programmer's utility that watches tool calls for bizarre errors like GNO Jawaid that? Jim Murphy Well, the blank action is documented somewhere (not sure off hand...). GNO Jawaid Since I very rarely check for error codes on every tool call. Matt DTS Dave's idea of "programmer-friendly" is "Make it call SysFailMgr if it's a bonehead programmer error." Matt DTS (This is generally the toolbox philosphy, too, as CMLoadResource shows.) M Wolfgram The Nov 90 GSTN #60 says that Menu Strings in handles (aka loaded rPString resources) should not cross GNO Jawaid Ack! Ack! That's such an annoying way to drop out. Could we possibly have GNO Jawaid something that allowed us to pop into GSBug or NiftyList? AFC DYAJim Yes, but when you have rezpath bugs it makes them harder than hell to AFC DYAJim track down, Matt. Not too friendly for complex problems. M Wolfgram boundaries (fixed/ncross prefered). :) Jim Murphy Jawaid: I found it. The blank behaviour is documented in TBR III on page 28-65. Jim Murphy "If you pass an invalid item ID, no item is displayed in the pop-up rectangle." GNO Jawaid Hmm... well, it's better than crashing, that's for sure :) AFC JohnC Hey guys...I've got to run..gee come late and leave early...thanks! Matt DTS Marc: "Loaded resources" and "Handles" are not synonymous. M Wolfgram True... but load a resource and what do you get? M Wolfgram The third paragraph states that noCrossBank should be set. Matt DTS "Note that this restriction applies only to menu strings, not the menu templates that can be used with Matt DTS NewMenu2." M Wolfgram I'll concede that nit, Matt... Menu Strings must not cross bank boundaries, but MenuBar, Menu and M Wolfgram MenuItem's can fend for thenselves :) GA Matt DTS If you read all the paragraphs in order, they're warning against when you have menu strings that Matt DTS aren't in your code segments, possibly in your own resource types. Nothing about NewMenu2 resource Matt DTS templates anywhere. M Wolfgram I'm not arguing, Matt. Old habits (and lot's of weirdness) makes one wary - sometime too an extreme M Wolfgram Thanks for letting me review the light :) Jim Murphy Matt: Ask Marc about his views on empty handles. :-) M Wolfgram no no not that :) Matt DTS I'll pass. :) GNO Jawaid Wait- I wanna hear. GNO Jawaid :-) Jim Murphy (I, btw, love them and use them _all_ throughout ScriptEdit and HexEdit :-) GNO Jawaid (just kidding, folks) M Wolfgram I allocate real handles :) Jim Murphy And such is an empty handle. :-) AFC SteveB Handle discrimination? M Wolfgram I bet you like complex numbers too? Jim Murphy Hey, I find the non-existance of something very easy to comprehend. Zero is zero is zero. Simple. :-) Matt DTS Does allocating 3i handles of 64K + 2i bytes each actually free up 6 -192K bytes? M Wolfgram Either you allocate SOMETHING or you don't allocate at all! M Wolfgram Good, Matt! Matt DTS Marc: An empty handle allocates 20 bytes for that handle and moves it into the "used" list. Matt DTS It just points to a block that has no bytes. AFA Jay What's the point of having something for nothing. AFC SteveB The pointer to nowhere? :) AFL Marty Lots of people want something for nothing. :) M Wolfgram Just don't ever dereference it! Matt DTS You can dereference it -- just don't use it if the pointer is NIL. M Wolfgram Is NewHandle/SetHandleSize more efficient than NewHandle (to the right size)? Rhetorical ? Jim Murphy I like being able to allocate a handle that I'll use for some structure that I don't yet have the... Matt DTS Marc: No, NewHandle(right size) is more efficient. Matt DTS (By a completely trivial number of cycles to someone using a higher-level language.) Jim Murphy size calculated for. Then I can simply resize it from zero, without worrying about things. M Wolfgram (which some of us have decended to :) DYA Derek oh - I want to make a custom SFGet file box. I've designed it in Genesys DYA Derek (it's pretty complicated) but now I realize that it needs to be a dialog DYA Derek template.. what's the easiest way to change this into a dialog template? DYA Derek can I to Genesys to produce Rez code and then use that as a starting point? DYA Derek sorry if there's an easy answer but I rarely use the Dialog Manager. M Wolfgram I wrote two routines that load and unload custom dialog resources for that purpose - I'll put it up M Wolfgram in the Lunar library later. M Wolfgram It is... DYA Derek that sounds great. I'll look foreward to seeing it.