[comp.sys.mac.programmer] GetIndString and System 7

resnick@cogsci.uiuc.edu (Pete Resnick/2113674) (06/26/91)

Now that there is a ReadPartialResource routine in System 7, I was
wondering if a) it is used for GetIndString and b) whether it is used
by the Help Manager to read in from STR# resources. I can always split
up my help and error strings better than I am now, but if this is taken
care of, I won't sweat it as much.

pr
--
Pete Resnick             (...so what is a mojo, and why would one be rising?)
Graduate assistant - Philosophy Department, Gregory Hall, UIUC
System manager - Cognitive Science Group, Beckman Institute, UIUC
Internet/ARPAnet/EDUnet  : resnick@cogsci.uiuc.edu
BITNET (if no other way) : FREE0285@UIUCVMD

nerm@Apple.COM (Dean Yu) (06/28/91)

In article <1991Jun26.152232.27719@ux1.cso.uiuc.edu> resnick@cogsci.uiuc.edu (Pete Resnick/2113674) writes:
>Now that there is a ReadPartialResource routine in System 7, I was
>wondering if a) it is used for GetIndString and b) whether it is used
>by the Help Manager to read in from STR# resources. I can always split
>up my help and error strings better than I am now, but if this is taken
>care of, I won't sweat it as much.
>

  GetIndString has always been a glue routine that is implemented by whoever
sells compilers, so we couldn't really re-write it using Partial Resource
calls.  At any rate, you can't really use these calls to implement GetIndString
since ReadPartialResource takes a byte offset from the beginning of the
resource, and you can't know where a string starts in a 'STR#'.

  -- Dean Yu
     Blue Meanie, Negative Ethnic Role Model, Window Cleaner, etc.
     Apple Computer, Inc.
     blah blah blah blah...

zben@ni.umd.edu (Ben Cranston) (06/28/91)

In article <54390@apple.Apple.COM> nerm@Apple.COM (Dean Yu) writes:

>  GetIndString has always been a glue routine that is implemented by whoever
> sells compilers, so we couldn't really re-write it using Partial Resource
> calls.  At any rate, you can't really use [them] to implement GetIndString
> since ReadPartialResource takes a byte offset from the beginning of the
> resource, and you can't know where a string starts in a 'STR#'.

I think the original poster was thinking more along the lines of truly
*huge* STR# resources, where there might not be enough free memory to read
the whole thing in at once.  I could certainly see an implementation of
GetIndString with a fixed-size buffer (maybe on the lines of 10K or so)
that under most conditions of fairly short resources would be about the same
performance as current versions but would gracefully degrade to skipping
through 10K chunks if necessary.  Dean is correct, however, in saying that
the whole resource (up to the desired string) would have to be read because
you cannot compute where the desired string is going to be.

time@ice.com (Tim Endres) (06/28/91)

In article <54390@apple.Apple.COM>, nerm@Apple.COM (Dean Yu) writes:
>   GetIndString has always been a glue routine that is implemented by whoever
> sells compilers, so we couldn't really re-write it using Partial Resource
> calls.

Except for MPW.

> At any rate, you can't really use these calls to implement GetIndString
> since ReadPartialResource takes a byte offset from the beginning of the
> resource, and you can't know where a string starts in a 'STR#'.

Since they are Pascal strings, you can jump off the length bytes,
but I doubt you would see any difference unless you had huge resources
with some type of index.

-------------------------------------------------------------
Tim Endres                |  time@ice.com
ICE Engineering           |  uupsi!ice.com!time
8840 Main Street          |  Voice            FAX
Whitmore Lake MI. 48189   |  (313) 449 8288   (313) 449 9208
-------- USENET: A slow moving self parody.....

sundinKC@dna.lth.se (Anders Sundin) (06/28/91)

Ben Cranston writes:
> I think the original poster was thinking more along the lines of truly
> *huge* STR# resources, where there might not be enough free memory to read
> the whole thing in at once.
For huge STR# resources you might be better off to define your own
resource type, one for each STR#. Use the ID of the new type as index.

Instead of

  resource 'STR#' (1000) {
    "A string",
    "Another string"
  };

You could use

  type 'str1' as 'STR ';
  resource 'str1' (1) {
    "A string"
  };
  resource 'str1' (2) {
    "Another string"
  };

-Anders Sundin
-- 
   -------------------------------------------------------------
  |  Anders Sundin          |  e-mail: sundinKC@dna.lth.se      |
  |  University of Lund     |          ok2aps@gemini.ldc.lu.se  |
  |  Organic Chemistry 2,   |          ok2aps@seldc52.bitnet    |
  |  P.O. Box 124           |   phone:  +46 46 108214           |
  |  S-22100 Lund, Sweden   |   fax:    +46 46 108209           |
   -------------------------------------------------------------