🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.mac.programmer.help
5 messages
5 total messages Started by Bill A. Oyler Mon, 21 Aug 1995 05:06
Can an OSType be interchanged with a Str255? How?
#7
Author: Bill A. Oyler
Date: Mon, 21 Aug 1995 05:06
14 lines
994 bytes
Hello,

This should be a simple question.  I need to change the creator of a file
by using the SetFInfo toolbox call.  The creator is stored in a Str255,
however, not in an OSType like the call requires.

How can I convert a Str255 to an OSType?  I tried some different methods
of typecasting, but can't get anything to work.  Help!  :)

=====================================================
Bill A. Oyler               People usually get what's
Minnetonka, MN, USA         coming to them ... unless
oylerb@tdkt.skypoint.net            it's been mailed.
=====================================================
Re: Can an OSType be interchanged with a Str255? How?
#13
Author: F. Degott
Date: Mon, 21 Aug 1995 11:50
41 lines
1720 bytes
In article <oylerb-2108950006040001@msp1-5.nas.mr.net>,
oylerb@tdkt.skypoint.net (Bill A. Oyler) wrote:

>Hello,
>
>This should be a simple question.  I need to change the creator of a file
>by using the SetFInfo toolbox call.  The creator is stored in a Str255,
>however, not in an OSType like the call requires.
>
>How can I convert a Str255 to an OSType?  I tried some different methods
>of typecasting, but can't get anything to work.  Help!  :)
>

Hi Bill,

an OSType is a char array of size 4 (with offset 1).

file manager declaration:

type OSType = PACKED ARRAY [1..4] OF CHAR;

convertion: Str255 to OsType 

var
      Str: Str255;
      OsT: OSType;
      i,l: integer;

Str:='TEXT';{something describing an OSType}
{convertion: Str255 -> OsType}
for i:=1 to 4 do OsT[i]:=' ';{init. OsT with space}
l:=lenght(Str);
if l>4 then l:=4;
for i:=1 to l do OsT[i]:=Str[i]; {copying str to OsT}

Hope this helps.
Fr
-------------------------------------------------------------------------
FR Degott (Francois-Regis.Degott@imag.fr)
Lab. LMC-IMAG - UJF - Grenoble - France
-------------------------------------------------------------------------
Re: Can an OSType be interchanged with a Str255? How?
#15
Author: Martin Adler
Date: Mon, 21 Aug 1995 11:54
22 lines
1075 bytes
In article <oylerb-2108950006040001@msp1-5.nas.mr.net>,
oylerb@tdkt.skypoint.net (Bill A. Oyler) wrote:

> Hello,
> 
> This should be a simple question.  I need to change the creator of a file
> by using the SetFInfo toolbox call.  The creator is stored in a Str255,
> however, not in an OSType like the call requires.
> 
> How can I convert a Str255 to an OSType?  I tried some different methods
> of typecasting, but can't get anything to work.  Help!  :)

Try:

OSType   myOSType;
Str255   myStr255;
...
myOSType = *((OSType *) (myStr255 + 1));
...

Gulpi
= Martin Adler
Re: Can an OSType be interchanged with a Str255? How?
#20
Author: Mark Sproul
Date: Wed, 30 Aug 1995 16:38
32 lines
1222 bytes
In article <oylerb-2108950006040001@msp1-5.nas.mr.net>,
oylerb@tdkt.skypoint.net (Bill A. Oyler) wrote:

> Hello,
> 
> This should be a simple question.  I need to change the creator of a file
> by using the SetFInfo toolbox call.  The creator is stored in a Str255,
> however, not in an OSType like the call requires.
> 
> How can I convert a Str255 to an OSType?  I tried some different methods
> of typecasting, but can't get anything to work.  Help!  :)


OSType  myType;
Str255  string;
long    tempLong;


    tempLong    =   string[1];
    myType      =   tempLong << 24;

    tempLong    =   string[2];
    myType      |=  tempLong << 16;

    tempLong    =   string[3];
    myType      |=  tempLong << 8;


    tempLong    =   string[4];
    myType      |=  tempLong;

Mark
Re: Can an OSType be interchanged with a Str255? How?
#21
Author: Steve Caine
Date: Thu, 07 Sep 1995 03:39
27 lines
1360 bytes
In article <oylerb-2108950006040001@msp1-5.nas.mr.net>,
oylerb@tdkt.skypoint.net (Bill A. Oyler) wrote:

> Hello,
> 
> This should be a simple question.  I need to change the creator of a file
> by using the SetFInfo toolbox call.  The creator is stored in a Str255,
> however, not in an OSType like the call requires.
> 
> How can I convert a Str255 to an OSType?  I tried some different methods
> of typecasting, but can't get anything to work.  Help!  :)

Bill,

Try this.

// CAUTION: This is dangerous on 68000 processors (Plus, Classic, etc.)
// because it can't handle addressing multi-byte values at odd addresses.
// Sometimes &theString[1] will be even, sometimes it will be odd.

Str255   theString = "\pTEXT";
OSType   theType;

if (theString[0] == 4) theType = *(long *)&theString[1];

--
Steve Caine
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads