#: 3217 S3/Languages 01-May-90 22:37:23 Sb: #3199-#F$Chain question Fm: Bill Dickhaus 70325,523 To: Zack Sessions 76407,1524 (X) Zack, As Pete said, use something other than 0, since the data area is at least 256 bytes, then leas 255,u should always work. Using 0 causes the stack to start 0 off of U, but since the stack is used "backwards", the page preceding the one pointed to by U will get zapped. (You probably already know this, but in case someone else is wondering) a PSHS X instruction does the same thing as STX ,--S. Whenever a register is pushed on the stack, the stack pointer is decremented. So the stack pointer is usually set to the end of the area to be used for the stack. Bill There is 1 Reply. #: 3225 S3/Languages 02-May-90 16:24:39 Sb: #3217-F$Chain question Fm: Zack Sessions 76407,1524 To: Bill Dickhaus 70325,523 Thanks, Bill, (And You TOO Pete) the leas 255,u solved the problem perfectly! Thanks a bunch, guys. Zack #: 3305 S3/Languages 06-May-90 10:42:00 Sb: #C arrays Fm: Mark Griffith 76070,41 To: All To all: I have uploaded a file into Library 3, called "arrays.txt". This is my comments on the discussion going on in this forum. Please feel free to comment on it as you like. I am also (like Pete), going out of town for a few days. I'm looking forward to the replies that I'm sure will be posted when I get back. Mark There are 2 Replies. #: 3308 S3/Languages 06-May-90 15:16:59 Sb: #3305-C arrays Fm: Bruce MacKenzie 71725,376 To: Mark Griffith 76070,41 (X) Again, I'll have to come to Jeff's defense. I think that nearly everything he's said has been right on the mark, but unfortunately he's been misconstrued. First, lets forget about initialization and memory allocation. That's a side issue and confuses things. Let's talk about pointers and their attributes. Arrays ar implemented in C as pointers. A one dimension array, say char p[12], is implemented as a pointer, p, which is a pointer to the simple data type, char. p[1] is only another way of saying *(p+1), ie what's pointed to by p after it has been incremented by 1. Now a two dimension array, say p[2][12], again is implemented as a pointer, p, which now is a pointer to the complex data type, 'array of 12 characters'. Since the data type is itself an array, implicit in this definition are two pointers, p[0] and p[1] (these are not true variables, stored in memory, but are derived on the fly by incrementing p). These are pointers to the simple data type, char, and point to the start of each 12 character array. So in this manner multidimension array handling is built up by a recursive application of the properties of pointers. Jeff was right on when he said that multidimension arrays are really arrays of arrays. #: 3328 S3/Languages 06-May-90 20:35:01 Sb: #3305-C arrays Fm: Jeff Dege 76426,211 To: Mark Griffith 76070,41 (X) I just read your file ("arrays.txt"), and you seem to suffering from the idea that there are multi-dimensional arrays in C. THERE AIN'T NO SUCH BEAST! "int foo[2][6];" does NOT declare a 12 element array, each of which is an int; it declares a 2 element array, each of which is an array of 6 ints. There is a WORLD of difference. #: 3350 S3/Languages 07-May-90 18:47:26 Sb: #BASIC09 Help Fm: Floyd Resler 72500,2572 To: All Does anyone know how to get something from a GET/PUT buffer in BASIC09 and put the information into an array? I basically want to do the same thing as loading a get/put buffer from disk into an array. There is 1 Reply. #: 3354 S3/Languages 07-May-90 20:40:15 Sb: #3350-#BASIC09 Help Fm: Kevin Darling (UG Pres) 76703,4227 To: Floyd Resler 72500,2572 (X) Floyd - need more info: what will the array contain? Pixel colors? Are you already capable of loading a buffer from disk into an array? If so, then peeking in order thru the buffer will be the same virtual thing. You'd first have to map the buffer into your basic09 space tho. See GRAB.AR in Lib 10 for an example. And I'll give you details as we find out what you're needing - kev There is 1 Reply. #: 3360 S3/Languages 08-May-90 17:32:41 Sb: #3354-#BASIC09 Help Fm: Floyd Resler 72500,2572 To: Kevin Darling (UG Pres) 76703,4227 (X) After I posted this message a friend of mine told me about mapping the GET/PUT buffer into the work space and then peeking the data. Quite easy, actually. Don't know why I didn't think of it before! I'm working on a 16 color, 16x16 pixel icon editor. I ran into the problem when I started working on my Icon Set options. Basically, the user can put several icons into one file. This is much more handy, and quicker, than saving icons seperately (which a user can, if he wants). I plan to package this editor along with my MultiEdit program (an AIF/Icon editor for MV) along with a game demonstrating the use of icons created with the editor. Floyd There is 1 Reply. #: 3361 S3/Languages 08-May-90 18:17:40 Sb: #3360-#BASIC09 Help Fm: Kevin Darling (UG Pres) 76703,4227 To: Floyd Resler 72500,2572 (X) Floyd - great! Yell if you run into troubles. One hint: do any GETs on byte boundaries. That is, on X coord's 0,3,7.. if in 4 color, 0,2,4 if in 16 color, and 0,7,15... if in two color. That way, the buffer is aligned to the left bitwise. Oh and try to end with on a byte boundary too. Do you see what I mean? - kev There is 1 Reply. #: 3379 S3/Languages 09-May-90 16:44:10 Sb: #3361-BASIC09 Help Fm: Floyd Resler 72500,2572 To: Kevin Darling (UG Pres) 76703,4227 (X) Yep, I know what you mean. Of course, with 16x16 pixel icons that's real easy! Can't wait to get it finished. I was inspired to write this program from a similiar utility in Rainbow for BASIC. I liked it and wanted one under OS9. By the way, whatever happened to the OS9 version of Kyum-Gai? Floyd #: 3472 S3/Languages 13-May-90 21:23:48 Sb: #F$Fork Fm: GLEN HATHAWAY 71446,166 To: all Hi all... Having a bit of a problem forking a child process. I'm writing a LF stripper in assembler and want to fork Rename to rename the output file to the original name of the file. It won't work and I'm not sure what I'm doing wrong. If you think you can give me a hand, let me know, and I'll upload it via EMail to you. Thanks... There is 1 Reply. #: 3473 S3/Languages 13-May-90 21:58:43 Sb: #3472-#F$Fork Fm: Kevin Darling (UG Pres) 76703,4227 To: GLEN HATHAWAY 71446,166 (X) Glen - why don't you strip out the sections where you do the fork, and post it here in a msg? (be sure to use the post/store unformatted (SU) option so the lines don't get scrunched up). One thing is: Y= the size of the parameters in BYTEs, not pages... and you should probably end the parameter line in a space or CR to delimit the filename you're renaming. What kind of error do you get? There are 2 Replies. #: 3475 S3/Languages 13-May-90 23:47:27 Sb: #3473-#F$Fork Fm: GLEN HATHAWAY 71446,166 To: Kevin Darling (UG Pres) 76703,4227 (X) Hi Kev... You're kidding!?! Those twits who put the manual together said pages! Anyway, I don't get any error at all, it just doesn't rename the file. Drat! I just tried to upload the file segment, but I use OSTerm, and it won't send ASCII dumps (at least I have never figured out how to make it work). I'll try changing the parameter size to bytes and if that doesn't work, I'll put that part of the program up as EMail to you, OK? There is 1 Reply. #: 3485 S3/Languages 14-May-90 09:45:05 Sb: #3475-#F$Fork Fm: Steve Wegert 76703,4255 To: GLEN HATHAWAY 71446,166 (X) Glen, You can use a protocol while uploading a message. Type UPL and go from there! Steve There is 1 Reply. #: 3493 S3/Languages 14-May-90 21:15:29 Sb: #3485-#F$Fork Fm: GLEN HATHAWAY 71446,166 To: Steve Wegert 76703,4255 (X) Hi Steve... Really! I didn't know that. I'll have to try it next time I have an unkillable bug. Thanks... There is 1 Reply. #: 3516 S3/Languages 15-May-90 20:36:55 Sb: #3493-#F$Fork Fm: Steve Wegert 76703,4255 To: GLEN HATHAWAY 71446,166 (X) Glen, Just to elaborate a bit further, the UPLoad command is supported at the MESSAGES prompt (just type mess) and within the forum editor by issuing the command /upl . Hope this helps Steve There is 1 Reply. #: 3524 S3/Languages 16-May-90 00:45:06 Sb: #3516-F$Fork Fm: GLEN HATHAWAY 71446,166 To: Steve Wegert 76703,4255 (X) Thanks Steve... Now if I can only remember that next time I need it... #: 3476 S3/Languages 13-May-90 23:58:45 Sb: #3473-#F$Fork Fm: GLEN HATHAWAY 71446,166 To: Kevin Darling (UG Pres) 76703,4227 (X) Hi Kevin... Just tried it with Y in bytes and that cured it completely. There are times when this manual really bugs me. Costs a lot of time debugging something that's not a bug at all - just a stupid typo! Anyway, once I get one more little deficiency worked out of this thing, I'll upload it here - not that anyone needs yet another file stripper, but what the hey! They'll get another anyway... There is 1 Reply. #: 3477 S3/Languages 14-May-90 00:48:11 Sb: #3476-#F$Fork Fm: Kevin Darling (UG Pres) 76703,4227 To: GLEN HATHAWAY 71446,166 (X) Glen - glad to hear you got going. I think that particular manual mistake has been in there since day 1 of OS9's existence . Once you think about it, pages doesn't really make sense there. Hindsight speaking, of course. Hehe. - kev There is 1 Reply. #: 3478 S3/Languages 14-May-90 01:37:34 Sb: #3477-F$Fork Fm: GLEN HATHAWAY 71446,166 To: Kevin Darling (UG Pres) 76703,4227 (X) Hi Kevin... Well, I'm done. It still won't strip files bigger than 64K, but I'll work on that later. 99% of my text downloads are smaller then 64 anyway. So I'm going to upload it as-is. Take a look if ya want, but you'll find it pretty tame stuff, compared to what you're used to working with. Thanks for the help... #: 3474 S3/Languages 13-May-90 22:22:41 Sb: #problems with os9fork Fm: BRETT 72057,3720 To: C gurus Greeting- I have two questions for some one longer in the tooth than I. 1. Is there any way to transfer files between Dynacalc and Lotus 1,2,3? 2. Is there any way to redirect input on an os9fork call in C? example code follows static char mail_args[] = " foo!foobar!user < dead.letter"; os9fork("mail",strlen(mail_args),mail_args,1,1,0); These two lines always cause mail to take input from stdin, not from dead.letter as it should (IMHO). HELP! this is giving me some trouble with things I am working on for the uucp package. -Brett uucp............marob!nsi1!cassie!wa3yre!wynkoop There are 2 Replies. #: 3482 S3/Languages 14-May-90 08:54:26 Sb: #3474-problems with os9fork Fm: Bill Dickhaus 70325,523 To: BRETT 72057,3720 (X) Brett, I can't help you with question #1, but I can with #2. To use redirection, pipes, and any other shell functions, you must use the system() function OR fork shell using the complete command line as you would type it in from the keyboard. In your code fragment, you are actually passing all that stuff to mail, and it doesn't know what to do with it. System is easier to use, since you don't have to put in all those other parameters. This is your code modified to use the system() function: char *mail_arg = "mail foo!foobar!user < dead.letter"; system(mail_arg); If the command line is constant, you could also use: system("mail foo!foobar!user < dead.letter"); You can also use functions like strcpy() and strcat() to build up a command line, something like: char *user; strcpy(user, "foo") sendlet(user); .... sendlet(user) char *user; { char cmdline[50]; /* make sure this is big enough, or use malloc */ system(strcat(strcat(strcpy(cmdline, "mail "),user)," There seems to be a small problem with fseek() in the Kreider library. >I am using fseek(fp, --p, 2); to position the file pointer at the end >of a file and then back up character by character. Is the variable "p" initilized as a LONG? I use the exact same code in the version of TAIL that I wrote and it works just dandy. Mark There are 2 Replies. #: 3642 S3/Languages 21-May-90 05:43:25 Sb: #3639-#Kreider fseek() bug Fm: James Jones 76257,562 To: Mark Griffith 76070,41 (X) Gee...you caught the mistake I usually make when using fseek(). Wish I had a nickel for each time etc. There is 1 Reply. #: 3665 S3/Languages 21-May-90 22:03:12 Sb: #3642-Kreider fseek() bug Fm: Mark Griffith 76070,41 To: James Jones 76257,562 (X) James, He he....yeah, I'm real careful about that stuff now. Mark #: 3699 S3/Languages 22-May-90 17:26:17 Sb: #3639-Kreider fseek() bug Fm: David George 72240,134 To: Mark Griffith 76070,41 Yes I have p as long ( long p = 0L; ) Did you compile your version of TAIL with the Kreider Clib.l or Microware. I only have the problem with the Kreider Clib David #: 3652 S3/Languages 21-May-90 10:46:03 Sb: #3635-Kreider fseek() bug Fm: Pete Lyall 76703,4230 To: David George 72240,134 (X) David - Interesting problem. I also have a small problem like that in my 'more' program... backing up too far. Try dropping a note directly to Carl on this... (71076,76). Also, I'll have a look a few things here. (I have all the clib sources, but not always the ability to unearth the problems!)... Pete #: 3700 S3/Languages 22-May-90 17:33:31 Sb: fseek() function Fm: David George 72240,134 To: 71076,76 Carl, I seem to be having a small problem with the fseek() call in your library. When I use fseek(fp, --p, 2) to postion the pointer at the end of a file and read backwards it (fseek) go back to far. This is for the TAIL program. I have compiled successfully on both my Atari with Professional OS9 and with the standard Microware CLIB.L However I like the additional features your lib offers so I use it whenever possible. Also any news on when a 68K version of your CLIB will be available? I especially like the password functions. David George 72240,134 Press !>1 #: 3760 S3/Languages 23-May-90 22:37:53 Sb: #Silly questions Fm: GLEN HATHAWAY 71446,166 To: All Hi all... Is it possible to use attribute bytes (as when programming in RSDOS assembler) to control the look of text in an OS-9 assembly program? Are the attribute bytes part of the hardware? Are they still there (accessed by display codes) or is text handled in a completely different way? Would sure be handy - in my program I have text already printed that I want to highlight selected sections of, but I'm not sure how, other than rewriting it. I guess using attr bytes would mean cheating, unless someone wrote some kind of program to access them so one wouldn't have to write directly to screen (though the access program would write directly...). Hmmm... Is there an easy way to set up a text screen, VDG style, so that the process can write directly to it and do it 'legally'? Albert Marsh 76234,2740 uploaded a set of Basic09 procedures that I think do something very similar, but I've had trouble making it work. I think he uploaded it as fastes.ar. The B09 file is called LoadSave.B09. Any ideas? Would definitely make things move MUCH faster - I know, cause I'm porting my RSDOS assembler program to OS-9 and finding OS-9 unacceptably slow, even using all the tricks I can find to make it faster (buffering large amounts of screen data before writing it). The program, under RSDOS, was great. In OS-9, it falls a bit short... So far anyway... There is 1 Reply. #: 3763 S3/Languages 23-May-90 22:48:41 Sb: #3760-#Silly questions Fm: Pete Lyall 76703,4230 To: GLEN HATHAWAY 71446,166 (X) Glen - Not sure about the attribute question... do you mean to cause the listing to be highlighted? If that's what you mean, then probably not. If you just want to see part of a listing, you can embed OPT directives for 'l' and '-l' to turn listing on and off. Re: writing to VDG screens... I believe so. You can use a i$getstt call to get the base of screen memory, and then use that as a working pointer for your operations. Again, that's VDG only. Pete There is 1 Reply. #: 3765 S3/Languages 24-May-90 00:37:20 Sb: #3763-#Silly questions Fm: GLEN HATHAWAY 71446,166 To: Pete Lyall 76703,4230 (X) Hi Pete... Here's the situation: I have a screen full of text. I want to search through the buffer it was written from for a match to a string of bytes (ie. FF00). When (if) a match is found, I want to highlight the text on the screen. Thing is, I don't want to use a VDG screen if I can help it. Y If what I think is correct, I can't use overlay windows on a VDG, right? If I can't use overlay windows, the whole thing gets pretty tough. Hmmm... It used to run without them under RSDOS, and worked well - but expectations were lower then. Maybe I'll try it with a VDG screen and see what I think... There is 1 Reply. #: 3775 S3/Languages 24-May-90 10:04:26 Sb: #3765-#Silly questions Fm: Pete Lyall 76703,4230 To: GLEN HATHAWAY 71446,166 (X) Glen - Getting out of my territory here.. the winders gurus are Kevin, Mark, and that crowd. I believe your assumptions are basically sound though. I don't know if there's a way to manipulate a non-VDG window in the way you describe, without cheating. One possibilty: have a look at VEFIO in the DL10 area... it does some organized, controlled cheating (if there is such a thing) along the lines you're working with. Pete There is 1 Reply. #: 3788 S3/Languages 24-May-90 20:55:16 Sb: #3775-Silly questions Fm: GLEN HATHAWAY 71446,166 To: Pete Lyall 76703,4230 (X) Hi Pete... VEFIO I have looked at, but it's SO complex! I really don't want my program to have to rely on it. I'm still trying things... #: 3782 S3/Languages 24-May-90 18:57:04 Sb: #3673-F$Fork Fm: Bill Dickhaus 70325,523 To: Pete Lyall 76703,4230 (X) Pete, That's exactly what I did in a recent utility I wrote. I could only guesstimate the actual size of the output file, so I set the size to the max I thought it might be, to try to get it in one contiguous chunk, if possible. Then I just made sure to set the file size equal to the current position in the file when all done, works great, no counters to maintain! Bill #: 3806 S3/Languages 26-May-90 01:02:01 Sb: #3804-#BASIC09 Help Fm: Kevin Darling (UG Pres) 76703,4227 To: Colin Smith 73777,1360 (X) Colin - here's a test program which maps in a buffer, and just Gets a char at a location each time the mouse button is pressed, and Peeks the mapped-in buffer. Study it and ask Q's. PROCEDURE SpotTest (* Gets a char from Text Screen: BASE 0 TYPE registers=cc,a,b,dp:BYTE; x,y,u:INTEGER DIM reg:registers DIM Mouse(32):BYTE DIM I_GetStt:BYTE \I_GetStt=$8D DIM SS_Mouse:BYTE \SS_Mouse=$89 DIM F_ID:BYTE \F_ID=$0C DIM X1,Y1,Group,BuffNum,BuffLoc:INTEGER DIM oldx,oldy:INTEGER GOSUB 100 \(* Find a Group to Use *) RUN gfx2("Get",Group,BuffNum,1,1,2,1) RUN MapBuff(Group,BuffNum,BuffLoc) LOOP GOSUB 200 \(* Get Mouse coord IF X1<>oldx OR Y1<>oldy THEN RUN gfx2("CurXY",X1,Y1) oldx=X1 \oldy=Y1 ENDIF IF Mouse(8)<>0 THEN RUN gfx2("Get",Group,BuffNum,X1,Y1,2,1) RUN gfx2("CurHome") PRINT "Value is: "; PRINT PEEK(BuffLoc); PRINT " Character is: "; PRINT CHR$(PEEK(BuffLoc)); PRINT " " PRINT "--------------------------------"; RUN gfx2("CurXY",X1,Y1) ENDIF ENDLOOP (* ****************************************** 100 (* Find a Group via our ID RUN Syscall(F_ID,reg) \Group=reg.a \BuffNum=1 ON ERROR GOTO 110 RUN gfx2("KillBuff",Group,0) 110 ON ERROR RETURN (* ****************************************** 200 (* Get Mouse Coords: reg.a=0 reg.b=SS_Mouse reg.x=ADDR(Mouse) reg.y=1 RUN Syscall(I_GetStt,reg) X1=(Mouse($18)*256+Mouse($19))/8 Y1=Mouse($1B)/8 RETURN There is 1 Reply. #: 3864 S3/Languages 27-May-90 13:47:49 Sb: #3806-BASIC09 Help Fm: Colin Smith 73777,1360 To: Kevin Darling (UG Pres) 76703,4227 OK. Thanks a million. I'll see what I can do with it. Again, thanks. --Colin #: 3807 S3/Languages 26-May-90 01:02:18 Sb: #3804-BASIC09 Help Fm: Kevin Darling (UG Pres) 76703,4227 To: Colin Smith 73777,1360 (X) (* ****************************************** PROCEDURE MapBuff PARAM Group,BuffNum,BuffLoc:INTEGER TYPE registers=cc,a,b,dp:BYTE; x,y,u:INTEGER DIM reg:registers DIM I_SetStt:BYTE \I_SetStt=$8E DIM SS_MpGPB:BYTE \SS_MpGPB=$84 reg.a=1 reg.b=SS_MpGPB reg.x=Group*256+BuffNum reg.y=$01 RUN Syscall(I_SetStt,reg) (* check CC register bit for error IF LAND(reg.cc,$01)<>0 THEN PRINT "Error #"; reg.b PAUSE ENDIF BuffLoc=reg.x \(* Return Location END #: 3852 S3/Languages 27-May-90 03:04:59 Sb: #C and JOoysticks Fm: TONY CAPPELLINI 76370,2104 To: ALL Does anyone know how I can read the fire buttons on the joystick ports from a C program ? I want to use them to monitor some external events but I don't know how to address them. Are they read by opening a path to that port or does it require some other stuff ? TC There is 1 Reply. #: 3861 S3/Languages 27-May-90 10:44:13 Sb: #3852-#C and JOoysticks Fm: Zack Sessions 76407,1524 To: TONY CAPPELLINI 76370,2104 (X) You can use the I$GetStt SS.JOY function documented in the Tech Ref manual, page 8-116. You'll have to call it with the _os9() C library function. Zack There are 2 Replies. #: 3870 S3/Languages 27-May-90 16:47:16 Sb: #3861-C and JOoysticks Fm: TONY CAPPELLINI 76370,2104 To: Zack Sessions 76407,1524 I'm looking in the os-9 manual page 8-116 now. SS.JOY isn't a function() is it \ I'm not sure what I$GetStt is either. I have only been doing C for as year or so and that has been on a PC (sorry) at work. I don't know how to connect with os9 through C. Any suggestions where I should start ? See what I mean about talking perso to person. It would be a lot easier doing this in a 10 min phone call than 6 or 7 of these messages. If it's ok could I call you ? If so leave your number and a convenient time at the beep. I have compiled a few utilities on my system, but they don't really get down to the system level like you were talking about. Thanx TC #: 3871 S3/Languages 27-May-90 16:48:01 Sb: #3861-C and JOoysticks Fm: TONY CAPPELLINI 76370,2104 To: Zack Sessions 76407,1524 PS. Wwhat do they mean by function code 13 ? TC #: 3882 S3/Languages 27-May-90 22:01:38 Sb: #3870-C and JOoysticks Fm: Zack Sessions 76407,1524 To: TONY CAPPELLINI 76370,2104 (X) Give me a call anytime after 5PM weekdays, wor anytime weekends, up to ~11PM. 919-675-2426. Got tomorrow, so call during the day if you wish. Zack #: 3886 S3/Languages 27-May-90 23:54:03 Sb: #3870-#C and JOoysticks Fm: Bruce MacKenzie 71725,376 To: TONY CAPPELLINI 76370,2104 (X) Tony, If you have no assembly experience then I can see that you might have a bit of trouble figuring out an _os9() call. Here's the source of a function that will read the joystick status: #include _gs_joy(path,joy,but,x,y) int path,joy,*but,*x,*y; { struct registers r; r.rg_a=path; r.rg_b=SS_JOY; r.rg_x=joy; if(_os9(I_GETSTT,&r)==-1) return -1; *but=(int)r.rg_a; *x=r.rg_x; *y=r.rg_y; return 0; } The parameters are: path = path number to a window or to term. Be sure not to pass a FILE pointer. ie use fileno(stdin) and not stdin here. joy = 0 for right joystick. 1 for left joystick. but = pointer to an integer to receive the button status. Returns: 0 for none, 1 for button 1 down, 2 for button 2 down, 3 for both buttons down x =x value (0 to 63) y = y value (0 to 63) There is 1 Reply. #: 3917 S3/Languages 29-May-90 00:54:21 Sb: #3886-#C and JOoysticks Fm: TONY CAPPELLINI 76370,2104 To: Bruce MacKenzie 71725,376 (X) Ahhh. Finally something that looks familiar. I have some assembly experience, but NOT WITH OS9. I've played around under rsdos with super edtasm and an I/O board that I made, but some of the stuff I see for assmebly under os9 looks sooooo alien. Wwhat are all those $$$$? I guess Zack though I said assembly instead of C. I'll take a look at your example and see if I can figure it out. THANX TC There are 3 Replies. #: 3924 S3/Languages 29-May-90 05:17:21 Sb: #3917-C and JOoysticks Fm: James Jones 76257,562 To: TONY CAPPELLINI 76370,2104 (X) OS-9 assembly language is no big deal; all you have to do is remember the following: 1. position-independent, re-entrant code (too bad the folks at Sierra didn't remember this one) 2. the operating system gives you memory (paste a copy of the diagram that appears with F$Fork by your monitor, to make it easy to recall how to get to it) #: 3943 S3/Languages 29-May-90 16:23:51 Sb: #3917-#C and JOoysticks Fm: Zack Sessions 76407,1524 To: TONY CAPPELLINI 76370,2104 (X) I didn't misunderstand you, I realized you were asking about C and not assembler. Its just that even though C has a very rivh function library, there are many things OS9 can do which are covered with specific function calls. That's the purpose of the _os9() function. Check it out on page 3-26 in the Microware C manual. It serves the same purpose as BASIC09's SYSCALL function. (well, similar). The _os9() function gives you the ability to make all the Getstat and Setstat calls in the OS9 tech ref which are not covered by a function in the function library. Also, note in the example code which was posted has a syntax error. A return statement which is intended to return a value must have the value enclosed in parentheses, ie, return(-1); Zack Oh yes, all those $$$ in a assembler listing is probably references to base 16 numbers. $20 is decimal 32, etc. There is 1 Reply. #: 3949 S3/Languages 29-May-90 18:23:58 Sb: #3943-#C and JOoysticks Fm: Bruce MacKenzie 71725,376 To: Zack Sessions 76407,1524 (X) Zack, I believe you're wrong about the need for parenthesis with a return statement. The syntax is simply 'return expression;'. Parenthesis are purely optional. There is 1 Reply. #: 3964 S3/Languages 29-May-90 22:19:34 Sb: #3949-#C and JOoysticks Fm: Zack Sessions 76407,1524 To: Bruce MacKenzie 71725,376 (X) The parenthses MAY be optional but they are the K&R Standard, which Microware C is modelled after. Zack There is 1 Reply. #: 4002 S3/Languages 30-May-90 17:32:25 Sb: #3964-#C and JOoysticks Fm: Bruce MacKenzie 71725,376 To: Zack Sessions 76407,1524 (X) I think that it is a bit too strong to say that the use of parentheses with a return statement is K&R standard. It IS a common style. I broke myself of the habit because I tended to type 'return()' when no value was to be returned. The COCO compiler chokes on this. It can be argued that using parentheses is undesirable since it makes the return statement look like a function call, which it isn't. On the other hand, the parentheses can make the code read more clearly, especially within a complex line of code. In the end it is a matter of style and personal preference. There is 1 Reply. #: 4014 S3/Languages 30-May-90 22:19:00 Sb: #4002-#C and JOoysticks Fm: Zack Sessions 76407,1524 To: Bruce MacKenzie 71725,376 (X) I don't think is strong at all to say that it is the K&R standard. After all, if you look on page 68 and 70 of K&R, you'll plainly see that the format of the return statement is "return(expression)". On page 68, the book goes on to say, that the main purpose of the return statement is not to simply return to the caller but to return a value to the caller, but if no value is expected by the caller, then no expression is needed at all, in which case the returned value is garbage. It doesn't mention it, but the "accepted" standard for that form of the return statement is sio simply "return" with no parentheses at all. Admittedly, in the appendix on page 203, the return statement is described with it's expression not enclosed in quotes, so there is some ambiguity, but I disagree that it "is common style". I have seen a lot of C code on several different platforms in the past few years, and NOWHERE have I seen the return statement used to pass a value without the parentheses. It may be YOUR common style, but it not EVERYBODY'S common style. But, since the compiler apparently accepts it inthe format which you describe, then the usage of parentheses is a matter of personal preference, but I don't recommend it's use, as other compilers may croak. I don't have a copy of the second printing of K&R (based on the ANSi standard) so I'm not sure if the current standard requires the () or not. Zack There are 2 Replies. #: 4016 S3/Languages 30-May-90 22:33:42 Sb: #4014-#C and JOoysticks Fm: James Jones 76257,562 To: Zack Sessions 76407,1524 (X) Trust me--although K&R in the body of K&R 1st edition always parenthesize the expressions they use in return statements, the appendix was as near to a standard as existed pre-X3J11, and it just says expression. Since a parenthesized expression is an expression, it's just as acceptable syntactically, though some may argue on stylistic grounds one way or another. The ANSI standard simply says expression, so neither it nor K&R *require* parentheses. I have no way of knowing for sure, but...I bet that the K&R 1st edition practice (adding redundant parentheses) may have arisen under the influence of PL/I, which *does* insist on the parentheses in RETURN statements. After spending a long time influenced by the style of K&R 1st edition, I have moved over to the point of view that argues that return(expression) looks too much like a function call, so I omit those redundant parentheses. (I use redundant parentheses freely to avoid playing more-macho-than-thou games involving detailed knowledge of the umpteen, often counterintuitive, levels of precedence of the various operators of C.) There are 2 Replies. #: 4023 S3/Languages 31-May-90 16:14:23 Sb: #4016-C and JOoysticks Fm: Zack Sessions 76407,1524 To: James Jones 76257,562 (X) I bow to your obvious experiance in the matter, but (being an old PL/1 programmer from way back) prefer the redundant () for the return statement. Ahh, to each his/her own! Zack #: 4059 S3/Languages 01-Jun-90 20:49:31 Sb: #4016-C and JOoysticks Fm: Mike Knudsen 72467,1111 To: James Jones 76257,562 (X) James, I'm glad to see a PROFESSIONAL programmer who agrees with me that C precedence is impossible to remember. In Boolean expressions I write C like "infix LISP." I also use return(expr) since "return expr" looks too sleezy (as in BASIC). --mike k #: 4017 S3/Languages 30-May-90 23:38:12 Sb: #4014-#C and JOoysticks Fm: Bruce MacKenzie 71725,376 To: Zack Sessions 76407,1524 (X) Zack, Of the three books on C in my library, Purdum always uses parentheses, Gehani never does and Hogan says they're not required but that many use them for clarity. There is a diversity in this usage and I would say that any compiler that required parentheses with return is definitly non-standard. It is a question of style and I think the most compelling argument is Occam's Razor--why hit the shift key if you don't need to. Still I think a line like: return (strcmp(s1,s2)==1) ? s1 : s2; does benefit by being written return((strcmp(s1,s2)==1) ? s1 : s2); although the two do compile the same. There is 1 Reply. #: 4024 S3/Languages 31-May-90 16:16:07 Sb: #4017-#C and JOoysticks Fm: Zack Sessions 76407,1524 To: Bruce MacKenzie 71725,376 (X) OK, so maybe it isn't as much of a "standard" as I may have implied earlier, but I'm so used to using them now, it'll be hard for me to give them up! Zack There is 1 Reply. #: 4025 S3/Languages 31-May-90 16:21:50 Sb: #4024-C and JOoysticks Fm: Bruce MacKenzie 71725,376 To: Zack Sessions 76407,1524 (X) Zack, Sure, there's nothing wrong with using the parentheses. Probably more people use them than don't. #: 3947 S3/Languages 29-May-90 18:15:32 Sb: #3917-C and JOoysticks Fm: Bruce MacKenzie 71725,376 To: TONY CAPPELLINI 76370,2104 (X) Oh, you have done some assembly work. Those '$' as in 'os9 I$Write' are op system calls which translate as 'SWI ;FCB code' in standard 6809 assembler. 'I$Write' is a symbol defined in os9defs and is equal to the system call code. What you do is load up the registers CPU with the appropriate values as documented in the tech manual, execute the sys call with the 'os9' psuedo op, the op system does what it does and then returns to calling program with the CPU registers modified as documented. The C function _os9(code,reg) loads the registers with the values contained in the structure pointed to by reg and then calls the system call specified by code. The structure for the register values and symbols for the sys call codes are defined in os9.h. You ought to list os9.h and have a look at it. This should make things clearer. #: 3884 S3/Languages 27-May-90 22:06:17 Sb: #3871-C and JOoysticks Fm: Zack Sessions 76407,1524 To: TONY CAPPELLINI 76370,2104 (X) SS.JOY is a "getstat" call. Getstat is a generic call to ask for various status type information for various IO devices. To determine which information is being requested getstat requries a "function code". In this case function code $13 tells getstat that it is a SS.JOY call. Call me and I'll be gald (whoops, that's glad!) to discuss it with you, voice. Zack #: 3938 S3/Languages 29-May-90 14:02:02 Sb: #C error trapping Fm: Dan Charrois 70721,1506 To: all I have a question regarding C. In reading a book I have on the language, I found that there is a global variable errno that contains the latest error result. As a result of this, I am led to believe that error trapping in C (run-time error trapping) is possible as it is for other languages, such as Basic09. In a program I wrote, a division by zero error resulted in my returning back to OS9 with an error message - is there any way to get C to recognize the error before it happens and avoid going back to OS9, but handle the error in the way I see best? such as the onerror command in Basic09... Thanks for your replies. .....Dan Charrois There are 3 Replies. #: 3939 S3/Languages 29-May-90 15:58:16 Sb: #3938-#C error trapping Fm: Pete Lyall 76703,4230 To: Dan Charrois 70721,1506 (X) Dan - Actually, that depends on how the internal math functions were written. If they do the equivalent of this: if((param1/param2) == ERRDIV) exit(ERRDIV) then there's no way to trap it. If the function you used RETURNS an error value (the usual 'C' way of doing things) either explicitly (unlikely) or by returning a -1, and then letting you examine 'errno', you can do as you like with it. We'd probably have to see the program fragment to get more specific. Pete There is 1 Reply. #: 4013 S3/Languages 30-May-90 22:16:02 Sb: #3939-C error trapping Fm: Dan Charrois 70721,1506 To: Pete Lyall 76703,4230 (X) Thanks for your reply. The functions I am using are those contained in the transcendental math library (clibt.l). Hopefully they don't exit internally - it wouldn't seem the proper way of doing things... Thanks, and I'll look further into things...Dan #: 3948 S3/Languages 29-May-90 18:20:36 Sb: #3938-#C error trapping Fm: Bruce MacKenzie 71725,376 To: Dan Charrois 70721,1506 (X) Dan, Yes, there is a way to trap math errors in C. You have to set up a signal trapping function with the intercept() function. When an error occurs the signal trap is called. Usually, the signal trap simply sets an appropriate flag and returns. The main program must check the flag at the appropriate time to see if an error has occurred and then take some action. There are 2 Replies. #: 3969 S3/Languages 29-May-90 23:14:26 Sb: #3948-#C error trapping Fm: Pete Lyall 76703,4230 To: Bruce MacKenzie 71725,376 (X) Bruce - You sure about that? Example: failure to pass a valid filename to the fopen() function. It'll return an error condition (NULL FILE pointer), but won't do any signalling, nor intercept stuff. Pete There is 1 Reply. #: 3993 S3/Languages 30-May-90 07:10:58 Sb: #3969-#C error trapping Fm: Bruce MacKenzie 71725,376 To: Pete Lyall 76703,4230 (X) Pete, You're right that the library functions usually give an error indication with the returned value. However, an error condition which happens during a math operation, division by zero, floating point overflow ect., causes the code to send a signal to itself. You must capture this signal with an intercept routine or the process will return to the shell with an error message. There is 1 Reply. #: 3994 S3/Languages 30-May-90 09:30:07 Sb: #3993-C error trapping Fm: Pete Lyall 76703,4230 To: Bruce MacKenzie 71725,376 (X) Bruce - That's good to know. Never did anything with enough math in it to have to find that out. Pete #: 4015 S3/Languages 30-May-90 22:20:17 Sb: #3948-C error trapping Fm: Dan Charrois 70721,1506 To: Bruce MacKenzie 71725,376 (X) Thanks for your reply as well, Bruce. If the math functions try and abort the program rather than set errno, I'll see what I can learn about setting an appropriate intercept routine. Dan #: 3958 S3/Languages 29-May-90 20:46:30 Sb: #3938-C error trapping Fm: James Jones 76257,562 To: Dan Charrois 70721,1506 (X) OK--there are errors and there are errors. For instance--if you're on a 68020 and using a 68881, an attempt to divide by zero will blow you off with an exception from the coprocessor. Other errors are caught by defensive coding in library routines and result in setting errno and returning some special value (e.g. EOF from getc()). Software floating-point behavior depends on how the stuff is written, of course. For division by zero, I fear that the best way to catch the problem is to test the divisor before you divide. (Alas, that won't catch overflow.) Different routines handle errors differently, is about all I can say--read the docs carefully. #: 3970 S3/Languages 29-May-90 23:28:58 Sb: #multi-source RMA Fm: GLEN HATHAWAY 71446,166 To: All Hi all... Having trouble making multiple source files work with RMA, RLink and Make. I just can't seem to get it to work. The manual is somewhat vague and gives no examples. I think I understand the 'mainline' thing, but I still get phasing errors. Can anybody either explain it or give me a short example to follow? I'm a bit lost... There is 1 Reply. #: 3990 S3/Languages 30-May-90 04:14:58 Sb: #3970-#multi-source RMA Fm: MOTD Editor..Bill Brady 70126,267 To: GLEN HATHAWAY 71446,166 (X) Glen, it would be easier for folks to help if you gave an example of the makefile. There is 1 Reply. #: 4010 S3/Languages 30-May-90 20:41:02 Sb: #3990-multi-source RMA Fm: GLEN HATHAWAY 71446,166 To: MOTD Editor..Bill Brady 70126,267 (X) Hi Bill... I'll do that... #: 3976 S3/Languages 30-May-90 01:14:12 Sb: #C file buffering Fm: Bob van der Poel 76510,2203 To: all Here's my next "dumb" question. It has to do with the way 'C' buffers files. If I understand things correctly all the "proper" file stuff (fopen, fputs, etc.) use buffered i/o. Of course, this presents problems for terminal i/o. For example, if you wish to print a line without a CR; or if you use functions like CurXY()... This problem can be overcome by using setbuff() so that the i/o is done on a un-buffered basis. But then, if you want to print a long line it will be done with a whole series of system calls. I think this would really slow things down if there was to be a lot of terminal i/o. So, is there a way to get the best of both worlds. Would something like this work: leave file as buffered, if doing cursor pos, etc. flush the file, if printing a line with a CR, flush the file, Or is this needlessly complex. Also, what happens if you just want to get 1 or 2 characters from the keyboard. Will fflush() work here too? Seems that the simplest thing to do is to forget about buffered files completely and handle it using the unix-like functions. But the more I read the more I think this is not the 'best" solution. So, what thoughts do you have on this... There are 3 Replies. #: 3992 S3/Languages 30-May-90 04:59:44 Sb: #3976-#C file buffering Fm: James Jones 76257,562 To: Bob van der Poel 76510,2203 (X) Yes, what you suggest (for output) would work, i.e. using explicit fflush() where you want to force it out. Just getting one or two characters from buffered input? I guess I'm not sure what you mean. stdio isn't really designed for switching back and forth between buffered and unbuffered (though you can certainly do it via setbuf()). Could you explain what you're after in more detail? There is 1 Reply. #: 4069 S3/Languages 02-Jun-90 01:05:27 Sb: #3992-#C file buffering Fm: Bob van der Poel 76510,2203 To: James Jones 76257,562 (X) Okay, here is what I have done. I've written an input routine with editing (delete, insert, etc.). It's quite simple to use--you just pass it a string to edit, and the input/output fileptrs. It works just fine, so long as both streams are set for single character (unbuffered) mode. This limits the use of the routine. I would like the routine itself to set up the proper mode (probably with setbuf()), do its thing, and then restore things. It just occurred to me that I could open an duplicate path via I$DUP (hmmm, isn't there a standard library function too?), and set that path up as I need it. I guess I would still have to flush the output buffer before doing this but the input buffer should be okay. Guess I should just try it... There is 1 Reply. #: 4077 S3/Languages 02-Jun-90 11:46:28 Sb: #4069-C file buffering Fm: Zack Sessions 76407,1524 To: Bob van der Poel 76510,2203 Yes, there is a dup() function in MW C. #: 3995 S3/Languages 30-May-90 09:40:06 Sb: #3976-#C file buffering Fm: Pete Lyall 76703,4230 To: Bob van der Poel 76510,2203 (X) Bob - That's really on the nose. I believe CR terminated lines will self-flush, but other than that, you're on target. You shouldn't have to do that with input, though. If you are consistantly just getting a few chars from the keyboard (i.e. menu selections, etc.), why not use read(0,&c,1) vice using buffered I/O? Pete There is 1 Reply. #: 4070 S3/Languages 02-Jun-90 01:05:39 Sb: #3995-#C file buffering Fm: Bob van der Poel 76510,2203 To: Pete Lyall 76703,4230 (X) Yeah, I could use read()...but I understand that "proper" C protocol is to avoid using unbuffered, unix-like, i/o. But skipping the buffered i/o completely certainly has advantages for terminal routines. Guess one has to decide between what works well and what is "the right way." There are 3 Replies. #: 4078 S3/Languages 02-Jun-90 11:48:08 Sb: #4070-C file buffering Fm: Zack Sessions 76407,1524 To: Bob van der Poel 76510,2203 I my opinion, what is "proper" C protocol is what works for you for your specific needs. I frequently use unbuffered IO (read() and write()) with terminal IO, and it seems to perform quite well. Zack #: 4080 S3/Languages 02-Jun-90 14:05:24 Sb: #4070-C file buffering Fm: Pete Lyall 76703,4230 To: Bob van der Poel 76510,2203 Bob - Nay, nay.... read() is poifectly acceptable. Used buffered if there's no reason not to, as it is much less expensive. Pete #: 4086 S3/Languages 02-Jun-90 21:55:47 Sb: #4070-C file buffering Fm: Mark Griffith 76070,41 To: Bob van der Poel 76510,2203 Bob, I have heard mention of read() and write() not being kosher, mostly because there are compilers out there that don't support them (MS-DOS types I think). I wouldn't worry about sticking with fread() and fwrite() though. The low-level I/O functions are much faster in my judgement. One thing you should watch out for when using setbuf(), if you setbuf() standard output to 0 (single character I/O), it doesn't really matter which function (fwrite() or write()) you use...it will be slow as all get out. Setting standard input to single character I/O makes it easier to read a single keypress, and still allows you to read in entire lines of text without changing anything. But, you can't use ungetc() if you need to. For serious editing, or just about anything more involved than using the built in line edit OS9 provides, it is usually a good practise to null out the device descriptor for the terminal and work with each character itself without having to worry about people having different xmode settings. It takes a bit more work, but eliminates lots of headaches. If you also then use read() and write() to the terminal, you'll get nice and fast screen updating. Mark #: 4060 S3/Languages 01-Jun-90 20:57:47 Sb: #3976-C file buffering Fm: Mike Knudsen 72467,1111 To: Bob van der Poel 76510,2203 (X) Bob, it's best to do output buffered, and one-key-at-a-time (no ENTER) input as unbuffered. You can get the corresponding "raw" (Unix-ese) channel number as "stdin->_fileno" or something close -- look in stdio.h to be sure. Just be sure that whenever you do unbufeered I/O on the same path as buffered, always fflush() the path first. Also you can set buffered output so it WILL NOT turn CRs and LFs bytes into CR-LF pairs. Do stdout->_flag |= _RBF. Ask for more details if needed. Don't use setbuf(). But use fprintf(stderr, ...) if you want instant output quick. #: 4133 S3/Languages 06-Jun-90 06:01:43 Sb: BASIC09 Help Fm: Floyd Resler 72500,2572 To: All I'm having a problem with I-Code modules. I'm working on a BBS and have the most often used modules merged together and loaded into memory. The other modules I pull from disk when I need them. After I use the module, I KILL it. Using this method, I get no Module Not Found errors. However, when I try to call a module again that I previously called and KILLed, I get a memory full error! Why? #: 4146 S3/Languages 07-Jun-90 04:59:54 Sb: #4133-#BASIC09 Help Fm: MOTD Editor..Bill Brady 70126,267 To: Floyd Resler 72500,2572 (X) Floyd, your mistake is KILLing the modules. For some reason, KILLing causes B09 to lose the module. The best way is to use SYSCALL to do a Non Mapped Load/ & Unload. The non-mapped load will load a module in memory but outside your map. Then, when you RUN it, it gets mapped in (as long as there is room). In Wiz Pro, I keep 16k free, and map in and out many modules this way. BTW, be careful merging modules. Merged modules tend to load as one module, and you can't call one without getting the other. Hope this is clear. Let me know if you need more. There is 1 Reply. #: 4147 S3/Languages 07-Jun-90 06:24:22 Sb: #4146-#BASIC09 Help Fm: Floyd Resler 72500,2572 To: MOTD Editor..Bill Brady 70126,267 (X) Thanks for the info! I knew the problem had to be because I was KILLihe modules, but, if I didn't, then I would get the dreaded Module Not Found error. One questions: do I do a non mapped load before I RUN the module or will RUN do it for me? Floyd There is 1 Reply. #: 4156 S3/Languages 08-Jun-90 04:13:11 Sb: #4147-BASIC09 Help Fm: MOTD Editor..Bill Brady 70126,267 To: Floyd Resler 72500,2572 (X) You must do the load first. #: 4179 S3/Languages 09-Jun-90 05:35:33 Sb: #4156-#BASIC09 Help Fm: Floyd Resler 72500,2572 To: MOTD Editor..Bill Brady 70126,267 (X) Bill, Your help with my problem and your clarification of the PMap utility has made programming this BBS fun as opposed to agrevating! I mean, as long as I keep enough free space in 64k process area, my BBS can be as big as my hard drive! I do have a question about pre-loading. I tried merging several files together and then attempted to pre-load them. Well, the system gave me a module not found error as soon as I tried to use one. Do I need to pre-load each module seperately? Floyd There is 1 Reply. #: 4208 S3/Languages 09-Jun-90 21:40:19 Sb: #4179-#BASIC09 Help Fm: MOTD Editor..Bill Brady 70126,267 To: Floyd Resler 72500,2572 (X) No, you can merge, but remember that when you RUN any one of the merged files, all come into your space.... & if all don't fit, you get none. OK? There is 1 Reply. #: 4214 S3/Languages 10-Jun-90 05:28:45 Sb: #4208-BASIC09 Help Fm: Floyd Resler 72500,2572 To: MOTD Editor..Bill Brady 70126,267 Ah! I see! Thank you! That explains why when I tried it I got error 43 as opposed to bringing them seperately from disk. So I can merge them together making sure that the files are less than 8k or whateve space I have left over in the workspace. Floyd #: 4262 S3/Languages 11-Jun-90 13:34:01 Sb: #4214-#BASIC09 Help Fm: MOTD Editor..Bill Brady 70126,267 To: Floyd Resler 72500,2572 (X) That's right Floyd. That's how you can easily write 200K plus programs in the CoCo under Basic09! There is 1 Reply. #: 4264 S3/Languages 11-Jun-90 15:10:24 Sb: #4262-BASIC09 Help Fm: Floyd Resler 72500,2572 To: MOTD Editor..Bill Brady 70126,267 The PMap utility makes writing programs of that size much easier. When something goes wrong, I use PMap to see what is in the workspace. I can then use DirM to see which procedure is the co culprit. Very nice. I just wish I had known this a long time ago! Floyd #: 4281 S3/Languages 12-Jun-90 01:03:31 Sb: #%#**$"## C Compiler Fm: TONY CAPPELLINI 76370,2104 To: ALL I know every computer and OS has it's own quirks but can anyone tell me what strange myths are waiting to jump out at me from this dang C compiler we are bound to. I'v been doing all my programming on a PC, and when I started to use the Microware C compiler, boy wuz I in for a surprize. No unsigned chars ? No formal function prototypes allowed void function(char, int); Ok I guess I can live with that, but when I try to do a simple input from the keyboard and the program jumps over the getchar() call like it wasn't even there, that takes the cake. When I had this problem on the PC, a simple fflush(stdin) would take care of it. But it aint woikin on dis cawmpyootur ! Y knot ? My code looks like this printf("\nSelect on e of the following 1,2,3 "); fflush(stdin); ch = getchar(); ch = toupper(ch); switch(ch) { case 'A' : do something break; case 'B' : do something else break; case 'C' : here too break; } This part works ok. But when I do the same input and switch statement that is just after this one, the secondd GETCHAR() doesn't even wait for keyboard input. Where is it going in such a hurry ? By the way, the printf above should have A, B, C instead of 1, 2,3. My ch variable wuz declared as a char originally, then I tried making it an int, out of desperation. Any clues to this one ? While your at it, is there anything else I should no about this compiler before it's tOOOOOOOO late ?? I know this works on my PC's compiler (sorry about the comparison) so it seems it must be something in the Microware version. Thanx for da help guys ! TC There are 4 Replies. #: 4290 S3/Languages 12-Jun-90 06:52:15 Sb: #4281-%#**$"## C Compiler Fm: James Jones 76257,562 To: TONY CAPPELLINI 76370,2104 (X) Well...considering that the Microware 6809 compiler was written in the early to mid-80's, it would be hard for them to foretell what X3J11 was going to do. It only claims K&R 1st edition compliance, and if you look carefully at said book, you'll find that it says nothing about being able to have anything unsigned but int. (Actually, the exceptions to K&R 1st edition compatibility are the #if directive and bitfields.) I'm not sure what fflush() is supposed to do on an input stream, so I will have to go consult a reference before I can say anything sensible about that. #: 4294 S3/Languages 12-Jun-90 09:24:09 Sb: #4281-%#**$"## C Compiler Fm: Mark Wuest 74030,332 To: TONY CAPPELLINI 76370,2104 (X) Tony, 1. Look in the C compiler manual, and you will find that getchar() does indeed return an int. 2. Immediately after the getchar() that seems to return immediately, add the following line: printf("getchar returned %d\n",ch); This will tell you what it returned. I don't know what you will find, but it is almost always "obvious" enough to make you feel stupid. ('Ever notice how, when you lose something, you always find it in the *LAST* place you look? ) Mark #: 4323 S3/Languages 12-Jun-90 19:44:26 Sb: #4281-%#**$"## C Compiler Fm: Bruce MacKenzie 71725,376 To: TONY CAPPELLINI 76370,2104 (X) Tony, First, fflush() only works for output buffers, it does nothing to an input buffer. Assuming stdin is buffer, during your first getchar() call the object code does a readln system call which reads characters from the keyboard up to and including a CR. So you press a key and hit [ENTER]. Both the keypress and a CR are placed in the C buffer, and the keypress is read out by the getchar(). The second time through, the getchar() call reads the CR from the first call rather than going back to the keyboard with a second readln--not what you want at all. The quick and dirty solution is to always do a second getchar to clear the CR after reading a keypress in this manner. #: 4372 S3/Languages 14-Jun-90 12:10:02 Sb: #4281-%#**$"## C Compiler Fm: Scott t. Griepentrog 72427,335 To: TONY CAPPELLINI 76370,2104 Okay, your first problem is trying to use 'C Standard I/O' on OS9. It will work, but only if you are wanting line based input, not character based. This is due to the way that TEXT versus BINARY paths are handled in OS9. A TEXT path will be serviced via the I$READLN call, which gets one line, whereas the BINARY paths (fread) will be serviced by I$READ call, which will get x chars. There is a way to tell the C compiler to use BINARY mode on an input stream, so that you can still use getchar() however: Look on page 4-11 of the C compiler manual - getchar() page. to set the stdin path for BINARY handling, do the line: stdin->_flag|=_RBF; BEFORE any input on stdin. This way the C compiler will pull a I$READ instead of a I$READLN, and you will get the char you wanted instead of a whole line at once. However, I *highly* recommend that you do the following (low level i/o) instead, as it will work a heck of a lot better: read(0,&c,1); Which reads stdin directly, into char c, one char. That's the best way to get just one byte from input. Any more q's? StG #: 4283 S3/Languages 12-Jun-90 01:09:07 Sb: #C and Screen I/O Fm: TONY CAPPELLINI 76370,2104 To: Zack Sessions Zack. Is it possible for me to print out text (each of 5 lines in a different color) from C ? For example the word red would be in red, the word green would be green , extc.. If so how do I accomplish this ? TC There is 1 Reply. #: 4306 S3/Languages 12-Jun-90 16:40:57 Sb: #4283-C and Screen I/O Fm: Zack Sessions 76407,1524 To: TONY CAPPELLINI 76370,2104 (X) Sure you can do that, but only on a graphics window which supports enough colors. Here is a code segment: DWSet(path,8,0,0,40,24,0,1,2); Select(path); Palette(path,3,8); Palette(path,4,36); Palette(path,5,18); Palette(path,6,54); FColor(path,3); puts("This line is BLUE"); FColor(path,4); puts("This line is RED"); FColor(path,5); puts("This line is GREEN"); FColor(path,6); puts("This line is YELLOW"); . . . The trick is to use the FColor() function to change the current value of the forground color register. Zack #: 4357 S3/Languages 14-Jun-90 00:52:49 Sb: #Polling Fm: GLEN HATHAWAY 71446,166 To: All Hi all... I've run into a small snag in writing a program: I want to use CTRL-H to call a help screen. The program also polls for various other keys, including LEFT-ARROW, for other functions. Microware defined both LEFT-ARROW and CTRL-H as #8. Is there a good way to differentiate? I've tried all kinds of things, including SS.KySns, but so far the program is still too easily confused. I don't really want to have to use ALT-H, as I don't find it as comfortable to push quickly as CTRL-H, but if I can't find a work-around I may have to do it. HELP! P.S. I'm working in RMA assembler. There is 1 Reply. #: 4365 S3/Languages 14-Jun-90 09:35:51 Sb: #4357-Polling Fm: Wayne Day 76703,376 To: GLEN HATHAWAY 71446,166 Glen, Not to tell you how to write your own program, but Control-H is as a backspace or DELete, and unless you're the only one that may ever use your program, that may lead to confusion. The PC world has pretty well standardized on F1 as the "Help" key.. have you thought about Control-"?" or something like that? Wayne #: 4359 S3/Languages 14-Jun-90 06:15:07 Sb: #help with 'c' index() Fm: SCOTT HOWELL 70270,641 To: all Help!!!!! Will some one help me this is 'mysterous' C function called index(). Here is what the Microware 'c' compiler says about index() synopsis char *index(ptr,ch) char *ptr; ch index() returns a pointer to the first occurence of the character ch in the string pointed to by ptr. Returns null if char not found. What I want to do is to print an integer indicating the location of that ch (ie it would print the integer '3' for 'm' in 'computer'.) Could someone write a small program that does this. The example in the manual makes abs no sense. There is 1 Reply. #: 4363 S3/Languages 14-Jun-90 08:27:10 Sb: #4359-#help with 'c' index() Fm: Jeff Dege 76426,211 To: SCOTT HOWELL 70270,641 What you need to keep in mind is that a string is an array of characters, and the name of array variable is treated as a pointer to the first elemnt. Once you have a pointer to the first 'm' in a string, all you have to do is subtract to get the index. #include #include main() { char string[80], *p; puts("Enter a string"); fflush(stdin); /* flush the output buffer */ gets(buffer); p = Index(string, m); printf("The first 'm' occurs in location %d\n", p - string); } If you'll notice, if the string starts with an 'm', this program will print 0 (all C arrays start at 0.) There is 1 Reply. #: 4366 S3/Languages 14-Jun-90 10:29:24 Sb: #4363-help with 'c' index() Fm: Pete Lyall 76703,4230 To: Jeff Dege 76426,211 (X) Just a couple of quickie additions to Jeff's code: 1) m should be 'm' in the index() call... 2) You may want to make the position (p - string + 1) so you can enumerate from 1, as is typical in other languages for string operations. This is purely optional. Pete #: 4381 S3/Languages 15-Jun-90 01:18:08 Sb: #Maybe another C bug Fm: Bob van der Poel 76510,2203 To: all I have been playing around with Eric Williams spell-check programs from the UG library. These programs were originally complied with the Introl_C compiler. I've had to make a few minor changes in order to get things to work under the Microware C compilier. But in the process (Mark, I am really hesitant to say this!!!) I have discovered another bug in the compilier. It seems that if a GOTO is done to a label at the start of a function (after all the declarations) the stack pointer is not set up properly causing a drastic crash. Inserting a line of BS code in front of the label solved the problem (as did rewriting the code to avoid the GOTO entirerly), but I was wondering if anyone else was aware of the this problem. If not I'll spend a bit of time on it to find out the exact situations in which it causes the problem and post the results. BTW, I have the spell program working and have been able to make drastic (about seven fold) changes to the speed simply by changing from unbuffered to buffered i/o. I hope to do some other things too and intend to post the entire package when done. Any ideas, requests or suggestions? There are 2 Replies. #: 4384 S3/Languages 15-Jun-90 06:30:33 Sb: #4381-#Maybe another C bug Fm: Mark Griffith 76070,41 To: Bob van der Poel 76510,2203 Bob, No need to try and avoid me Bob (grin). I didn't mean before to imply there are NO bugs in the compiler, just that many people find things that don't work as they think they should, say its a bug, and its really only the way they are doing it. You might well have found something here. I NEVER use goto myself, although some of the code I use and have hacked upon does, so I leave it there since if it works...... I think most people avoid goto like the plague so this has never shown up before. BTW: did you happen to notice the spell checker uploaded for the UG? It works pretty well without any changes. Maybe it was never presented here. Mark There are 2 Replies. #: 4385 S3/Languages 15-Jun-90 07:31:43 Sb: #4384-Maybe another C bug Fm: James Jones 76257,562 To: Mark Griffith 76070,41 (X) I could believe the one about the goto--there's one goto-related bug that survived for quite some time in the 68K compiler because people must not have written just that sort of code before (it had to do with explicit gotos into the body of a switch statement that had some auto variables declared in it). #: 4387 S3/Languages 15-Jun-90 09:33:00 Sb: #4384-Maybe another C bug Fm: Pete Lyall 76703,4230 To: Mark Griffith 76070,41 (X) Markly - I believe William's spell checker WAS the one in the UG. I also had to make changes when compiling it under MW C. Also, the GOTO bug is something that I think has been recognized previously. I think James Jones has a better description of it available. Pete #: 4402 S3/Languages 16-Jun-90 10:28:54 Sb: #4381-Maybe another C bug Fm: Bill Dickhaus 70325,523 To: Bob van der Poel 76510,2203 Bob, That's good news on the speed increase! I use that spelling checker occasionally, but since its so slow, its impractical for anything but one word at a time. Bill #: 4382 S3/Languages 15-Jun-90 01:45:25 Sb: #4365-Polling Fm: GLEN HATHAWAY 71446,166 To: Wayne Day 76703,376 (X) Hi Wayne... I've pretty well settled on CTRL-? to do the job. Working around the other is too difficult, and not "standard" either, I guess. Thanks for the advice... #: 4417 S3/Languages 16-Jun-90 21:33:12 Sb: #Running Basic09 Fm: George Gavaghan 76236,421 To: [F] All Sysop- I've just purchased the OS9 LV.II w/ BASIC09 and am having serious difficulty in running the BASIC09 program. Also, from a previous experience I know to expect trouble from the GFX2 command.(loading and running) I'm running on a COCO 3 w/128k and a single FD-502 drive. Any and all help would be appreciated. Thanks. ---->GG There are 2 Replies. #: 4422 S3/Languages 16-Jun-90 22:31:28 Sb: #4417-Running Basic09 Fm: Kevin Darling (UG Pres) 76703,4227 To: George Gavaghan 76236,421 Hi George. Can you describe what kind of difficulties you're having in more detail? That is, trouble loading basic09? Trouble running large procedures? Setting up gfx windows? Or ? Any particular program example? Since basic09 is in the CMDS directory on the second disk, you might pop that disk in and type "load /d0/cmds/basic09" and then replace your boot disk in the drive. Now basic09 is loaded into memory and should come up with "basic09" at any time. You might have to load gfx2 and inkey the same way. best - kev #: 4433 S3/Languages 17-Jun-90 09:43:36 Sb: #4417-Running Basic09 Fm: Zack Sessions 76407,1524 To: George Gavaghan 76236,421 You failed to tell us just what the "difficulty" is. Do you get an error code message? What happens that shouldn't happen? Also, if you are serious about OS9, with there price of memory upgrades so cheap, I stongly recommend you get a 512K memory upgrade. Zack #: 4461 S3/Languages 17-Jun-90 23:52:37 Sb: #4422-#Running Basic09 Fm: George Gavaghan 76236,421 To: Kevin Darling (UG Pres) 76703,4227 (X) Kevin- The trouble is that I can load but not run Basic09. I forget the error code I recieve, but I will try your sugestion and get back to you soonest. Thanks for your help. --->GG There is 1 Reply. #: 4465 S3/Languages 18-Jun-90 01:56:37 Sb: #4461-#Running Basic09 Fm: Kevin Darling (UG Pres) 76703,4227 To: George Gavaghan 76236,421 (X) George - okay, please let us know what the error code is... and also what else you had loaded into memory. - kev There is 1 Reply. #: 4473 S3/Languages 18-Jun-90 20:18:00 Sb: #4465-#Running Basic09 Fm: George Gavaghan 76236,421 To: Kevin Darling (UG Pres) 76703,4227 (X) Kev- I tried your sug. on looading Basic09, PERFECT. Now for the next onslaught of questions. First, what does that UG in your title stand for? Second,I tried a small prog. from the manual(OS9) in the Basic09 section. No can do chief. I've been programming Basic for about 3 years now and I can't figure this stuff out. Look at pg.9-37 in the Basic09 sec. When I create then change to the window,all I get are a bunch of dots, no letters. I know it has to be the merge command, I'm not getting the fonts into /w1 or something. Big problem is that once I ex the terminal screen,I have to BOOT-UP again because the window doesn't work!(or rather I can't tell if it's working 'cause I don't read morse code. Run it and you'll know what I mean) I'm asuming you have the manual,though it might have a little dust on it(it sounds like youu don't need it much any more.), if you don't, I'll give you the command sequense next message. Thanks for all your help. -->GG There are 2 Replies. #: 4475 S3/Languages 18-Jun-90 20:54:06 Sb: #4473-#Running Basic09 Fm: James Jones 76257,562 To: George Gavaghan 76236,421 (X) UG stands for "user group". Shouldn't matter what window you merge fonts into; SCF snarfs the escape codes on the way out and stores the font data away. You should be very sure that the font group and number your program asks for matches that of one of the fonts you merged, or you'll get the Morse code consistently! (That's the voice of experience speaking about that last bit...Sigh.) There are 2 Replies. #: 4496 S3/Languages 19-Jun-90 20:52:37 Sb: #4475-Running Basic09 Fm: George Gavaghan 76236,421 To: James Jones 76257,562 (X) James- Thanks for the info. Do you happen to know the code(s) I would have to use, the manuual falls short in a lot of areas including this one as far as information goes. --->GG #: 4503 S3/Languages 19-Jun-90 21:51:15 Sb: #4475-#Running Basic09 Fm: George Gavaghan 76236,421 To: James Jones 76257,562 (X) Hi, George again. Kevin had me merge prior to wcreate'ing and it worked perfect. I don't think I needed any code(s) in this instance. Thanks for the info anyway, I'll file it for future reference. Now mabey you could help me with anotherr little problem I'm having. Whan I try to "PACK" a procedure I get error code 214-NO PERMISSION. No permission for what !!?? It's my procedure,I changed all ATTR to on and it still wont work. I also tried to load "PACK" prior to using it(just in case) and that didn't work either. Any sugestions? Nothing I try seems to work. ---->GG There are 2 Replies. #: 4506 S3/Languages 19-Jun-90 21:59:52 Sb: #4503-Running Basic09 Fm: Kevin Darling (UG Pres) 76703,4227 To: George Gavaghan 76236,421 (X) George - ah, I caught your message to James. "Pack" is built into basic09. (Be sure to save your program source to disk first!) If you just type "pack" it'll try to convert/save the program to your commands directory. If you'd swapped disks on OS9, then it could get confused and try to open a new file in a wrong place on disk... thus a common 214 "no permission" error causer. Be sure writeprotect is off the disk, that there's enough room on disk, and that you've done a "chx /d0/cmds" for example, first. If there's not enuf room, pack to somewhere else: stick in a fresh disk, "pack >/d0/filename". Back later. #: 4521 S3/Languages 20-Jun-90 07:45:25 Sb: #4503-#Running Basic09 Fm: James Jones 76257,562 To: George Gavaghan 76236,421 (X) When you pack a procedure, BASIC09 creates a file by the name of the (first, if you do a pack*) procedure named in the current execution directory. Perhaps it is permission on an already-existing file there by that name that is being referred to. There is 1 Reply. #: 4527 S3/Languages 20-Jun-90 18:10:25 Sb: #4521-Running Basic09 Fm: George Gavaghan 76236,421 To: James Jones 76257,562 (X) JAMES- THANKS FOR THE INFO, BUT I HAVE ALREADY BEEN INFORMED THAT I MUST CHX TO CMDS BEFORE I CAN PERFORM A "PACK". THANKS FOR YOUR ASIST ANYWAY, I WILL KEEP THAT IN MIND WHEN I TRY IT AGAIN. --->GG #: 4489 S3/Languages 19-Jun-90 03:06:43 Sb: #4473-#Running Basic09 Fm: Kevin Darling (UG Pres) 76703,4227 To: George Gavaghan 76236,421 (X) Geo - Ah. What happened was that wcreate'ing the window automatically defaults the font to stdfonts... unfortunately they don't exist yet . So do the same lines, EXCEPT do the stdfonts merge BEFORE wcreating the window. Now when the window is made, os9 finds the font in memory and can use it right away. Also, you might want to say "merge /d0/sys/stdfonts" instead of the way they did it, as you might not be sitting on the root dir of the disk with the SYS subdirectory like they assume. You can tell they assumed this because they used a relative pathlist "sys/stdfonts" instead of an absolute pathlist like "/d0/sys/stdfonts". Which reminds me of a side tip which always helps new OS-9 users: when you CHD or CHX to a new disk/dir, OS9 remembers that spot on that *one* particular disk (not the pathnames themselves)... so switching disks and not using chd/chx again (or not using full pathnames with the drive name in front) will often cause confusion on the part of os9 and yourself . Hope you can get 512K soon... the machine really opens up enormously when you do... almost no limit, practically speaking. Keep at it! best -kev PS: you could also have blindly typed "display 1b3a c801" while in the dots, which means "use font c8 01", which are the stdfonts group/buffer numbers. Bing. It'd have come up. Try "display 1b3a c802" just for fun, also. That's the stdfonts 6x8 version. There is 1 Reply. #: 4498 S3/Languages 19-Jun-90 21:02:27 Sb: #4489-#Running Basic09 Fm: George Gavaghan 76236,421 To: Kevin Darling (UG Pres) 76703,4227 (X) Kev- You DO know what your doing , don't you.As far as the CHD and CHX, I've found it easier to just stay in the root for now. At least till I get more comfortable with the system. Can you tell me if there is any other DEPENDABLE documentation on OS9 I might be able to use, I really am gettiing tired of fighting with this manual.(I can't be the first person to have all these problems. Can I?) Thanks again. ---->GG P.S. I can PACK only from a window, is this true. There are 2 Replies. #: 4504 S3/Languages 19-Jun-90 21:55:12 Sb: #4498-Running Basic09 Fm: Zack Sessions 76407,1524 To: George Gavaghan 76236,421 (X) For more "user-friendly" documentation you might try "Start OS9" from KLE, and two books (whose titles escape me for the moment) something like "Complete Rainboe Guide to OS9" and Rainbow Guid to OS9 Windows" available from any Radio Shack store. Zack #: 4505 S3/Languages 19-Jun-90 21:55:16 Sb: #4498-#Running Basic09 Fm: Kevin Darling (UG Pres) 76703,4227 To: George Gavaghan 76236,421 (X) George - A lot of people recommend "Start OS-9", a book which should be advertised in Rainbow mags... newcomers seem to like it a lot. It leads people thru examples that work , and comes with a disk to help out. There are only a few major mistakes in the stock manual... but they're lulus! Just where a newcomer can get most confused, usually ;-). The most important thing to remember is that 99.9% of the time, there's a simple reason you get errors. Just a matter of keeping cool and tracking it down. We reserve our greatest admiration around here for people who keep at something until they figure it out. And of course, questions are welcome. PS: Ummm, you can Pack from any kind of device which you can type "pack" on . I'm not sure I understand what you mean? There are 2 Replies. #: 4515 S3/Languages 20-Jun-90 06:25:03 Sb: #4505-#Running Basic09 Fm: George Gavaghan 76236,421 To: Kevin Darling (UG Pres) 76703,4227 (X) Kev- When I "PACK" I get error 214. Even in the window, should I CHX to CMDS? And I tried to config for both sides of thre disk, and failed. Is there a way I can just add the modules to my current disk? ---->GG There is 1 Reply. #: 4522 S3/Languages 20-Jun-90 07:47:53 Sb: #4515-Running Basic09 Fm: James Jones 76257,562 To: George Gavaghan 76236,421 (X) Perhaps the thing to do is to describe for us the sequence of events leading up to the 214. Be sure to mention any and all swapping of disks, chd and chx commands (either that you do yourself or that may be in a BASIC09 procedure you are running), and the like that you do. #: 4532 S3/Languages 20-Jun-90 22:59:53 Sb: #4505-Running Basic09 Fm: George Gavaghan 76236,421 To: Kevin Darling (UG Pres) 76703,4227 (X) KEV- I used chx /d0/cmds for "pack" and it worked fine. I also managed to config a disk with ddd0-40d and d0-40d, thaat also worked fine. Now, how doo I transfer my files to the new disks? I tried copy (error 244) and when I try to config on the new dsk it aborts just after I enter the new disk in to be scratched. When I tried "BACKUP" I get error 249(media mismatch). I tried to "keep cool" and track it down but this is getting down right frustrating! At it now for 3 hours now with no luck. Any ideas? ----->GG P.S. Alsoo you might have noticed double characters from time to time in my messages. My keyboard seems to like doing that. Anything I can do to fix that? #: 4462 S3/Languages 17-Jun-90 23:56:39 Sb: #4433-Running Basic09 Fm: George Gavaghan 76236,421 To: Zack Sessions 76407,1524 (X) Zack- As for the memory, as soon as I get the money I plan on the upgrade. As to the "difficulty", I can load the Basic09 module into memory but can't run it using the Bassic09 command, all I get is an error code. I recieved a suggestion from Dave and will try it then let you know how it goes. Thanks for your reply. -->GG #: 4537 S3/Languages 21-Jun-90 00:10:13 Sb: #4381-Maybe another C bug Fm: Paul K. Ward 73477,2004 To: Bob van der Poel 76510,2203 (X) Bob, Gosh, a speedy spell checker in the public domain! Great! Paul #: 4538 S3/Languages 21-Jun-90 00:12:04 Sb: #4384-#Maybe another C bug Fm: Paul K. Ward 73477,2004 To: Mark Griffith 76070,41 (X) Mark, You know, some time you and I should button hole Simmy (for a LOT of reasons!) and get a comprehensive C compiler bug list out of him. Our staff is looking forward to supporting the software we're sending out with the MM/1 -- but of course it would be nicest if we had several interpretations of the C compiler bug list for reference. Paul There is 1 Reply. #: 4590 S3/Languages 24-Jun-90 08:04:15 Sb: #4538-Maybe another C bug Fm: Mark Griffith 76070,41 To: Paul K. Ward 73477,2004 Paul, Sheeesh, I've never kept a list of compiler bugs since I've never seen them...probably due to the way I use it. Others here might have that available for you. I assume you mean the 6809 compiler?? Wouldn't you want a bug list for the OSK compiler though? Mark #: 4541 S3/Languages 21-Jun-90 01:28:12 Sb: #4384-#Maybe another C bug Fm: Bob van der Poel 76510,2203 To: Mark Griffith 76070,41 (X) Mark, I am refering to the spell checker in the UG library. I've got most of the stuff running quite nicely now. The amazing thing is the increase in speed--the thing is actually useable now! I want to do a few final touch-ups and then I'll upload the whole package (without the dictionary!). Also, I will see if I can figure out the GOTO bug and post it here. There is 1 Reply. #: 4591 S3/Languages 24-Jun-90 08:04:26 Sb: #4541-Maybe another C bug Fm: Mark Griffith 76070,41 To: Bob van der Poel 76510,2203 21-Jun-90 02:28:12 Sb: #4384-Maybe another C bug Fm: Bob van der Poel 76510,2203 To: Mark Griffith 76070,41 Bob, I think errr.....I can't remember his name right now.....and ex UG president uploaded an archive of the spell checker already ported to 6809 and the archive included source and binaries for both 6809 and OSK versions. No fixing required (grin). You probably came up with the same thing only faster. Mark #: 4580 S3/Languages 23-Jun-90 14:15:37 Sb: #4384-#Maybe another C bug Fm: Jim Peasley 72726,1153 To: Mark Griffith 76070,41 (X) Mark; I may have found an 'anomaly' in STERM. I was downloading some files this morning, and after the 2nd one, I checked the transfer rate (ctrl Z). I don't believe that it was only 34%, but that's what it told me. Anyway, on the third file, after entering the name of the file for my computer, instead of creating the 'download box', I got a line at the bottom of the screen in reverse video of "*--------------------*" and another line at the top of the screen, also in reverse video, of garbage chars. As the download progressed, the byte counter incremented properly (and was readable), and after completion (yes, it was successful), everything returned to normal. Upon checking the xfer efficiency again, it was a phenomintl 327.6% !!! Specifics: CoCo3, STERM v.1.3, invocation "sterm13", baud=2400, 38ms HD w/ B&B interface. Next time I dl something, I'll see if I can duplicate the problem. ..Jim There is 1 Reply. #: 4593 S3/Languages 24-Jun-90 08:04:52 Sb: #4580-Maybe another C bug Fm: Mark Griffith 76070,41 To: Jim Peasley 72726,1153 Jim, Sterm Version 1.3 does have an elusive bug somewhere that causes that. I'm not sure if it is in the termcap code, or Sterm's logic. I only noticed it a couple times here, but I'm been running a slightly different version for the past year or so. I'll be uploading that version in the near future and I hope it fixes that bug for you. Also, I noticed that you arn't using the -f flag when you start Sterm. If you don't used this, Sterm assumes a "Classic" B transfer, which means no packet send-ahead. You'd very likely get a 34% efficiency rate then. If you are downloading to your hard drive, use the -f flag and you should get transfer rates of around 72% - 78%. Mark #: 4562 S3/Languages 22-Jun-90 17:26:30 Sb: #Help 'c' problem again Fm: SCOTT HOWELL 70270,641 To: all Why is'nt this program working. I want the program to keep looping until a character other than 'd' is pressed char c; main() { while(c=='d'); { printf("this is a test\n"); c=getchar(); } printf("\nIt works\n"); } This is another reason why I think 'c' is such a confusing language. There is 1 Reply. #: 4563 S3/Languages 22-Jun-90 17:52:51 Sb: #4562-#Help 'c' problem again Fm: Bruce MacKenzie 71725,376 To: SCOTT HOWELL 70270,641 (X) Scott, The culprit is the semicolon after the while(c=='d') statement. Delete it and your routine should work fine. There is 1 Reply. #: 4565 S3/Languages 22-Jun-90 21:10:18 Sb: #4563-#Help 'c' problem again Fm: SCOTT HOWELL 70270,641 To: Bruce MacKenzie 71725,376 (X) Well it does in a way. It repeats but it never escapes the loop even when I type 'd'. I changed scanf(..) to c=getchar() and it does work in a way. In Turbo 'c' there is a function called 'getche()' which returns a character when the key is pressed, NOT after a CR. Is there a function in microware 'c'. There are 2 Replies. #: 4566 S3/Languages 22-Jun-90 21:21:19 Sb: #4565-Help 'c' problem again Fm: Robert A. Hengstebeck 76417,2751 To: SCOTT HOWELL 70270,641 (X) Take a look at my program in the dl 10 area called EZDIR.AR . Also if you need it, I can upload some short C codes that I wrote to test single key entries. The program HDO.AR also in dl 10 use single key entry exclusively. #: 4581 S3/Languages 23-Jun-90 17:00:16 Sb: #4565-Help 'c' problem again Fm: Bruce MacKenzie 71725,376 To: SCOTT HOWELL 70270,641 Buffered FILE I/O using the standard library functions is line oriented and not well suited to reading single keypresses. It's better to use the low level system call functions for this purpose: read(fileno(stdin),&c,1); This will stop and return the next keypress. If you don't want the routine to hang until a key is pressed use getstat() to check for data available: if(getstat(1,fileno(stdin))==0) read(fileno(stdin),&c,1); #: 4564 S3/Languages 22-Jun-90 19:56:06 Sb: #"C" programming Fm: Rodney Harper 75130,1321 To: All I am interested in learning "C". Could anyone possibly introduce me to some reference material for this language. Also, what is the "C" compiler that you recommend. Thanks, >>Rod<< There is 1 Reply. #: 4579 S3/Languages 23-Jun-90 14:14:34 Sb: #4564-"C" programming Fm: Jim Peasley 72726,1153 To: Rodney Harper 75130,1321 (X) Rodney; C compiler depends on which machine you have. For the CoCo, there's only the Tandy C compiler for about $100. There used to be others at a substantially higher price, but I'm not sure if they're still available. For reference materials, there's a file in (I think) Lib 1 called CTUTOR.AR which has many, many source code examples and some explanatory text. There's also 'C Primer+' by the Waite Group (a SAMS book) which should be available at any B. Dalton's or Waldenbooks. Easy reading and very helpful, although a bit shy on some examples. Another one that I've found helpful is 'ABC A Book on C', but it's at work and I don't remember the author's name. For specific questions, be sure to ask here... there's a several hundred years of experience available right here (I'm not one of them tho! ;-) ). ...Jim /exit s #: 4613 S3/Languages 24-Jun-90 17:54:26 Sb: #4590-#Maybe another C bug Fm: Paul K. Ward 73477,2004 To: Mark Griffith 76070,41 (X) Mark, Oops, of course I meant the OSK compiler. I forget you are not YET using OSK! BTW, we should talk on the phone again RSN. Paul There is 1 Reply. #: 4982 S3/Languages 08-Jul-90 11:54:12 Sb: #4613-Maybe another C bug Fm: TONY CAPPELLINI 76370,2104 To: Paul K. Ward 73477,2004 (X) Thats only because we don't have MM1's yet. HINT HINT ! TC #: 4644 S3/Languages 26-Jun-90 01:04:59 Sb: #4591-#Maybe another C bug Fm: Bob van der Poel 76510,2203 To: Mark Griffith 76070,41 (X) Well, I have uploaded my new version into the applications library. You will need the dictionary from the old version. Hope it helps someone. There is 1 Reply. #: 4713 S3/Languages 28-Jun-90 05:43:34 Sb: #4644-Maybe another C bug Fm: Mark Griffith 76070,41 To: Bob van der Poel 76510,2203 (X) Bob, I downloaded your hacked dictionary and am impressed with the speed increase. Thanks for doing that. BTW...are you interested in a larger dictionary? This one only has about 80,000 words. I can get and MAYBE upload a dictionary of over 120,000 from one of the systems at work. Mark #: 4635 S3/Languages 25-Jun-90 10:55:15 Sb: #4562-Help 'c' problem again Fm: Mark Wuest 74030,332 To: SCOTT HOWELL 70270,641 (X) Scott, Bruce MacKenzie gave the correct solution to your problem in msg # 4581. Just replace your line: c=getchar(); with: read(0,&c,1); and you will get the results you are looking for. Mrk #: 4652 S3/Languages 26-Jun-90 09:29:31 Sb: #4562-Help 'c' problem again Fm: Pete Lyall 76703,4230 To: SCOTT HOWELL 70270,641 (X) Scott - I'm sure you've had multiple responses at this point, but I see a couple of things: a) There's a semicolon after your test condition, which in effect causes a 'null' statement (i.e. while(c == 'd'), do nothing - including not getting any other characters, so the results of the test never change. b) What is c initially? If it's a typical automatic variable, it could contain anything - no promises here unless it's a static variable. You could either shift the position of the getchar(), and alter the logic, or you could stuff a NULL or something into c so you know your starting point. Pete #: 4771 S3/Languages 30-Jun-90 12:04:20 Sb: #4581-#Help 'c' problem again Fm: Tom Breton 71141,3433 To: Bruce MacKenzie 71725,376 (X) Bruce, thanks for message 4581. I've been trying to figure out why getchar() wouldn't let my program continue until it got a . Being a beginner, I didn't realize it was so dependent on the buffer. But when I tried read(fileno(stdin),&c,1) it *still* waited for a before it would recieve a character. Do I have to go to an even lower level keyboard scan or something to get it to respond to a single keypress? Tom There is 1 Reply. #: 4790 S3/Languages 30-Jun-90 22:14:02 Sb: #4771-#Help 'c' problem again Fm: Bruce MacKenzie 71725,376 To: Tom Breton 71141,3433 (X) You've got me Tom. It doesn't work like that on my system--a COCO III, LVL II with the Microware C compiler. Not knowing exactly what you've coded, compile and run the following program. It should return the ascii value of a key immediately after it is pressed. #include main() { char c; do { read(fileno(stdin),&c,1); printf(" Key = %x/n",(int)c); }while(c!='/n'); } (the slashes above in /n should be backslashes--the terminal program I'm using doesn't have them) There is 1 Reply. #: 4897 S3/Languages 05-Jul-90 12:06:28 Sb: #4790-#Help 'c' problem again Fm: Tom Breton 71141,3433 To: Bruce MacKenzie 71725,376 (X) Just so you know, your program still waits for a whole line on my sytem. [IBM XT, DOS 3.3, tried both QuickC and MS Codelink 4.00] It does nothing until I have typed in an entire line, then executes as if I just typed it. It works fine, just too late. Do you - or anyone else reading - know how I can get around my buffer, or read from it when it hasn't got a complete line? (And since I've only programmed in C for two weeks, remember I might not know stuff that's obvious to everyone else) Thank you, Tom There are 2 Replies. #: 4900 S3/Languages 05-Jul-90 13:17:41 Sb: #4897-Help 'c' problem again Fm: Pete Lyall 76703,4230 To: Tom Breton 71141,3433 (X) Tom - [butting in..] Are you using low level (read()) or high level (fread(), gets(), getchar(), etc.)? If high level, try setting buffering off, i.e. setbuf(stdin,0); Also - in MSDOS land, they distinguish between text a binary file types (at least when reading/writing the files)... Try setting your file type variable to O_BINARY (check your docs)... Pete #: 4907 S3/Languages 05-Jul-90 16:36:37 Sb: #4897-Help 'c' problem again Fm: Bruce MacKenzie 71725,376 To: Tom Breton 71141,3433 (X) Sorry, Tom. I don't think I can help much with your problem--looks to be MSDOS specific. I never touch the stuff (MSDOS) myself. #: 4653 S3/Languages 26-Jun-90 09:37:55 Sb: #4564-"C" programming Fm: Pete Lyall 76703,4230 To: Rodney Harper 75130,1321 (X) Best textbook I have seen/used on learning C by yourself is the Waite Group's 'C Primer Plus'. It's thorough, example based, non-lofty, and even sprinkles some humor in an otherwise dry subject. Others have also reported a similar reaction to it. Pete #: 4656 S3/Languages 26-Jun-90 14:10:09 Sb: #thanks to all Fm: SCOTT HOWELL 70270,641 To: all Thanks Everyone!!!! I finally worked it out with the read(0,&ch,1) combined with a strcmp("q",ch). One funny thing though is that strcmp returns a FALSE if the strings match so the while guard looks it will break out if you press anything other that 'q'. There are 4 Replies. #: 4658 S3/Languages 26-Jun-90 15:53:48 Sb: #4656-thanks to all Fm: Zack Sessions 76407,1524 To: SCOTT HOWELL 70270,641 (X) strcmp() requires string pointers for both paramters. You are using a char value for the second parameter. &ch won't work either cuz that's a pointer to type char, not string. Try using strchr("q",ch) or if you don't have the Krieder lib use index("q",ch). Zack #: 4662 S3/Languages 26-Jun-90 19:09:26 Sb: #4656-thanks to all Fm: Pete Lyall 76703,4230 To: SCOTT HOWELL 70270,641 (X) Scott - It doesn't return a FALSE, per se. It returns a difference of 0. If the characters mismatch at some point, it'll return a positive if the difference was positive, and the same for negative. For clarity, some people like to declare a MACRO to take care of the logic: #define STREQ(x,y) (strcmp(x,y) == 0) This way, you could use: if STREQ(onestring, theotherstring) blah_blah(blah); Pete #: 4665 S3/Languages 26-Jun-90 19:44:59 Sb: #4656-thanks to all Fm: Scott t. Griepentrog 72427,335 To: SCOTT HOWELL 70270,641 (X) Whoa! Wrongo! read(0,&ch,1); - puts char in (char) ch BUT!!! strcmp("q",ch); is TOTALLY wrong. 1) assuming ch is declared 'char ch;' you have only one byte allocated. Strings are multiple bytes... AND strcmp expects a pointer to string. A char is not going to work! strcmp("q",&ch); would be closer, but still wrong. You must have a zero terminator to both strings, and you have no idea what follows the char ch in memory! There are two alternatives: char ch[2]; ch[1]=0; read(0,ch,1); strcmp("q",ch); OR char ch; read(0,&ch,1); if (ch=='q') ...; Of course the latter makes more sense. Want some additional help on C? You can call me at (317)241-6401, or mail me here or any StG-net node at sysop@root. StG #: 4668 S3/Languages 26-Jun-90 21:33:44 Sb: #4656-thanks to all Fm: James Jones 76257,562 To: SCOTT HOWELL 70270,641 (X) Be careful. Two things: (1) strcmp expects to be handed *pointers* to characters, and those pointers had better point to NUL-terminated strings, so that even if you changed that to strcmp("q", &ch), it might not do what you want. (2) strcmp() is documented to return a negative number if the first string is less than the second, zero if the first string is equal to the second, and a positive number if the first string is greater than the second. It always pays to read the documentation. #: 4941 S3/Languages 07-Jul-90 01:26:47 Sb: #I don't C so well ! Fm: TONY CAPPELLINI 76370,2104 To: Zack Sessions Zack Hi there. I have a couple of C related questions for you. How can I check to see if my printer is on line, or even powered on for that matter ? I tried the following if ( !(status = write(printer, font_code, len) ) ) { print an error message here ! } but when the printer was off-line, the program stopped until I put it back on-line. Also, I was trying to erase just a portion of the text screen by using putchar(0X04), fflush(stdout), from within a for loop; But the $4 didn't seem to do anything. These code can be found in the LII manual on page B-3. I also tried using putchar(0X0B), but that is for a graphics screen. Any clues ?? TC There are 3 Replies. #: 4944 S3/Languages 07-Jul-90 01:30:56 Sb: #4941-#I don't C so well ! Fm: Pete Lyall 76703,4230 To: TONY CAPPELLINI 76370,2104 (X) I believe the later vintage coco printer drivers return E$NotRdy (error 246) if the printer doesn't come ready within a few seconds. Pete There is 1 Reply. #: 4979 S3/Languages 08-Jul-90 11:40:20 Sb: #4944-#I don't C so well ! Fm: TONY CAPPELLINI 76370,2104 To: Pete Lyall 76703,4230 (X) What do you mean by later vintage coco printer drivers ? I am not using the stock LII driver. I am using the Parallel.dr for the Disto printer port. I beleive Kevin may have written it ??? TC There is 1 Reply. #: 4994 S3/Languages 08-Jul-90 14:09:26 Sb: #4979-#I don't C so well ! Fm: Kevin Darling (UG Pres) 76703,4227 To: TONY CAPPELLINI 76370,2104 (X) Tony, The original printer driver timed out after a coupla seconds... which was complained about (and patched in numerous files on BBSs and here), because most programs couldn't deal with getting back an E$NotRdy error. And it really goofed up people trying to single-sheet feed a printer. So it was actually found that most people preferred no time out on the printer driver. But you're right, it'd be good to have a way to check the status. Any thoughts? Can't just check the busy line... would have to be a delay on that status, etc. I can send you the original driver source if you wish. Kev There is 1 Reply. #: 5027 S3/Languages 09-Jul-90 19:24:01 Sb: #4994-#I don't C so well ! Fm: TONY CAPPELLINI 76370,2104 To: Kevin Darling (UG Pres) 76703,4227 (X) Kev. Thanx but no thanx. I don't think I could do much with the driver. But can you tell me why my program just sits and waits for the printer to be put back on-line. My code is as follows, if( !(status = write(printer, font_code, fontbuf_len) )) { printf("\nError ! Printer is off-line or not connected. "); fflush(stdout); } Is it just the way I am implementing this, or is that the way os9 works ? TC There are 2 Replies. #: 5032 S3/Languages 09-Jul-90 20:27:28 Sb: #5027-I don't C so well ! Fm: Kevin Darling (UG Pres) 76703,4227 To: TONY CAPPELLINI 76370,2104 Tony - what's happening is that the printer driver doesn't abort... it simply waits until the printer is ready for the next character. Which could be forever, of course. I suppose the driver could/should be rewritten to handle some kind of ready? statcall (which would have to wait a second or two just in case the printer is still busy, before returning the status). Right now, I can think of two ways to handle it. One, fork another process either to do the printing, which you can abort if it doesn't signal you that it's started, or two, you could present a dialog box with "Please make sure your printer is online" type of thing? #: 5042 S3/Languages 10-Jul-90 09:09:32 Sb: #5027-I don't C so well ! Fm: Mark Wuest 74030,332 To: TONY CAPPELLINI 76370,2104 Tony, I use OSK, but I have a solution that will work. I used this back before OSK had the alarm() calls. I wrote a program called timesig which took exactly 3 arguments: argv[1] is the process you want to signal, argv[2] is the signal to send, and argv[3] is the time to wait (I used seconds). (Of course, argv[0] was "timesig"). This way, you can os9fork() timesig to send yourself a signal in a couple of seconds just before you do the write() and, if your write() returns (-1), just check to see if you got the signal. Here's sort of what timesig looked like: main(argc, argv) int argc; char *argv[]; { int pid, sigval, time; pid = atoi(argv[1]); sigval = atoi(argv[2]); time = atoi(argv[3]); sleep(time); kill(pid,sigval); } Good luck! Mark #: 4961 S3/Languages 07-Jul-90 18:36:49 Sb: #4941-#I don't C so well ! Fm: Zack Sessions 76407,1524 To: TONY CAPPELLINI 76370,2104 (X) As Pete mentioned, if you try to open a path to a device which is not ready, the error code returned is 246 (E$NotRdy). If you use the C Systemhfunction open(), it will simply return -1 on any open error. Without seeing more of your code, it hard to tell. I tested the following code segment on my system and it functions as expected, ie, clears the second line of the display. #include main() { putchar(0x0c); puts("This data is on Line 1"); puts("This data is on Line 2"); puts("This data is on Line 3"); tsleep(120); putchar(0x02); putchar(0x20); putchar(0x21); putchar(0x04); fflush(stdout); tsleep(120); putchar(0x02); putchar(0x20); putchar(0x2a); puts("Just one more line!"); } Oh, and $0B is not just for graphics screens. Zack There is 1 Reply. #: 4980 S3/Languages 08-Jul-90 11:46:52 Sb: #4961-I don't C so well ! Fm: TONY CAPPELLINI 76370,2104 To: Zack Sessions 76407,1524 (X) I guess I should do the error checking on the open() line, instead of the write() line. But if somehow the printer was turned off or off-line between the open() and the write(), how would you test for it. Aaas I said my program sits and waits without printing any errors until I manually put the printer ON-LINE. I like to make my programs as bullet-proof as possible. AS you can see, if I can't detect a printer beong off-line, the program is full of holes. I'm not sure how to upload code-fragments here or I would send yoy what I am working with. Maybe I'll give you a call and we can do it over the phone. By looking at the code you sent me, I'm not sure we are talking about the same situation. I know how hard it is to get the big picture when your not actually looking at a printout. TC #: 4970 S3/Languages 08-Jul-90 09:44:04 Sb: #4941-#I don't C so well ! Fm: Bruce MacKenzie 71725,376 To: TONY CAPPELLINI 76370,2104 (X) Tony, On buffered writes to SCF devices C uses I$WriteLn which activates line editing at the op system level. This filters out a lot of non-ASCII control codes. It's best to use the system call function write() to send control codes to the screen, printer and such. Try: char c; c=4; write(fileno(stdout),&c,1); or if you have cgfx.l you can use: ErEOLine(fileno(stdout)); There is 1 Reply. #: 4981 S3/Languages 08-Jul-90 11:49:41 Sb: #4970-#I don't C so well ! Fm: TONY CAPPELLINI 76370,2104 To: Bruce MacKenzie 71725,376 (X) Bruce Look at my message again. I AM using write(), not writeln(). But I turned my printer off line, AFTER I opened the path to /p1, to see what would be returned from write() when the printer was not ready. Wwell my program just sits there and waits until the printer is put back on line. Aas you can see this is not acceptable, but how do I get around this ? TC There are 2 Replies. #: 4995 S3/Languages 08-Jul-90 14:11:28 Sb: #4981-#I don't C so well ! Fm: Kevin Darling (UG Pres) 76703,4227 To: TONY CAPPELLINI 76370,2104 (X) PS: I think most printer drivers wait forever these days. However, they also do F$Sleeps... I wonder if another process could be used to do the printing, and maybe the main one could time-out and abort things? There is 1 Reply. #: 5028 S3/Languages 09-Jul-90 19:24:52 Sb: #4995-I don't C so well ! Fm: TONY CAPPELLINI 76370,2104 To: Kevin Darling (UG Pres) 76703,4227 (X) Good Idea. I'll try a timeout from main. TC #: 5025 S3/Languages 09-Jul-90 16:41:48 Sb: #4981-#I don't C so well ! Fm: Bruce MacKenzie 71725,376 To: TONY CAPPELLINI 76370,2104 (X) Tony, My reply refered to the second part of your message about why putchar(04) didn't do what you wanted it to do. For the printer try doing a getstat(1,PATH). If you're printer driver services the SS.RDY getstat call this should return -1 if the printer is off line. The standard LVL II bit banger /p doesn't service the call by the way. It always returns -1 and an illegal service request error code in errno. There is 1 Reply. #: 5029 S3/Languages 09-Jul-90 19:27:42 Sb: #5025-I don't C so well ! Fm: TONY CAPPELLINI 76370,2104 To: Bruce MacKenzie 71725,376 (X) Bruce I haven't used getstat() yet. I'm not sure how it works. I'll have to dig into the books tonight, after school. I'm using a Disto driver and /p1, so I don't know if it works like you said. I think Kevin MAY have written it, but I'm not sure. Kev ? TC #: 4964 S3/Languages 07-Jul-90 20:50:29 Sb: #sqrt() function in C? Fm: Zack Sessions 76407,1524 To: ALL I have the need to use the sqrt() function in a C program. I have the latest version of the Krieder lib. The docs state that there is an int sqrt(n) function. When I try to link a program which uses it, I get it as an unresolved reference. dEd of clib.l sure enough shows there is no sqrt() function. What gives?!? Zack There are 2 Replies. #: 4968 S3/Languages 08-Jul-90 04:26:53 Sb: #4964-#sqrt() function in C? Fm: James Jones 76257,562 To: Zack Sessions 76407,1524 (X) I'd be surprised if there were an int sqrt function. I'd expect it to take a double argument and return a double result. Try clibt.l from the Kreider library. There is 1 Reply. #: 4971 S3/Languages 08-Jul-90 10:06:08 Sb: #4968-#sqrt() function in C? Fm: Zack Sessions 76407,1524 To: James Jones 76257,562 (X) There is a double int function in clibt.l, I checked that. I also tried merging clibt.l to the end of clib.l and then got a bunch of multiply defined symbols. The docs DO state an int sqrt() function plain as day on page 39. The double function would work just as well for me, but how do I use clibt.l AND clib.l at the same time? Zack There is 1 Reply. #: 4974 S3/Languages 08-Jul-90 11:04:27 Sb: #4971-#sqrt() function in C? Fm: Pete Lyall 76703,4230 To: Zack Sessions 76407,1524 (X) Jack - (oops.. Zack).. Don't merge 'em... Clibt is a superset of clib. The transcendentals are extra, and all the math stuff is rewritten for speed at the sacrifice of size (in Clibt). Otherwise, they're identical. Pete There is 1 Reply. #: 4993 S3/Languages 08-Jul-90 13:56:42 Sb: #4974-sqrt() function in C? Fm: Zack Sessions 76407,1524 To: Pete Lyall 76703,4230 (X) Like I said in my last message, it was moot. OK, I'll try clibt.l, and use the double sqrt() function. [D [D Zack #: 4972 S3/Languages 08-Jul-90 10:58:37 Sb: #4964-#sqrt() function in C? Fm: Pete Lyall 76703,4230 To: Zack Sessions 76407,1524 (X) Zack - Use Clibt.l instead. Pete There is 1 Reply. #: 4992 S3/Languages 08-Jul-90 13:55:20 Sb: #4972-sqrt() function in C? Fm: Zack Sessions 76407,1524 To: Pete Lyall 76703,4230 (X) What about function references to functions in clib.l? Does clibt.l provide those functions? I have two other message I haven't read yet, so this message may ne moot. Zack #: 4998 S3/Languages 08-Jul-90 15:18:20 Sb: #still sqrt() problems Fm: Zack Sessions 76407,1524 To: ALL OK, I am now using clibt.l. So how come the following program: #include main() { double x, y; pffinit(); x = 36; y = sqrt(x); printf("Th square root of %f is %f\n",x,y); } Gives the following output: The square root of 36.000000 is 0.000000 Zack There are 2 Replies. #: 5004 S3/Languages 08-Jul-90 17:26:51 Sb: #4998-#still sqrt() problems Fm: Pete Lyall 76703,4230 To: Zack Sessions 76407,1524 (X) Zak - Do you have the sqrt() routine declared as returning a double? Pete There is 1 Reply. #: 5005 S3/Languages 08-Jul-90 18:33:14 Sb: #5004-still sqrt() problems Fm: Zack Sessions 76407,1524 To: Pete Lyall 76703,4230 (X) Oh, gosh, you're right! Default type for a function is int, isn't it. Zack #: 5008 S3/Languages 08-Jul-90 22:05:17 Sb: #4998-still sqrt() problems Fm: James Jones 76257,562 To: Zack Sessions 76407,1524 (X) Because C lets you sleaze out and not declare functions, assuming them to return int. sqrt() doesn't return an int, it returns a double--so the code generated for main probably snarfs the least-significant sixteen bits of the double returned and treats it like an int, which probably gives you a zero. Either explicitly declare "double sqrt();" or put in the directive "#include ". {{_ #: 5089 S3/Languages 11-Jul-90 18:50:13 Sb: #Basic09 Fm: Floyd Resler 72500,2572 To: all I have a couple questions about BASIC09. Does something get messed up when you use a GOSUB or call another procedure between EXITIF and ENDEXIT? For example, EXITIF variable>2 THEN GOSUB 200 ENDEXIT or EXITIF variable>2 THEN RUN program ENDEXIT In either of the above examples, control returns after the ENDEXIT not at the bottom of the loop. Am I doing something wrong or is this just a problem with BASIC09? Question 2: Sometimes, while in the trace mode, I'll hit a STOP in the my program will end (of course). However, from that point forward, all results of variable manipulation are displayed whether I'm in trace or not. Is there any way to stop this other than restarting BASIC09? There is 1 Reply. #: 5093 S3/Languages 11-Jul-90 20:10:23 Sb: #5089-Basic09 Fm: James Jones 76257,562 To: Floyd Resler 72500,2572 I just tried a simple example with the GOSUB in the EXITIF THEN clause, and did not have the problem you describe. I'd take a close look at the contents of the subroutine. #: 5097 S3/Languages 11-Jul-90 22:28:43 Sb: Kreider clib docs Fm: Mark Griffith 76070,41 To: All To All C programmers: I recently uploaded the complete docs for the Kreider Library in DL3. These docs, all 147 pages and 160K+ cover everything in the library. Also included is a new MROFF for printing, and a simple MAN utility for online viewing. Many programming examples are included to help those having trouble. Enjoy. Mark #: 5178 S3/Languages 14-Jul-90 01:19:24 Sb: #5097-#Kreider clib docs Fm: Bob van der Poel 76510,2203 To: Mark Griffith 76070,41 (X) Mark, Just finished having a look at the new clib docs. Great job. However, two files seem to be missing from the archive: system.txt and sleep.txt. Also, exit.txt gives an mroff error during printing. In assembling the new mroff I had to change the #include to a #include and make some changes to sgstat.h since I do not have a copy of scfstat.h.... not a problem, but could be pretty frustrating to a novice C programmer just trying to print out the docs. Anyway, could you post the 2 missing files (PLEASE, do this as a separate upload--I don't want to DL the entire 156K again!!). There are 2 Replies. #: 5190 S3/Languages 14-Jul-90 12:02:42 Sb: #5178-Kreider clib docs Fm: Jim Peasley 72726,1153 To: Bob van der Poel 76510,2203 (X) Bob; scfstat.h is available in header.ar - just checked my index of ar files. Not sure in which DL it's in, but I got it here. ..Jim #: 5212 S3/Languages 14-Jul-90 23:04:52 Sb: #5178-Kreider clib docs Fm: Mark Griffith 76070,41 To: Bob van der Poel 76510,2203 (X) Bob, I'll re-upload the missing files and include exit.txt with the error fixed. Whew! This was a long monster to do (almost two years in the making). I'd expected more mistakes, but I must have read the files over about 100 times. I don't want to upload this all again either. The first attempt, CIS locked up at 158K, but the second try went fine. I also am a long distance call to a CIS node. Look in DL3 for a file HEADER.AR or something like that from me. It has all the header files you need to run Carls library. The only difference between scfstat.h and sgstat.h is the former doesn't have the structure for the rbf descriptors. Mark #: 5227 S3/Languages 15-Jul-90 11:50:22 Sb: Clib Documents Fm: Ken Drexler 75126,3427 To: Mark Griffith 76070,41 Mark, The Kreider library documents look great! They are a great improvement over the old set. I downloaded clibdo.ar yesterday and discovered a few bugs: (No 147 page document would be complete with out a few.) 1. The following files have lines which exceed 80 characters in width when the line and page indent is included: conv.txt, gs_rdy.txt, password.txt and unixtime.txt. Because of the tight page spacing, this throws off the page formatting for all following pages. 2. The .sh macro in setstat.txt is missing its <.>. 3. The sleep.txt and system.txt files are missing from the archive file. 4. Mroff.mdoc is missing all sections after 7.1. Based on the cross-reference table, the missing sections are 7.2 through 11.1. I can fix the first two items but would appreciate the missing files and the rest of the mroff manual. Thanks. Ken #: 5246 S3/Languages 16-Jul-90 02:10:09 Sb: #5212-Kreider clib docs Fm: Bob van der Poel 76510,2203 To: Mark Griffith 76070,41 (X) Mark, Okay, I'll look for the new files later. Then I guess I just have to print it all out.... BTW, the copy of sgstat.h I have has the RBF stuff in it, without a structure tag. Also, the members for sgbuf must have a few different names than the scfstat.h you are using. I got all the header files for Carl's library when I dl'd the library. They were included in the archive. I'll have a look at header.ar as per Jim's suggestion. #: 5250 S3/Languages 16-Jul-90 06:11:21 Sb: #5227-#Clib Documents Fm: Mark Griffith 76070,41 To: Ken Drexler 75126,3427 Ken, Hmmmmm.....it appears that my copy of the mroff docs has been tuncated. I'm missing everything from section 7.1 on and the archive was lost a couple years ago. Perhaps someone else has a good copy and can upload it here. I always looked at my printed copy so I never noticed. Sorry. Mark There is 1 Reply. #: 5259 S3/Languages 16-Jul-90 16:23:45 Sb: #5250-Clib Documents Fm: Zack Sessions 76407,1524 To: Mark Griffith 76070,41 Look for it in email. Zack #: 5303 S3/Languages 18-Jul-90 00:07:48 Sb: #5250-Clib Documents Fm: Ken Drexler 75126,3427 To: Mark Griffith 76070,41 Mark, Thanks for the message. I will look for the mroff documents in the library. Could you upload the missing sleep.txt and system.txt files? Also they should be added to the .ar file. Ken #: 5304 S3/Languages 18-Jul-90 01:18:40 Sb: #Clib docs Fm: Bob van der Poel 76510,2203 To: Mark Giffith 76070,41 to: Mark Griffith 76070,41 subject: clib docs Mark, A few more problems with the new clib docs. 1. I belive that the page for defdrive() is missing. 2. A couple of formatting problems (doesn't mroff do line wrap???). The pages for _gs_rdy, password, and unixtime all contain lines which are too long for the right margin. This causes an extra line feed(s) which mroff is not aware of with the result that the page breaks are out of sync. I fixed it by inserted a CR in the offending lines. All we need now is an index (hint!). This package of docs is a vast improvement over the previous situation--at least now I only need about 4 manuals (instead of 5!) open on my desk. Thanks again. BTW, what do the numbers at the top of the pages mean: (3c) (3s), etc. There is 1 Reply. #: 5312 S3/Languages 18-Jul-90 07:20:21 Sb: #5304-Clib docs Fm: James Jones 76257,562 To: Bob van der Poel 76510,2203 The numbers probably roughly correspond to those you'd find in Nuxi--er, Unix--manual pages (1 for programs, 2 for system calls, 3 for standard I/O and other library functions). #: 5346 S3/Languages 19-Jul-90 06:02:37 Sb: #5303-#Clib Documents Fm: Mark Griffith 76070,41 To: Ken Drexler 75126,3427 (X) Ken The missing pages were uploaded a couple days ago as DOCFIX.AR. Mark There is 1 Reply. #: 5416 S3/Languages 21-Jul-90 10:57:01 Sb: #5346-Clib Documents Fm: Ken Drexler 75126,3427 To: Mark Griffith 76070,41 Mark, Thanks. Ken #: 5347 S3/Languages 19-Jul-90 06:02:43 Sb: #5304-Clib docs Fm: Mark Griffith 76070,41 To: Bob van der Poel 76510,2203 (X) Bob, I guess I forgot to do a page for defdrive(). Here's your chance! MROFF does do line wraps, but I turned it off for the name and synopsis sections of the manual pages cause I didn't want it to wrap. I know a couple of the lines are longer than the width of the rest of the text. I printed everything out here before I uploaded it (that's how I found out the page numbers for the index), so it should have printed fine for you too. The numbers at the top of the page are like JJ said, an attempt to made things look UNIX-like. Mark #: 5366 S3/Languages 19-Jul-90 21:42:20 Sb: #Make Fm: DENNIS SKALA 73177,2365 To: 76070,41 (X) Mark, I downloaded the Kreider library docs. I appreciate your putting them together - it must have been quite an effort! I finally got mroff compiled, and am well on my way toward getting the docs printed. But I could not get 'make' to work (never used it before). Here's my slightly edited version of your makefile: * Makefile to compile MROFF ODIR = /dd/lang/c/cmds RDIR = /dd/lang/rels RFILES = nromain.r nrotxt.r nromac.r nroio.r * CFLAGS = -s mroff: $(RFILES) chd /dd/lang/rels; cc $(RFILES) -f=$(ODIR)/Mroff -m=4k -e=11 nroio.r: nro.h nroio.c nromac.r: nro.h nromac.c nrotxt.r: nro.h nrotxt.c nromain.r: nro.h nromain.c * END And here is the output it produces: cc -r=/dd/lang/rels nromain.c cc -r=/dd/lang/rels nrotxt.c cc -r=/dd/lang/rels nromac.c cc -r=/dd/lang/rels nroio.c chd /dd/lang/rels; cc nromain.r nrotxt.r nromac.r nroio.r - f=/dd/lang/c/cmds/Mroff -m=4k -e=11 Now my compiler (the plain vanilla cc1 level I Microware version sold by Tandy) chokes on the -r=stuff. Of course I had to rename the file 'cc' for the sake of make. -r all by itself is an OK option. Why does make' produce this non-legal output? Or am I missing something here? make - edition $12, CRC = $41F1F2 cc1 - edition 4, CRC = $63CE5F ***** Dennis ***** There is 1 Reply. #: 5368 S3/Languages 19-Jul-90 23:31:35 Sb: #5366-Make Fm: Mike Haaland 72300,1433 To: DENNIS SKALA 73177,2365 ~ Dennis, Grab CC.AR in lib 3 here. It has CC front end in it uses the -r= option fine. Did you ever get the Development System from Tandy? You should if you're gonna get busy with C under Level II. It's (the Dev Pak) got a new Linker and a new Assembler for level II. MikeH BTW- That -r= is a 'legal' option. #: 5472 S3/Languages 22-Jul-90 21:46:38 Sb: #5368-Make Fm: DENNIS SKALA 73177,2365 To: Mike Haaland 72300,1433 (X) Mike, Sure, I have the Development System - that's where 'make' comes from. I found it odd that it is somewhat incompatible with the official C compiler. I notice in the docs that they refer to OSK a lot. I suspect that the version of 'make' in the Level II Development System was hastily kludged from the OSK version, and the "r=stuff" incompatibility slipped through. I *DID* have the cc.ar from DL3 here, and for some reason had returned to using the original cc1. Rereading the docs, I see that version *DOES* support "r=stuff". End of problem. Thanks for the input. BTW, one of these days I'm gonna have to cough up for the MVCanvas upgrade. I should've just given you the original, some $, and my address in Chicago! ***** Dennis ***** Press !> #: 5490 S3/Languages 23-Jul-90 21:22:36 Sb: CLIB Docs Fm: Zack Sessions 76407,1524 To: 76070,41 (X) Mark, Was the popen() and pclose() functions intended to be included in your recent upload of the Krieder Lib docs? If so, then they are missing. Otherwise, NICE job! Zack #: 5502 S3/Languages 24-Jul-90 01:21:14 Sb: #5347-Clib docs Fm: Bob van der Poel 76510,2203 To: Mark Griffith 76070,41 (X) Mark, There really are some too-long lines in the docs. I'm using an 80 column printer in pica. If you are too then something is really strange. Regarding the numbers at the top of the pages, I should have figured out the Unix connection myself. After all (I'm learning bit by bit) if there is something cryptic relating to OS9 then is usually a Unix influence. Just what was the mother-tongue of the folks who created Unix anyway??? Oh, and thanks for the reminder about the index--I guess I can just print out the man.hlp file and stick it in the back of my new manual. Should work fine. I'll leave defdrive() for now--I'm not sure why anyone would ever use that command anyway? Guess it is a hold-over from before /dd conventions? Oh, I just noticed that the description for RAND() is still wrong. Unless I am missing something in the way the function works it does not use a scale factor. It would be nice if it did! Could this be a difference between clib.l and clibt.l? #: 5538 S3/Languages 25-Jul-90 06:11:20 Sb: #5502-#Clib docs Fm: Mark Griffith 76070,41 To: Bob van der Poel 76510,2203 (X) Bob, Huh, rand() is right. I talked to Carl when there was a hubbub here about how to use it and he gave me the scope. Rand() has no scale and srand() is used to seed it. The example I gave in the docs works. Here is another: #include main() { long time(); srand((unsigned) time(0)); /* seed the generator */ printf("%d\n", rand()); printf("%d\n", rand()); printf("%d\n", rand()); printf("%d\n", rand()); srand((unsigned) time(0)); /* reseed the generator */ printf("%d\n", rand()); printf("%d\n", rand()); printf("%d\n", rand()); printf("%d\n", rand()); } Mark There is 1 Reply. #: 5595 S3/Languages 27-Jul-90 01:18:40 Sb: #5538-Clib docs Fm: Bob van der Poel 76510,2203 To: Mark Griffith 76070,41 Mark, thanks for the additional comments on rand(). The problem is that according to the recent docs you uploaded (as well as my original docs for Carl's library) the syntax for rand() is given as rand(sf). Also, there is no example in the docs (I'm looking at the page titled "math"). By the way, if a range is needed it is simple enought to do using the modulus operator. For example, to get a random number between 1 and sf just do something like: int n; n=(rand()%sf)+1; Also, the way the function works is in agreement with other 'C' library info I have. Anyway, thanks again for the excellent job on the new docs. Having the whole works in one manual is very nice. #: 5570 S3/Languages 26-Jul-90 01:09:51 Sb: #info headers in c Fm: Bob van der Poel 76510,2203 To: all I was just looking for something in my C manual (the MW.6809 version sold by Tandy) and came across something interesting. On page 2-2 in the middle of the page there is a section "information" which implies that version numbers, etc. can be placed in C programs. But just what is the "directive 'info'"? According to the manual one should have something like #asm info /version/ #endasm But, of course, RMA has never heard of the op "info". Any one have any ideas as to what this means--or is it just wishful thinking on the part of the person who wrote the docs? There are 2 Replies. #: 5572 S3/Languages 26-Jul-90 04:35:41 Sb: #5570-#info headers in c Fm: Kevin Darling (UG Pres) 76703,4227 To: Bob van der Poel 76510,2203 (X) Bob - just a guess, but I'd say that perhaps they meant a label instead? Like perhaps "info fcb version" ? That would embed a number, tho who knows where (unless they had you put it at the front, maybe). I thought the compiler had an option to add the revision number? Or maybe that's under OSK only. Dunno. There are 2 Replies. #: 5578 S3/Languages 26-Jul-90 09:31:42 Sb: #5572-#info headers in c Fm: Pete Lyall 76703,4230 To: Kevin Darling (UG Pres) 76703,4227 (X) Not staring at a manual at the moment, but I believe that the CC (or CC1, CC2) compiler driver has a '-E' option that allows you to set the edition #, or something to that effect. Pete There is 1 Reply. #: 5590 S3/Languages 26-Jul-90 18:39:17 Sb: #5578-info headers in c Fm: Kevin Darling (UG Pres) 76703,4227 To: Pete Lyall 76703,4230 (X) The wonderful help file you gave me a long time ago for CC, agrees with you ( -e=n for edition number). And I shoulda said "edition" myself, instead of "revision" in my previous message. thx! #: 5601 S3/Languages 27-Jul-90 01:47:47 Sb: #5572-info headers in c Fm: Bob van der Poel 76510,2203 To: Kevin Darling (UG Pres) 76703,4227 (X) Kevin, Yes, it would be possible to use a label like you suggested. But I'm quite sure the data would NEVER end up in the space they say it will. #: 5581 S3/Languages 26-Jul-90 12:44:25 Sb: #5570-info headers in c Fm: Zack Sessions 76407,1524 To: Bob van der Poel 76510,2203 (X) Hmm, I see what you're talking about, Bob. (Oh, btw, got the disk, THANKS!) I never noticed that before, not sure what they are talking about, but as Pete mentioned, there is a commandline option to set the edition number. Actually, this is passed on to rlink, which actually sets the edition number in the final memory module created. Looks like the info directive lets one put character string data in for some type of identification, but since I never noticed that in the manual, I haven't tried to use it. If you figure it out, let us know! Zack #: 5571 S3/Languages 26-Jul-90 01:10:34 Sb: #Data compression Fm: Bob van der Poel 76510,2203 To: all Does anyone know if there is a chunk of C code kicking around which will do some kind of effecient data compression on a string. I would like to pass the routine a pointer to a null terminated string and get back a pointer to a compressed version of the string plus its size. The data would be ascii characters (always) so I'm not sure what compression scheme would be best. LZW? I've looked at the source for AR and I guess I could change it to work on in-memory buffers, but I hate to re-invent the wheel all the time--besides, it looks pretty complicated and is probably a case of overkill for my purposes! There are 2 Replies. #: 5579 S3/Languages 26-Jul-90 09:36:43 Sb: #5571-#Data compression Fm: Pete Lyall 76703,4230 To: Bob van der Poel 76510,2203 (X) Bob - None that we know of. Also, the effects of LZW encoding might be lost on parcels as small as simple strings. JJ and Carl are more up on LZW than I, but I believe it analyzes a larger cross section for redundancies, and then builds a table based upon the frequency of the redundancies. If you were only working with ASCII, you could write your own that would take characters and mash them to 7 bits. This way, you could have 8 characters in every 7 bytes. If you were working with non numeric, or all upper/lowercase, you could probably get a better compression as well by using less bits (6 or 5). Pete There is 1 Reply. #: 5600 S3/Languages 27-Jul-90 01:47:34 Sb: #5579-#Data compression Fm: Bob van der Poel 76510,2203 To: Pete Lyall 76703,4230 (X) Hmmm, the 8 to 7 compression just isn't enough. My strings will actually be quite long - probably 1500 bytes - and will contain a lot of spaces at times. I'm toying with doing an index-card type DB. The idea is to have a full-screen card which will get compressed and saved in a file. I'd like to compress things to keep the filesize down. There is 1 Reply. #: 5610 S3/Languages 27-Jul-90 09:44:03 Sb: #5600-Data compression Fm: Pete Lyall 76703,4230 To: Bob van der Poel 76510,2203 Bob - Hmmm... at 1500 bytes, you might be able to get some advantage out of LZ, or even the RLE, especially if your data is highly redundant. RLE may also be the lowest overhead. Pete #: 5586 S3/Languages 26-Jul-90 17:43:47 Sb: #5571-#Data compression Fm: Jim Williams 72157,3524 To: Bob van der Poel 76510,2203 (X) I dled some C source for an LZW type of compression scheme from DDJ forum a few months ago. I assume a simple RLE scheme wouldn't do? --Eet-- Director of Mayhem Extra Terrestrial Imports, Ltd. There is 1 Reply. #: 5599 S3/Languages 27-Jul-90 01:46:48 Sb: #5586-Data compression Fm: Bob van der Poel 76510,2203 To: Jim Williams 72157,3524 (X) Actually RLE would probably be just as effective (see my note to Pete). Do you happen to recall the name/library of the the stuff you D'ld. And, speaking of RLE, do you happen to have any code for that? #: 5617 S3/Languages 27-Jul-90 14:39:06 Sb: clib.l docs Fm: Zack Sessions 76407,1524 To: Mark Griffith 76070,41 Mark, I assume you saw my message about popen() and pclose()t(, didn't get any response from ya. Are they supposed to be include