STEIN@UCONNVM.BITNET (Alan Stein) (03/08/91)
I've been having problems with functions returning values. For example, the following bombed: float f(x) float x; { return (x*x); } void main () { float y; ... y = f(x); ... } while, changing just those lines to the following works fine: void f (x,py) float x,*py; { y = x*x; } void main () { float x,y; ... f(x,&y); ... } The former seemed to work fine until I added a printer routine to my program. This kind of thing has happened several times, both with functions I've defined myself, as above, and with some functions from the Orca/C library, including some of the string functions (p2cstr,c2pstr, atof,strcpy,strcat) and trig functions (sin). __________________________________________________________ | | | Alan H. Stein | stein@uconnvm.bitnet | | Department of Mathematics | | | University of Connecticut | Compu$erve 71545,1500 | | 32 Hillside Avenue | GEnie ah.stein | | Waterbury, CT 06710 | SNET (203) 757-1231 | |__________________________________________________________|
jimmys@bonnie.ics.uci.edu (Jimmy Shaw) (03/08/91)
Subject: Launching a Sys16 application from a Orca/C Program -------- I am currently trying to write a program in Orca/C that will launch anan other program, namely Finder, Wings, ProSel 16, etc. The program that I am attempting to write will be a Password protection type program, that will prompt the user to enter the password. Once the correct password has been entered, then my program will launch the REAL program selector/manager. So far, I have successfully written the Password part, but for the life of me, I can't find any reference in the Orca/C manual, nor the Tool box refs Vol I, II, regarding launching another application. The Apple IIgs _Programmer' s Intro to the Apple IIgs_ briefly described the procedure, but since Hodge-Podge didn't have anything to do with it, they didn't provide any exact codes in C. (I tried looking the the Tool Ref II, in the Standard File Operation Tool Set, but that only covers load and save, NOT launch.) The only mention of it that even comes to what I want is in the Orca/C manual, where I am told to use System in the Libraries #include <stdlib.h> int system(char *command); I have tried using System("1/system/Finder"); But to my dismay, it works well under the shell, as an EXE file, but when I changed the file to a Sys16, then it won't launch Finder. (I did remember to turn the debugging option off, when making a Sys16 file.) I would be eternally (well, maybe not THAT long :) ) greatful if someone could provide me with the EXACT code for launching a SYS16 program from Orca/C. Jimmy Shaw
toddpw@nntp-server.caltech.edu (Todd P. Whitesel) (03/08/91)
jimmys@bonnie.ics.uci.edu (Jimmy Shaw) writes: >Subject: Launching a Sys16 application from a Orca/C Program > I have tried using > System("1/system/Finder"); > But to my dismay, it works well under the shell, as an EXE file, but That's because the shell must be present for functions like system() to work, since the system() function is intended for a controlling shell. One of the few major deficiences of GS/OS is that there still isn't a memory resident CLI that supports the basic O/S functions (locating and launching files). Shell programs are relied on for this, and the O/S provides lots of neat support for shells, but Orca doesn't use much of it. To get to the point, though: you'll need the Prodos 16 reference OR the GS/OS reference vol. 1 (preferably the latter since you ought to have it anyway if you're serious about programming the GS). They explain the System Loader toolset, which is used to load other programs. I'm sorry I don't have any code examples for you, Jonah Stich might if you ask nicely. Todd Whitesel toddpw @ tybalt.caltech.edu
daveh@ccwf.cc.utexas.edu (David H. Huang) (03/09/91)
In article <27D78C4E.9734@ics.uci.edu> jimmys@ics.uci.edu (Jimmy Shaw) writes: >Subject: Launching a Sys16 application from a Orca/C Program > I would be eternally (well, maybe not THAT long :) ) greatful if >someone could provide me with the EXACT code for launching a SYS16 program >from Orca/C. I don't know how to do it from Orca/C, but the procedure should be very similar to doing it from assembly, since it's just a GS/OS call. Use the QuitGS call with a pcount of 1 and a pointer to the GS/OS class 1 pathname of the application you want to launch. GS/OS class 1 pathnames have a length word in front of them instead of a length byte... Hope this helps! -- David Huang | Internet: daveh@ccwf.cc.utexas.edu | "Slight accidents with funny rays UUCP: ...!ut-emx!ccwf.cc.utexas.edu!daveh | can have serious consequences" America Online: DrWho29 |
neufeld@aurora.physics.utoronto.ca (Christopher Neufeld) (03/10/91)
Another one which got me for several hours last night: I have main(), which passes by value to a subroutine, which passes that same value to yet another subroutine, which writes it to a file with fwrite(). The bytes being written to the file were just plain wrong until I made a change to the savedata() routine: doesn't work: void savedata(a,b,c,...,g) int a; double b,c,**d,**e, etc. { [ fopen ] fwrite (&b,sizeof(b),1,file); ..... return; } It does work when I make the following change: [ as before ] { double hold; [ fopen ] hold = b; fwrite (&hold,sizeof(hold),1,file); .... return; } It looks like the pointer to a passed parameter isn't properly defined. It writes the integer properly, and has no trouble with the **double types, but double gets weird. A possibly related problem is that the 'variables' window in the debugger under Prizm, on the rare occasions that I use it, will not display the value of some variables passed as double, printing **.*** instead, though the variables evaluate properly in algebraic equations. It seems that functions which explicitly make use of the pointer mess up, while those which use the value don't have trouble. -- Christopher Neufeld....Just a graduate student | Note: new host. neufeld@aurora.physics.utoronto.ca Ad astra! | helios will still cneufeld@{pnet91,pro-cco}.cts.com | forward my mail to "Don't edit reality for the sake of simplicity" | me on aurora.
acmfiu@serss0.fiu.edu (ACMFIU) (03/15/91)
Alan, what does orca return in your pseudo-function f()? also, are your functions prototyped (very important to orca). albert
HB03932@SWTEXAS.BITNET (05/22/91)
Here is a quick little question for you "C" guys out there: I am finally getting around to learning "C", but I am having problems getting the getkey() function to work (i.e. you have to hit return/enter to have it "get" the first character). I was wondering if this is a bug in Orca/C (yeah, I have the original version). Is it fixed in the upgrades. Is there a way to re-define it on the version I have? Thanx in advance, Harold J. Bruce Computer Resource Director - Health Professions Southwest Texas State University
jb10320@uxa.cso.uiuc.edu (Jawaid Bazyar) (05/23/91)
HB03932@SWTEXAS.BITNET writes: >Here is a quick little question for you "C" guys out there: >I am finally getting around to learning "C", but I am having >problems getting the getkey() function to work (i.e. you have >to hit return/enter to have it "get" the first character). >I was wondering if this is a bug in Orca/C (yeah, I have the >original version). Is it fixed in the upgrades. Is there a >way to re-define it on the version I have? getkey()? There is no getkey defined as part of the C standard. Perhaps you mean getchar()... getchar() (and in fact all of the C I/O routines) buffer input- in this particular case, the line you're typing. Many systems have a way to put the I/O routines in a 'raw' mode, so you can get single characters at a time, but I don't believe Orca/C supports this. Here's a little routine that will wait for and get a character from the keyboard (sorry, no cursor displayed- but you can set one up by printing an inverse space). char getkey() { char c = 0; asm { sep 0x20 loop: lda 0xE1C000 bpl loop and #0x7f sta c lda 0xE1C010 rep 0x20 } return (char) c; } Yes, it's assembly, but I've been using this for a couple years with no problem. -- Jawaid Bazyar | "Twenty seven faces- with their eyes turned to Graduated!/Comp Engineering | the sky. I have got a camera, and an airtight bazyar@cs.uiuc.edu | alibi.." Apple II Forever! | I need a job... Be privileged to pay me! :-)
mattd@Apple.COM (Matt Deatherage) (05/25/91)
In article <1991May22.225351.13303@ux1.cso.uiuc.edu> jb10320@uxa.cso.uiuc.edu (Jawaid Bazyar) writes: > > getkey()? There is no getkey defined as part of the C standard. >Perhaps you mean getchar()... getchar() (and in fact all of the >C I/O routines) buffer input- in this particular case, the >line you're typing. Many systems have a way to put the I/O >routines in a 'raw' mode, so you can get single characters >at a time, but I don't believe Orca/C supports this. >Here's a little routine that will wait for and get a character >from the keyboard (sorry, no cursor displayed- but you can >set one up by printing an inverse space). > >char getkey() >{ >char c = 0; > > asm { > sep 0x20 >loop: > lda 0xE1C000 > bpl loop > and #0x7f > sta c > lda 0xE1C010 > rep 0x20 > } > return (char) c; >} > > Yes, it's assembly, but I've been using this for a couple >years with no problem. > >-- >Jawaid Bazyar | "Twenty seven faces- with their eyes turned to (Sorry for all the quoting, I thought it appropriate) This routine will fail if the Event Manager is started. With the Event Manager on, the system has a heartbeat task that reads the keyboard and puts the key in the event queue (it would be keyboard interrupts if those worked right). So if you ever do EMStartUp, be careful that you don't use this subroutine or you might have to hit several keys to get one. (Under the Event Manager, just ask GetNextEvent for the next key-down event.) -- ============================================================================ Matt Deatherage, Developer Technical | The opinions expressed herein are Support, Apple Computer, Inc. | not those of Apple Computer, and Personal mail only, please. Thanks. | shame on you for thinking otherwise. ^^^^^^^^ Technical questions are not personal. Please post them instead. ============================================================================