home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 March / macformat-035.iso / Shareware City / Developers / ICAppSourceKit1.2 / ICSubs.p < prev    next >
Encoding:
Text File  |  1995-04-23  |  1.2 KB  |  52 lines  |  [TEXT/CWIE]

  1. unit ICSubs;
  2.  
  3. interface
  4.  
  5.     uses
  6. {$ifc undefined THINK_Pascal}
  7.         Types, 
  8. {$endc}
  9.         ICTypes;
  10.  
  11.     function ICMapErr (icerr: ICError): OSErr;
  12.     function ICGetPrefStr (inst: ICInstance; key: Str255; var attr: ICAttr; var str: Str255): ICError;
  13.     function ICSetPrefStr (inst: ICInstance; key: Str255; attr: ICAttr; str: Str255): ICError;
  14.  
  15. implementation
  16.  
  17.     uses
  18. {$ifc undefined THINK_Pascal}
  19.         Memory, Resources, QuickDraw, AppleTalk, Aliases, Files,
  20. {$endc}
  21.         ICKeys, ICAPI;
  22.  
  23.     function ICMapErr (icerr: ICError): OSErr;
  24.     begin
  25.         if (icerr < -32768) or (icerr > 32767) then begin
  26.             icerr := icInternalErr;
  27.         end; (* if *)
  28.         ICMapErr := icerr;
  29.     end; (* ICMapErr *)
  30.  
  31. {$PUSH}
  32. {$R-}
  33.     function ICGetPrefStr (inst: ICInstance; key: Str255; var attr: ICAttr; var str: Str255): ICError;
  34.         var
  35.             err: ICError;
  36.             size: longint;
  37.     begin
  38.         size := 256;
  39.         err := ICGetPref(inst, key, attr, @str, size);
  40.         if err <> noErr then begin
  41.             str := '';
  42.         end; (* if *)
  43.         ICGetPrefStr := err;
  44.     end; (* ICGetPrefStr *)
  45.  
  46.     function ICSetPrefStr (inst: ICInstance; key: Str255; attr: ICAttr; str: Str255): ICError;
  47.     begin
  48.         ICSetPrefStr := ICSetPref(inst, key, attr, @str, length(str) + 1);
  49.     end; (* ICSetPrefStr *)
  50. {$POP}
  51.  
  52. end. (* ICSubs *)