sirkm@ssyx.ucsc.edu (Greg Anderson) (08/20/88)
I am working on a HyperCard XFCN using LSC 2.15. The statement strcpy(CStr,"junk"); works, but sprintf(CStr,"junk"); causes the XFCN to crash. Is the printf library of LSC incompatible with HyperCard, or am I missing some libraries? I'm linking with strings, sprintf/sscanf, MacTraps and XCmdGlue.c. Greg Anderson || The Temple of Zuul BBS: (408) 462-3832 Social Sciences Computing, UCSC || sirkm@ssyx.ucsc.edu
beard@ux1.lbl.gov (Patrick C Beard) (08/23/88)
In article <4562@saturn.ucsc.edu> sirkm@ssyx.ucsc.edu (Greg Anderson) writes: >I am working on a HyperCard XFCN using LSC 2.15. The statement >strcpy(CStr,"junk"); works, but sprintf(CStr,"junk"); causes the >XFCN to crash. Is the printf library of LSC incompatible with >HyperCard, or am I missing some libraries? I'm linking with strings, >sprintf/sscanf, MacTraps and XCmdGlue.c. The problem is with the way sprintf and the whole printf library is written. This got me down a while back, too. The functions all work by setting certain global variables and calling a core group of functions to do the formatting. Under LSC 2.15, you can't have global variables in code resources (I don't think you can even under 3.0 except for drivers and DA's) and so something strange is happening when you call sprintf. Patrick Beard LBL, beard@ux1.lbl.gov
castan@munnari.oz (Jason Castan) (08/23/88)
> In article <4562@saturn.ucsc.edu> sirkm@ssyx.ucsc.edu (Greg Anderson) writes: > >I am working on a HyperCard XFCN using LSC 2.15. The statement > >strcpy(CStr,"junk"); works, but sprintf(CStr,"junk"); causes the > >XFCN to crash. Is the printf library of LSC incompatible with > >HyperCard, or am I missing some libraries? I'm linking with strings, > >sprintf/sscanf, MacTraps and XCmdGlue.c. > Try LSC 3.0. Set the sprintf project to code resource and do a build library. Remember to use SetUpA4() RestoreA4() in your main(). This is straight from the manual, and I havent done it yet, though I just researched it because I need sprintf real soon now for some code i'm writing. Alternately, if your company (or is it u :-) is too stingy to buy lsc 3.0, just hack the printf*.c sources provided is LSC 2.*. john lim a very satisfied lsc 3.0 user
shane@chianti.cc.umich.edu (Shane Looker) (08/24/88)
>Under LSC 2.15, you can't have global variables in code resources (I don't >think you can even under 3.0 except for drivers and DA's) and so something >strange is happening when you call sprintf. Under LSC 3.0 you can have globals in your code resource. You must do the following at the beginning of your entry. RememberA0(); SetUpA4(); Before you return, do RestoreA4(). This is in the LSC 3.0 manual, in the section of CODE resources. Shane Looker Looker@um.cc.umich.edu