Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!sun!pitstop!sundc!seismo!uunet!mcvax!kth!luth!mikael From: mikael@sm.luth.se (Mikael Eriksson) Newsgroups: comp.sys.mac.hypercard Subject: Re: Two Questions (1 HyperTalk, 1 XCMD's)... Message-ID: <225@my6.sm.luth.se> Date: 22 Feb 89 08:26:10 GMT References: <685@gould.doc.ic.ac.uk> <2600@spray.CalComp.COM> Sender: mikael@sm.luth.se Reply-To: Mikael Eriksson Organization: University of Lulea, Sweden Lines: 64 UUCP-Path: {uunet,mcvax}!enea!my6.sm.luth.se!mikael In article <2600@spray.CalComp.COM> anson@spray.UUCP (Ed Anson) writes: >In article <685@gould.doc.ic.ac.uk> np@doc.ic.ac.uk (Nigel Perry) writes: > >>(b) In XCMD/XFCN's is there an official/recommended way of storing globals >>between calls to the XMCD? > >The OFFICIAL way to store globals is to convert the data to text and store >it in a HyperCard global. HyperCard provides call-backs for the purpose. > >Personally, I don't like that idea, since it can be a major performance >problem, not to mention a pain in the ... Another approved way to do this is to have a Handle to the data. (At least it was recommended by the Apple reps here in Sweden.) To save it just convert the *Handle* to text (with NumToHex for example) and save the text in a global. To retrieve the data do a StuffHex. Example: (In TML Pascal) const globalName ='MyHCGlobal'; var saveThis: Handle; globalString: Str255; (* Help routines *) procedure PasSetGlobal(paramPtr:XCMDPtr; name,value: Str255); (* Set global name to value *) var hndl: Handle; begin hndl:=PasToZero(paramPtr,value); SetGlobal(paramPtr,name,hndl); DisposHandle(hndl); end; function PasGetGlobal(paramPtr:XCMDPtr; name:Str255):Str255; (* Return the value of global name *) var hndl: Handle; str: Str255; begin hndl:=GetGlobal(paramPtr,name); ZeroToPas(paramPtr,hndl^,str); PasGetGlobal:=str; DisposHandle(hndl); end; (* To save the data *) PasSetGlobal(paramPtr,globalName,NumToHex(paramPtr,ORD(saveThis),8)); (* To retreive the data *) globalString := PasGetGlobal(paramPtr,globalName); if length(globalString)=8 then begin StuffHex(@saveThis,globalString); ... end else error; -- Mikael Eriksson (Email: mikael@sm.luth.se) ......... You are in error. 2+2=5 Thank you for your cooperation. The Computer.