Newsgroups: comp.sys.apple2.programmer Path: news.weeg.uiowa.edu!news.uiowa.edu!hobbes.physics.uiowa.edu!math.ohio-state.edu!cs.utexas.edu!uunet!math.fu-berlin.de!news.netmbx.de!zelator!tooly From: tooly@zelator.in-berlin.de (Theo Schneider) Subject: >Passing filenames to S16 programs Organization: Public-Access-Unix-System Date: Sat, 09 Oct 1993 11:04:40 GMT Message-ID: Lines: 119 >I need to pass pathnames to S16 programs. I know this is done with >MessageCenter messages. I also know there is an old stlye (pStrings) and >a new style (GS/OS strings). However, I can only find documentation for >the old style. >If there is a technote on the new style, I can't find it in the index. Can >someone tell me where to find it? If not, can someone outline the >procedure? You found the specs for the GS/OS strings in the GS/OS Ref. Manual at page 58. The structure of the GS/OS strings looks like this : GS/OS Input String : gsosInString = record size : integer; theString : packed array [1..254] of char; end; GS/OS Output String : gsosOutString = record maxSize : integer; theString : gsosInString end; if You want do convert an pString to an GS/OS String You can use the follow procedures : procedure P2GSString (theString : pString; var GSString : gsosInString); var i : integer; begin GSString.size := length (theString); i := 0; repeat i := i + 1; GSString.theString [i] := theString [i] until i = GSString.size end; procedure GS2PString (GSString : gsosInstring; var theString : pString); var i : integer; begin theString [0] := chr (GSString.size); i := 0; repeat i := i + 1; theString [i] := GSString.theString [i] until i = GSString.size end; >I also need to know how to know if a particular program will use the old >or new style (or do I need to know this?) so I know which message type to >create. >Even the documentation for the old style in toolbox volume 2 is >ambiguous. Can someone clear it up, please? >Even better, if someone has code that will take a list of strings and do >all the work and are willing to share it, tell me plase! Here is an pascal sample for the use of the messageCenter : procedure CheckMessage; type MessHndl = ^MessPtr; MessPtr = ^MessRec; MessRec = record MessNext : Longint; MessType : integer; MessPrOp : integer; MessData : Array [1..1] of byte end; var msgHandle : MessHndl; sPtr : pStringPtr; FileName : pString; PathName : gsosOutString; begin msgHandle := MessHndl (NewHandle (1, rEditMemID, 0, nil)); MessageCenter (getMessage, 1, msgHandle); if ToolError = noError then begin MessageCenter (deleteMessage, 1, msgHandle); HLock (msgHandle); if msgHandle^^.MessPrOp = 0 then begin sPtr := @msgHandle^^.MessData; while length (sPtr^) <> 0 do begin P2GSString (sPtr^, PathName.theString); PathName.maxSize := PathName.theString.size; { now you can use the PathName to open your file } sPtr := pointer (ord4 (sPtr) + length (sPtr^)+1) end end; end; DisposeHandle (msgHandle); end; I hope this clear some things for You, if You have more questions about the messageCenter feel free to ask. mfg Theo -- +****************************************************************+ * Theo Schneider | Tom Tooly Software Berlin * * Babelsberger Str. 40 | Internet : tooly@zelator.in-berlin.de * * 10715 Berlin | Zerberus : T.Schneider@TeleMail.Zer * * Germany | Phone : ++49 30 854 29 72 * +****************************************************************+