TweetFollow Us on Twitter

Dec 91 Mousehole
Volume Number:7
Issue Number:2
Column Tag:Mousehole

STR# Hurdles

By Larry Nedry, Mousehole BBS SysOp

From: Jslee

Re: STR# Resource

From the frying pan, now into the fire. As you all know the Mac has a toolbox call called GetIndString. This is really cool, but I need to do the same function in reverse, that is, how can I add additional STR# resources to a list of resources? I have yet to find a code fragment demonstrating this technique. What I want to do is add a series of strings to the STR# resource via C (Think to be precise). Looking at IM I-476 I see that STR# resource consists of 2 bytes containing the number of strings then m bytes as the strings. Can I take this to mean:

typdef struct {
  short num_of_strings;
  str63 the_strings[max_strings];
} str_def;

Is this right? If not, how would I do it? I need to have a handle to each string item so that I can write it back to the resource. Any ideas would be great.

From: Mrteague

Re: STR# Resource

You have it partly wrong - because the “strings” are Pascal strings (and it wouldn’t matter of they were C strings), they are NOT of fixed size, which means you can’t use a struct as you have defined. There would be a number of different ways of doing what you need to do, but generally it involves parsing the resource structure yourself - i.e.

{1}

tempHandle = GetResource(‘STR#’,someID);
HLock(tempHandle); tempPtr = *tempHandle;
numStrings = *(short *)tempPtr;
tempPtr += sizeof(short);
for (i = 1; i <= numStrings; i++)
 {
 char tempchar[256];
 short theLength = *tempPtr++;

 strncpy(tempchar, tempPtr, theLength);
 dosomethingwithstring(tempchar);
 tempPtr += theLength;
 }

Then you have to output the new resource - either you have to create a new resource from scratch and add each string to it at a time (sort of the reverse of above), or you can attempt to modify the existing resource in place (remember to detach resource first) - this gets tricky when you insert strings, delete strings, or modify the length of existing strings.

I wrote a HyperCard XMCD that did something similar to this a long time ago, so if you are still stuck after trying my suggestions, I will see what I can do to help.

From: Jslee

Re: Writing to an STR# resource

Hurdle # 1: Parse out the strings from an STR# resource.

Hurdle # 2: Find out how the STR# is organized so you can write back to the resource file.

Hurdle # 3: How can I write out the data in my string to the STR# resource.

I figured out hurdle #1 and #2. #3 is a bit more perplexing. What I did was to create a string that looks like this: “/0/3/5Test1/5Test2/0”. The reason why the string is formatted this way is because this is the way the STR#128 resource (my own resource file in the THINK C project) looks. Now when I create a handle to this string, and try to write out the resource using AddResource nothing is written. When I perform a SizeResource to my handle it returns a -1 which means that the handle to the resource does not exist. I would like to create a handle to my string, then write it out to the STR# resource with a new id. Here is a code fragment:

/* 2 */

do_write()
{
OSErr oserr;
Handle dstHdl;
Ptr destPtr;
int newID;
int checkdigit;
int my_resfile;
OpenResFile(“\pNewRes”);
my_resfile = OpenResFile(“\pNewRes”);
UseResFile(my_resfile);
/*
newStr looks like this:
 “/0/3/5Test1/5Test2/0”
*/
dstHdl = NewHandle(sizeof((char *)&newStr));
oserr = PtrToHand((char *)&newStr,dstHdl,(long)sizeof(newStr));
if (oserr)
{
/*check os error here */
}
HLock(dstHdl);
newID = UniqueID(‘STR#’);
AddResource(dstHdl,’STR#’,newID,”\p”);
WriteResource(dstHdl);
checkdigit = HomeResFile(dstHdl);
/* always shows up as a -1
   meaning that this is not a handle to the resource
   why?,why?,why?
*/
HUnlock(dstHdl);
CloseResFile(my_resfile);
}

From: Mikel

Re: OOP Ignorance

When you say “get at” the Button, are you referring to getting control when the button’s smacked? If so (mind you, I’ve not used THINK C objects, just MacApp), odds are you should declare a class descendent from the type of AcceptButton (TButton, perhaps?) and override the appropriate method. Hope this makes sense.

From: Smug1

Re: OOP Ignorance

Thanks for the help, and I will try in that region. What I want to do is, When someone clicks on that button, to be able to send the message to my routine to do “Whatever”. Sort of like an “On MouseDown” script in HyperCard. I HAVE tried to make a Subclass; maybe I am doing it wrong. Using the same code as before, When I declare a new class (MyButton) and then try to access it, it tells me that “Acceptbutton is not declared. Do I redo the “new(AcceptButton)” routine ?

From: Mikel

Re: OOP Ignorance

I took a peek at some THINK C OOP code and saw that your CButton, when pressed, can send a message to its supervisor (I assume that’s the container view). Call the button’s SetClickCmd method with the appropriate command number (of your choosing). When the user presses the button, the supervisor’s DoCommand method is called with the button’s clickCmd.

In other words, don’t bother creating a new button class. The support is already there.

From: Smug1

Re: OOP Ignorance

Thanks for more of the help. I will give that a try. I figured it was that or “DoGoodClick” but I was not real sure where to assign it. (I am programming in Think Pascal w/TCL, by the way) I will keep marching on, and let you know how it goes.

From: Smug1

Re: OOP Ignorance (Still)

Sorry to keep bothering everyone. If I could get a hint...

Using Think Pascal 3.0 w/TCL & AppMaker, trying to get control of my controls (Mainly, my OK & Cancel buttons). They are made in my window initialization (AppMaker Generated). I try to get a hold of them by using:

Type

MyButton = Object(Cbutton)

Procedure DoGoodClick(WhichPart:integer);

Override;

end;

It shows up in the “Class Browser”, and compiles fine, but in my code area I put:

procedure MyButton.DoGoodClick(WhichPart:Integer);

begin

{Nothing here but a “stop sign” to wait for the step through}

end;

I was just check to see if it would use it, but when I put a “Stop” there, it never goes near it. It stops at CButton’s “DoGood Click” but not mine. Is it my breath ? Any help would be appreciated.

From: Mikel

Re: OOP Ignorance (Still)

Sounds like your object isn’t the one getting into your view. Are you sure your initialization code instantiates a MyButton and not a CButton?

From: Smug1

Re: OOP Ignorance (Still)

Thanks for all the assistance and help. I finally called Bowers Development to ask them if there was a “Suggested” method of overriding their buttons that they have generated.

(Some Background) If you have never used AppMaker (which is a neat program, I think and now supports MacApp) It generates 2 “Modules” for each area--a regular module, and one with a “Z” prefix. The “Z” module should remain unchanged, because it will be regenerated should you change something later with the AppMaker program. But the regular module will be untouched, so you can override & code away, safe in knowing that you won’t wipe out your work if you make a change in the interface.

So I called Bowers, and they said that although it is not recommended to change the “Z” module, you HAVE to change it to assign a “SetClickCmd” to the button, or else recode EVERYTHING. They said they will automatically do this for future versions, but as of yet, this is the way to do it. I feel a little sheepish, but it’s better than still not knowing. Such a simple solution, but the manual said...

From: Smug1

Re: OOP Ignorance (Still)

A better way for me to get control of my button (or anything else for that matter) is NOT to modify the “Z” module of AppMaker, but to override the “IMainWindow” method of the “Z” module in the regular module, “inherit” the “IMainWindow” methods & instance variables, and add the “SetClickCmd there instead. That way, the “Z” module” remains pristine (i.e. no extra coding should I regenerate it). This is getting interesting (dare I say it, almost “Fun”!).

From: Mikel

Re: OOP Ignorance (Still)

Bizarre. Anyway, I’m currently using ViewEdit with MacApp, which is pretty cool, but I’d certainly like to hear more about AppMaker. Do you have their phone number?

From: Smug1

Re: OOP Ignorance (Still)

Yes, I do. As a side note, I ordered this from Japan, as a trade up from Prototyper, and I got it in about 3 days after the transfer of funds reached them. Anyway, the number is: (508) 369-8175 (EST 9-5) or (508) 369-8224 FAX number. Compuserve 70731,3710. Applelink D1721. As I learn more about OOP, and find that AppMaker helps a lot in “Getting idea”, but it must be ok for others too.

From: Midiman

Re: Writing a Macintosh Application

Is there anyone out there who can offer me some guidance in converting a Turbo Pascal program to a Macintosh application? I’ve spent an hour scanning the shelves at Computer Literacy trying to find a book on writing applications but the only thing I could find is MPW and I don’t have the capital to purchase it at this time. I have a Turbo Pascal book by Borland and it has a few applications that come with the software but the documentation is pretty cryptic. One of the examples enables me to write a text file to the screen but I can’t seem to figure out how to write it to an array. I’ve managed to define my menus and my windows but I’m really not too clear on what I’m doing (other than copying the examples in Turbo Pascal).

I also have the first two volumes of Macintosh Revealed but I have had no success using the examples in those books with Turbo Pascal. Any ideas on why that might be? I am not an experienced programmer, I’m pretty much self taught, but I’m not too proud to ask for help from anyone who can point me in the right direction. Any information that you might have in this regard would be greatly appreciated.

From: Walrus

Re: Writing a Macintosh Application

One book I can recommend for Macintosh programming is Macintosh Programming Primer for Think Pascal. This is using a different programming environment than you are. Outside of that, you might be able to find a Mac Turbo Pascal book somewhere, but I’m not sure what kind of selection you have for that. As for your comment that you really don’t feel like you know what you’re doing -- I think that happens with experienced programmers going to the Mac for the first time. If you have little experience outside of the Mac, then your learning curve will be even steeper. But you just have to keep at it and after awhile you’ll get the hang of it. You are best advised to stick with small projects for now (like create a mini application that has a menu that creates different kinds of windows). That way you can get some confidence in using the Toolbox and all that. As your experience increases, then you can go ahead and do some scarier things.

From: Smug1

Re: Writing a Macintosh Application

If you already have Turbo Pascal Mac, then I suggest "Turbo Pascal Tutor" from Borland. It goes through everything, and is pretty easy to follow. If you have not purchased a language, THINK Pascal is a winner. If you buy THINK, then get Mark & Reed's Macintosh Pascal Programming Primer. It's good, and dedicated to THINK. If you want Interface code generators, Prototyper supports Turbo, Think, MPW & TML. It only does procedural code. AppMaker does OOP & Procedures, but not Turbo (Think, MPW, MacApp), however in the long run, it can "Grow" with you. For "Real" reference, you'll need IM 1-6, a wheelbarrow, and a loan. Check your latest "MacTutor" for Ads on these products. Good Luck ! Don't worry about being a beginner. I am too, and you should see (maybe you shouldn't) some of the questions I ask...

From: Midiman

Re: Writing a Macintosh Application

Thanks for the feedback. I don’t think it would be a quantum leap to switch from Turbo Pascal to Think Pascal, but what about doing it in C? I only ask because I’m using my girlfriend’s Mac and she already has Think C. The reason I originally wrote the program in Turbo Pascal is that I thought it would be logical to do it in Pascal (since that’s what the operating system is written in) but the only Pascal she has is the old Borland Turbo Pascal. As far as sticking with simple applications is concerned, I’ve already gotten that far. I have figured out how to define my own menus, windows and sizes. What I can’t seem to do is the simple stuff like a ReadLn. It worked in the original program (which now displaces 20K, and 12 pages of hardcopy), but now it chokes on the ReadLn command even though I think I’ve declared all the necessary resources. Anyway, it’s beginning to look more and more like I’m going to go the Think way (whether it’s C or Pascal remains to be seen). Thanks again for the feedback, if you think of anything else that I might be doing wrong drop me a line.

From: Midiman

Re: Writing a Macintosh Application

Thanks for the response about writing the Mac application. I’m probably going to have to get the loan first before I get the wheelbarrow and Inside Macintosh. I’m not familiar with MacTutor however, is that a magazine? Would I find it at Computer Literacy? Your continued feedback will be greatly appreciated.

From: Smug1

Re: Writing a Macintosh Application

MacTutor is the Mac Programmers Magazine. I’m not sure what Computer Literacy is (Take that how you will...). I live in Japan, so I get it at the T-Zone at outrageous prices (Subscribe? maybe). That’s how I found the Mouse Hole (this BBS) Have fun, don’t hesitate to ask.

From: Pkram

Re: Multifinder & MacTutor

Does anyone remember which issue of MacTutor discussed programming with WaitNextEvent? I only have IM vol’w 1-5, but I think MacTutor had an article about how to use it. (Try volume IV, numbers 2 & 3 for some good MultiFinder articles.-ed)

From: Grinch

Re: Multifinder & MacTutor

It’s in the Programmer’s Guide to Multifinder as well as IM6. Actually, IM6 is more authoritative and it covers system 6 with Multifinder as well as system 7.

From: Jslee

Re: Segment Loader Limits with TCL

Yeah, I am running out of JT during the build (i.e. “data segment too big”). I got rid of a lot of static vars that I did not need. But the strange thing is that this happens ONLY when I venture outside the use of the TCL Libs and functions. What I have done is made two modal dialog routines which have 3 editable text fields. Man, each section of code takes up about 6k of data space. Yeah, I am doing a lot of string manipulation stuff, but I figured that it would give me SOME overhead, but NOT as much as it does. Right now the whole thing is reasonable. I have about 14-15k of data segment space left, so I am being REAL careful.

From: Dave

Re: Segment Loader Limits with TCL

Your overruns MAY be due to too much global data use (strings/global static arrays, etc.) Separate STRs can fix that. So can THINK C 5.0 which is now shipping.

From: Scottab

Re: Think Reference 1.0

Yes, but will the THINK Reference be easier to lug around than Inside Macintosh 1-6 and the X-Ref and far more comprehensive than the Programmer’s Online Companion? If so, I’ll buy it.

From: Walrus

Re: Think Reference 1.0

Think Reference not only gives you the calls for the routines (usually in C rather than Pascal) but tells you what it’s for, what the parameters are and many times gives some snippets of code. It’s much more comprehensive than Online Companion (the Think Ref database is 2.2 Megs) and is easier to lug around and refer to than IM. I haven’t taken Inside Mac DA off my system yet but I certainly don’t use it as much. TR seems to be easier to use.

From: Scottab

Re: Patching Launch trap

It would probably be too much work to patch OpenResFile, as any application can open any other application (read ResEdit). How would you tell that the application was actually launching, and not just opening?

This is a good question. The INIT I wrote a while back that keeps track of the applications launched patches _InitGraf. I will have to dig it up and see if it works under MultiFinder. It seemed at the time to be the perfect trap to patch, as every application should call it, whether or not it has menus, windows, or dialogs.

From: Scottab

Re: HELP! Menu Bar Height

I have heard about this routine, but I couldn’t find any other mention of it, even in the THINK C Mac #interfaces. Have you been able to call it ? If so, how?

What I do now is declare:

      extern int MBarHt : 0x0BAA;

Then just use MBarHt like any other integer. If you desire, and as soon as I get home, I will upload a code fragment that works on every Mac I’ve tried it on.

From: Btoback

Re: HELP! Menu Bar Height

GetMBarHeight is documented in IM5, page 315.

From: Frankh

Re: Serius?

I recently downloaded a demo of Serius, and it looks like an interesting way of generating an application, and it can read externally compiled code (in just about any language, it seems). The demo is pretty simple, but interesting. Does anyone here use the Developer version? How hard is it to generate useful external code for it? What are the drawbacks? Are there any major speed hits?

From: Walrus

Re: Minix on the Mac

Does anyone out there have any experience with Minix on the Macintosh (it’s kind of like a Unix shell)? Does it support programming access to Unix system calls from C? What about awk and sed? The package I saw was for $169 (with source code!) , and I am curious to know how much it simulates a ‘real’ Unix environment.

Yes, I know Apple has A/UX but I have neither an ‘030 machine nor $800 to spring for ‘Unix for the rest of us’.

From: Femur

Re: sound software

I’m looking for a shareware file for the Mac that can let me attach sounds to finder activities. I know I’ve seen this program on some BBS, but I can’t remember what it’s called, or from where I can download it.

Does anyone know what I’m talking about? Thanks.

From: Sysop

Re: sound software

The name of the cdev is SoundMaster. I have just uploaded the latest version (1.7.1) to the System File LIB.

From: Chuckerp

Re: Hacking Laserprep / QuarkPrep

Is anyone else decoding Apple’s Laserprep postscript code? How about QuarkXpress’s preamble? I’ll show you mine if...

From: Smug1

Re: Kanji Fonts

Does anyone have/know of a decent public domain Kanji Laser Font that works with a QMS PS/410 ? I have the fonts that came with my Japanese System, but I can not get the “Font Downloader” utility to see them, and everything comes out Bitmapped. Any info would be appreciated.

From: Mrteague

Re: Sytem 7 and HP DeskWriter

Re your problem with the HP DeskWriter : it would help to tell us what model Mac you are using this printer with. I believe the IIfx has problems with this printer - due to the HP DeskWriter printer driver doing some low level things it shouldn’t have been. As I understand it, problems with the Mac and HP DeskWriter are a fault of HP, not Apple. I also believe HP have fixed this problem some time ago, and there is a new version of the driver available - suggest you contact HP.

From: Scottab

Re: System 7 and HP DeskWriter

Contacting HP is a long and arduous task: they’re too big. I’ve found that dealing with them rarely results in them mailing you the drivers that week. They tried to convince me that the old ones were adequate for my uses. In all, I was disappointed. Try contacting the store you bought it from: they should have a copy and copy it onto your disk for free.

From: Sonnyb

Re: System 7 and HP DeskWriter

I have had a similar problem with DeskWriter. I called HP and apparently there is a problem using the DeskWriter through the serial port while using virtual memory. That is when you get the message “DataComm buffer overrun - no DTR handshake.” HP is working on the problem and will be offering an upgrade soon. This problem does not occur if you use the DeskWriter over an AppleTalk network. If you turn off virtual memory, all is well.

From: Dirks

Re: System 7 and HP DeskWriter

Thanx. Turning off V-memory really solved the problem. Now all I need is a RAM upgrade...

 

Community Search:
MacTech Search:

Software Updates via MacUpdate

Latest Forum Discussions

See All

Fresh From the Land Down Under – The Tou...
After a two week hiatus, we are back with another episode of The TouchArcade Show. Eli is fresh off his trip to Australia, which according to him is very similar to America but more upside down. Also kangaroos all over. Other topics this week... | Read more »
TouchArcade Game of the Week: ‘Dungeon T...
I’m a little conflicted on this week’s pick. Pretty much everyone knows the legend of Dungeon Raid, the match-3 RPG hybrid that took the world by storm way back in 2011. Everyone at the time was obsessed with it, but for whatever reason the... | Read more »
SwitchArcade Round-Up: Reviews Featuring...
Hello gentle readers, and welcome to the SwitchArcade Round-Up for July 19th, 2024. In today’s article, we finish up the week with the unusual appearance of a review. I’ve spent my time with Hot Lap Racing, and I’m ready to give my verdict. After... | Read more »
Draknek Interview: Alan Hazelden on Thin...
Ever since I played my first release from Draknek & Friends years ago, I knew I wanted to sit down with Alan Hazelden and chat about the team, puzzle games, and much more. | Read more »
The Latest ‘Marvel Snap’ OTA Update Buff...
I don’t know about all of you, my fellow Marvel Snap (Free) players, but these days when I see a balance update I find myself clenching my… teeth and bracing for the impact to my decks. They’ve been pretty spicy of late, after all. How will the... | Read more »
‘Honkai Star Rail’ Version 2.4 “Finest D...
HoYoverse just announced the Honkai Star Rail (Free) version 2.4 “Finest Duel Under the Pristine Blue" update alongside a surprising collaboration. Honkai Star Rail 2.4 follows the 2.3 “Farewell, Penacony" update. Read about that here. | Read more »
‘Vampire Survivors+’ on Apple Arcade Wil...
Earlier this month, Apple revealed that poncle’s excellent Vampire Survivors+ () would be heading to Apple Arcade as a new App Store Great. I reached out to poncle to check in on the DLC for Vampire Survivors+ because only the first two DLCs were... | Read more »
Homerun Clash 2: Legends Derby opens for...
Since launching in 2018, Homerun Clash has performed admirably for HAEGIN, racking up 12 million players all eager to prove they could be the next baseball champions. Well, the title will soon be up for grabs again, as Homerun Clash 2: Legends... | Read more »
‘Neverness to Everness’ Is a Free To Pla...
Perfect World Games and Hotta Studio (Tower of Fantasy) announced a new free to play open world RPG in the form of Neverness to Everness a few days ago (via Gematsu). Neverness to Everness has an urban setting, and the two reveal trailers for it... | Read more »
Meditative Puzzler ‘Ouros’ Coming to iOS...
Ouros is a mediative puzzle game from developer Michael Kamm that launched on PC just a couple of months back, and today it has been revealed that the title is now heading to iOS and Android devices next month. Which is good news I say because this... | Read more »

Price Scanner via MacPrices.net

Amazon is still selling 16-inch MacBook Pros...
Prime Day in July is over, but Amazon is still selling 16-inch Apple MacBook Pros for $500-$600 off MSRP. Shipping is free. These are the lowest prices available this weekend for new 16″ Apple... Read more
Walmart continues to sell clearance 13-inch M...
Walmart continues to offer clearance, but new, Apple 13″ M1 MacBook Airs (8GB RAM, 256GB SSD) online for $699, $300 off original MSRP, in Space Gray, Silver, and Gold colors. These are new MacBooks... Read more
Apple is offering steep discounts, up to $600...
Apple has standard-configuration 16″ M3 Max MacBook Pros available, Certified Refurbished, starting at $2969 and ranging up to $600 off MSRP. Each model features a new outer case, shipping is free,... Read more
Save up to $480 with these 14-inch M3 Pro/M3...
Apple has 14″ M3 Pro and M3 Max MacBook Pros in stock today and available, Certified Refurbished, starting at $1699 and ranging up to $480 off MSRP. Each model features a new outer case, shipping is... Read more
Amazon has clearance 9th-generation WiFi iPad...
Amazon has Apple’s 9th generation 10.2″ WiFi iPads on sale for $80-$100 off MSRP, starting only $249. Their prices are the lowest available for new iPads anywhere: – 10″ 64GB WiFi iPad (Space Gray or... Read more
Apple is offering a $50 discount on 2nd-gener...
Apple has Certified Refurbished White and Midnight HomePods available for $249, Certified Refurbished. That’s $50 off MSRP and the lowest price currently available for a full-size Apple HomePod today... Read more
The latest MacBook Pro sale at Amazon: 16-inc...
Amazon is offering instant discounts on 16″ M3 Pro and 16″ M3 Max MacBook Pros ranging up to $400 off MSRP as part of their early July 4th sale. Shipping is free. These are the lowest prices... Read more
14-inch M3 Pro MacBook Pros with 36GB of RAM...
B&H Photo has 14″ M3 Pro MacBook Pros with 36GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 Pro MacBook Pro (... Read more
14-inch M3 MacBook Pros with 16GB of RAM on s...
B&H Photo has 14″ M3 MacBook Pros with 16GB of RAM and 512GB or 1TB SSDs in stock today and on sale for $150-$200 off Apple’s MSRP, each including free 1-2 day shipping: – 14″ M3 MacBook Pro (... Read more
Amazon is offering $170-$200 discounts on new...
Amazon is offering a $170-$200 discount on every configuration and color of Apple’s M3-powered 15″ MacBook Airs. Prices start at $1129 for models with 8GB of RAM and 256GB of storage: – 15″ M3... Read more

Jobs Board

*Apple* Systems Engineer - Chenega Corporati...
…LLC,** a **Chenega Professional Services** ' company, is looking for a ** Apple Systems Engineer** to support the Information Technology Operations and Maintenance Read more
Solutions Engineer - *Apple* - SHI (United...
**Job Summary** An Apple Solution Engineer's primary role is tosupport SHI customers in their efforts to select, deploy, and manage Apple operating systems and Read more
*Apple* / Mac Administrator - JAMF Pro - Ame...
Amentum is seeking an ** Apple / Mac Administrator - JAMF Pro** to provide support with the Apple Ecosystem to include hardware and software to join our team and Read more
Operations Associate - *Apple* Blossom Mall...
Operations Associate - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Read more
Cashier - *Apple* Blossom Mall - JCPenney (...
Cashier - Apple Blossom Mall Location:Winchester, VA, United States (https://jobs.jcp.com/jobs/location/191170/winchester-va-united-states) - Apple Blossom Mall Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.