Path: utzoo!mnetor!uunet!husc6!tut.cis.ohio-state.edu!uwmcsd1!ig!agate!ucbvax!ucdavis!deneb.ucdavis.edu!g099508030ea From: g099508030ea@deneb.ucdavis.edu (Jim Deline) Newsgroups: comp.sys.mac.programmer Subject: Re: Fkeys Message-ID: <1436@ucdavis.ucdavis.edu> Date: 15 Mar 88 05:12:33 GMT References: <3661@super.upenn.edu> Sender: uucp@ucdavis.ucdavis.edu Reply-To: jedeline@deneb.ucdavis.edu.UUCP (Jim Deline) Distribution: comp.sys.mac.programmer Organization: University of California, Davis Lines: 52 Keywords: Fkeys In article <3661@super.upenn.edu> neil@dsl.cis.upenn.edu.UUCP (Neil Radisch) writes: >Is there any special conditions forced upon an fkey routine that effects >the use of variables? > >example >The following works fine > Procedure fkey; > begin > moveto(100,100); > drawstring('hello'); > end; > >The following does nothing > Procedure fkey; > var stuff:str255; > begin > stuff:='hello'; > moveto(100,100); > drawstring(stuff); > end; > >Any ideas....Oh by the way I'm using Turbo Pascal Your problem is, Neil, that you are not allowed to declare global variables in Fkeys. I know that your Fkey "procedure" looks like it declares a local variable, but since it is the 'Main' procedure the compiler treats it like a global declaration. What you can do is declare your Fkey main procedure, then call a procedure outside of main. Other procedures can have local variables. For instance: Procedure WriteSomething; VAR aString: Str255; Begin aString := 'Hello'; moveto(100,100); drawstring(aString) End; Procedure Fkey; { No variables allowed } Begin WriteSomething; End. I am not real familiar with Turbo, but in LightSpeed Fkeys are declared in units, and there has to be a 'Main' procedure. I hope this helps. Jim Deline, UCD Chem Dept.