#: 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 included in the documentation? Also, a few others, _gs_styp() is not there and strhcpy(). (I wonder why there's not an strhcat()?) And there is still a mention of an int version of the sqrt() function, even though it doesn't exist. Thanks, Zack #: 5639 S3/Languages 28-Jul-90 07:15:00 Sb: #5595-Clib docs Fm: Mark Griffith 76070,41 To: Bob van der Poel 76510,2203 (X) Bob, >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"). You must have not replaced the new man page for the old one since the new one certainly does have it correct and there is an example there. Mark #: 5706 S3/Languages 30-Jul-90 05:55:45 Sb: #5600-Data compression Fm: Scott t. Griepentrog 72427,335 To: Bob van der Poel 76510,2203 (X) Why not store the individual lines of the index card as variable size records in the key. That way you can have an index card of any length, insert/delete easily, etc. I have routines for this - the DB9 index method allows variable length keys, and no need to link to a data file. Data goes in key file - sorta combined. Just a thought... StG #: 5739 S3/Languages 31-Jul-90 22:20:09 Sb: #5599-Data compression Fm: Jim Williams 72157,3524 To: Bob van der Poel 76510,2203 (X) Uhm, I don't have any RLE code, except as part of an IFF file loader routine (prolly can find some in lib 9 of amigatech). As for the LZW code, it was called LZComp... dunno the compression scheme. I _think_ it was in lib 0 or 1. --Eet-- Director of Mayhem Extra Terrestrial Imports, Ltd. #: 5780 S3/Languages 02-Aug-90 16:03:44 Sb: #mktime function help Fm: SCOTT HOWELL 70270,641 To: all Can someone show me a c program fragment for the correct usage of the mktime() function. There is 1 Reply. #: 5782 S3/Languages 02-Aug-90 16:51:57 Sb: #5780-mktime function help Fm: Bruce MacKenzie 71725,376 To: SCOTT HOWELL 70270,641 It's easy enough Scott. char str[12]; FILE *out; strcpy(str,"temp.XXXXX"); mktemp(str); out=fopen(str,"w"); The above creates a file with a name such as temp.5 or temp.3 depending on what the process id is. #: 5785 S3/Languages 03-Aug-90 04:36:12 Sb: #CoCo 3 'C' Fm: edward langenback 73510,145 To: all is tpublic domain 'C' compiler available for the CoCo3? i've been wanting to get into 'C', but i've found that Rat-Shack no longer seems to have the 'C' compiler, at least, when i asked about it, no one knew what i was talking about. actually, some seemed to think that the idea of programming 'C' on the CoCo to be rather humorous. thanks, "KMA-68!!" >>>>>S S<<<<< !!!!!!!!!!!!! There is 1 Reply. #: 5786 S3/Languages 03-Aug-90 05:54:26 Sb: #5785-#CoCo 3 'C' Fm: Kevin Darling (UG Pres) 76703,4227 To: edward langenback 73510,145 (X) Ed - I don't know of any PD C compilers for the coco. We thought about porting one for the KMAs, but since C is included on those, never mind ;-). Supposedly you can still order the coco C from Express Order Software. If you can find the old catalog number, you could beat up on yer local shack guy. Or call direct, I think. Anyone remember? Yah on the humorous part. Ed Gresick likes to remind people that some thought that running several users off multiple serial ports was funny, too . There is 1 Reply. #: 5813 S3/Languages 04-Aug-90 03:44:21 Sb: #5786-#CoCo 3 'C' Fm: edward langenback 73510,145 To: Kevin Darling (UG Pres) 76703,4227 (X) ok thanks, i'll get hold of the express order catalog and do that. as for humor, someone once asked me (in a serious tone no less!) "is a Color Computer anything like Nintendo?" all i could do not to laugh in his face! and as for Rip Shaft, well.... ..."KMA-68!!" >>>>>S S<<<<< !!!!!!!!!!!!! s There is 1 Reply. #: 5818 S3/Languages 04-Aug-90 08:56:29 Sb: #5813-#CoCo 3 'C' Fm: Zack Sessions 76407,1524 To: edward langenback 73510,145 (X) In case the Rat Shack gives you grief about the Expw3res Order catalog, you can order it your self with a credit card. Call 1-800-321-3133. Cat Nu. 26-3038 CMC. Retail price $99.95. Zack There is 1 Reply. #: 5900 S3/Languages 06-Aug-90 03:56:12 Sb: #5818-CoCo 3 'C' Fm: edward langenback 73510,145 To: Zack Sessions 76407,1524 (X) thanks, hopefully, i shouldn't have too much trouble if i go in telling them *exactly* what i want and that i know they'll have to express order it. "hopefully that is....;)" "KMA-68!!" >>>>>S S<<<<< !!!!!!!!!!!!! s #: 5809 S3/Languages 03-Aug-90 23:57:28 Sb: #UPLOAD quota exceeded Fm: Greg Morse 72746,3451 To: sysop (X) SYSOP - I have a huge archive file ($2a99e bytes) that I would like to upload. this may cause the lib to exceed its quota. what to do? (it is the source code for the IAPL interpreter) - greg morse. There is 1 Reply. #: 5821 S3/Languages 04-Aug-90 09:32:32 Sb: #5809-UPLOAD quota exceeded Fm: Mike Ward 76703,2013 To: Greg Morse 72746,3451 (X) Greg, If it's one file, go ahead and upload it to Lib 3 and I'll handle it from there. If you want it in another Lib just leave me a note and I'll move it. Thanks! Mike #: 5810 S3/Languages 04-Aug-90 00:40:19 Sb: #APL INTERPRETER for FREE Fm: Greg Morse 72746,3451 To: all I have just uploaded a port for os9 of the free IAPL interpreter. Welcome comments on any bugs found. Run time system only today will upload source when sysop lets me! see APLRTS.AR in dl3. (PS This is for 6809 not osk). Greg Morse. There are 2 Replies. #: 5814 S3/Languages 04-Aug-90 04:01:38 Sb: #5810-APL INTERPRETER for FREE Fm: James Jones 76257,562 To: Greg Morse 72746,3451 (X) Yow! Thanks. (Now, is there an associated graphics font that has all the interesting characters? Maybe that could be an exercise for an enterprising person once the source is uploaded...) #: 5828 S3/Languages 04-Aug-90 12:00:17 Sb: #5810-APL INTERPRETER for FREE Fm: Wayne Day 76703,376 To: Greg Morse 72746,3451 (X) The problem with space in Library 3 has been fixed, and we await your pleasure. Wayne #: 5839 S3/Languages 04-Aug-90 14:52:53 Sb: APL FONTS Fm: Greg Morse 72746,3451 To: 76257,562 (X) James. Yes the font issue has been addressed two ways. First the IAPL society have defined a ascii to apl mapping to allow even a dumb vt220 to run iapl pgms. 2nd the os9 port will run a cmdfile on startup to download a font to your terminal. Of course you must define the font! I have done this for vt220 (see vt220fnt.ar in dl6?) you can tell IAPL that you have such a font and it will output different characters in that case. #: 5872 S3/Languages 05-Aug-90 11:56:37 Sb: #Mroff docs Fm: Ken Drexler 75126,3427 To: Mark Griffith 76070,41 (X) Mark, I found the full mroff documentation in DL 6 and downloaded it. I have now edited your modifications into the complete user's manual for my use. If you want I can upload it for you to post with your clib documentation. It is 44,000 bytes long in ascii before "ar'ing". Ken There is 1 Reply. #: 5883 S3/Languages 05-Aug-90 16:41:10 Sb: #5872-Mroff docs Fm: Mark Griffith 76070,41 To: Ken Drexler 75126,3427 Ken, I will be uploading an archive in the near future that will include some fixes for the files in the clib docs. I can include the revised mroff docs then, unless you want to upload it and save me the trouble (grin). Mark #: 5876 S3/Languages 05-Aug-90 15:08:21 Sb: #StG Lib upl to lib#3 Fm: Scott t. Griepentrog 72427,335 To: all For all who are interested, I have uploaded the library used on the V3 login package. Actually, just one of them - if there's enough interest, I'll upl the other, the CC exec that goes with it, and maybe even some source to various parts of the package. So, if you want more, speak up! StG There is 1 Reply. #: 5877 S3/Languages 05-Aug-90 15:10:52 Sb: #5876-StG Lib upl to lib#3 Fm: Scott t. Griepentrog 72427,335 To: Scott t. Griepentrog 72427,335 (X) Oh, BTW, this is the same stuff that has already been distributed on StG-net, so if you've seen it before, it's not a new version. There will be a new version when I'm done with V4 in a bit though. #: 5894 S3/Languages 05-Aug-90 23:21:03 Sb: Pascal help Fm: William L. Cotter 72557,306 To: All I have a problem running the PascalT.PRUN translator. I have a small Pascal program that I want to assemble so I can add it to my cmds dir Whenever I try to use PascalT.PRUN as described in the manual (page 4-2) I get nothing but errors and my machine locks up. Is there a compatibility problem with Pascal and OS9 Level 2 in the PascalT program? My program runs fine in P-code, but I want to take it all the way to assembly. Any help on this would be much appreciated. Thanks, Bill Cotter72557,306 #: 5948 S3/Languages 09-Aug-90 06:19:51 Sb: #Password functions Fm: Mark Griffith 76070,41 To: Carl Kreider, 71076,76 (X) Carl, There seems to be a problem with the password functions. In the example below, the second call to get the name returns NULL in all cases. If you swap the functions, then same thing happens, i.e., the second call always returns a NULL even if the name or uid exists. Apparently something is not getting reset in endpwent() ??? Any ideas? if (getpwuid(atoi(pw[ID]))) { fprintf (stderr, "\nUID %s is already used\n", pw[ID]); endpwent(); exit(0); } endpwent(); /* close password in case getpwuid fails */ if (getpwnam(pw[NAME])) { fprintf (stderr, "\nUser %s already exists\n", pw[NAME]); endpwent(); exit(0); } endpwent(); /* close password in case getpwnam fails */ Mark There is 1 Reply. #: 5950 S3/Languages 09-Aug-90 09:10:12 Sb: #5948-Password functions Fm: Carl Kreider 71076,76 To: Mark Griffith 76070,41 (X) I will look at this off line and get back. - Carl #: 5985 S3/Languages 11-Aug-90 11:25:17 Sb: #5883-Mroff docs Fm: Ken Drexler 75126,3427 To: Mark Griffith 76070,41 (X) Mark, I will upload it into DL6 with a note that it includes your additions. This will leave you the option grabbing it and incorporating it into the revised archive. Your clibdoc.ar is a slick useful package of all the parts that are needed to document and print Carl's library. Unless you think it is too big, the mroff manual is a useful part of it. Ken #: 6045 S3/Languages 12-Aug-90 17:42:43 Sb: #5948-#Password functions Fm: Carl Kreider 71076,76 To: Mark Griffith 76070,41 (X) > Apparently something is not getting reset in endpwent() ??? That is exactly the problem. Do you want the patch, fixed source, or a fixed library? I think Pete added some stuff and put it up here after my last release. I don't find any sources for that and my memory is really rusty on it, but I didn't want to drop a new library up here without being sure. Carl There are 2 Replies. #: 6068 S3/Languages 12-Aug-90 22:05:01 Sb: #6045-#Password functions Fm: Mark Griffith 76070,41 To: Carl Kreider 71076,76 Carl, Sheeesh, I dunno. I'm not sure what Pete did with the sources. I volunteered to keep them. I guess the best thing to do is get Pete in on this and see where we stand. Pete???? One thought, can you make an Ipatch file and upload that? This way everyone will be able to get the patch with minimal effort. Mark There is 1 Reply. #: 6094 S3/Languages 13-Aug-90 12:16:46 Sb: #6068-Password functions Fm: Pete Lyall 76703,4230 To: Mark Griffith 76070,41 (X) Mark/Carl - I have backups of the sources (which I cannot read until the MM/1 arrives), and I have Carl's original disks as well. I think the concept of patch files for the library may be best. Pete #: 6085 S3/Languages 13-Aug-90 04:34:40 Sb: #6045-Password functions Fm: Ed Gresick 76576,3312 To: Carl Kreider 71076,76 Hi Carl! I don't know the history, but I'd suggest a new library (maybe patches for those whoe don't want to download a new file). Just my $.02. Ed #: 6106 S3/Languages 13-Aug-90 21:14:11 Sb: #F$CpyMem Question Fm: Zack Sessions 76407,1524 To: ALL I'm trying to use an F$CpyMem _os9() call in C. Only problem is, how do I load Reg D from a char pointer when all I have is rg_a and rg_b to work with? Zack There are 2 Replies. #: 6108 S3/Languages 13-Aug-90 21:31:09 Sb: #6106-F$CpyMem Question Fm: James Jones 76257,562 To: Zack Sessions 76407,1524 Depends on how they're laid out in memory--though actually, that's only true if you do something rather sleazy. The non-sleazy way is to recall that A is the most significant byte of D, B the least significant (do me a favor and don't tell Ms. Methvin that I didn't say "more significant" and "less significant" even though only two things were being compared, OK? ), so if you cast your char * to an int, do something like regs.rg_a = ((int) cp) >> 8; regs.rg_b = ((int) cp) & 0xff; to get what you're after. #: 6109 S3/Languages 13-Aug-90 22:29:21 Sb: #6106-F$CpyMem Question Fm: Pete Lyall 76703,4230 To: Zack Sessions 76407,1524 Zack - Not sure I understand the question, but what about: rg_d = rg_a << 8 | rg_b; Pete #: 6113 S3/Languages 13-Aug-90 23:58:48 Sb: #_gs_opt Fm: Dan Charrois 70721,1506 To: all I seem to have a peculiar problem. Maybe those knowing a bit about C, or perhaps the more inner workings of OS9 may be able to help me out. If I have the following code: #include main() { struct sgbuf *p,*q; _gs_opt(0,&p); _ss_opt(0,&p); chain("Shell",strlen("\n"),"\n",1,1,0); } and then compile it and execute redirecting to another window, I get a shell in the window that dies when I send it an eof - no problems here. But if I put: _gs_opt(0,&q); directly after the _gs_opt(0,&p) line (i.e. execute _gs_opt twice), I get a shell in another window, but I can't type anything in it. It's not just that I lost an echo - nothing works, and I have a window with a stuck shell - I can't kill the window because the shell keeps waiting for a signal or something - I'm not sure... Anyway, shouldn't the two code fragments give me the same result? What difference does it make if I call _gs_opt twice? Any help would be greatly appreciated...Dan P.S. Oh yes - in the second case, before I get the shell prompt (I'm using shell+), I get a few seemingly random foreign language characters... I'm really stuck on this one.. Thanks again There are 3 Replies. #: 6115 S3/Languages 14-Aug-90 02:56:06 Sb: #6113-_gs_opt Fm: Kevin Darling (UG Pres) 76703,4227 To: Dan Charrois 70721,1506 (X) I'm no C programmer, but it looks to me like: 1. No storage is allocated for the option buffer. 2. By using "&" you're pointing to a pointer, not the buffers (if you had them). #: 6116 S3/Languages 14-Aug-90 03:06:24 Sb: #6113-#_gs_opt Fm: Kevin Darling (UG Pres) 76703,4227 To: Dan Charrois 70721,1506 (X) I'm out of practice in C. Here ya go. Try this: #include main() { struct sgbuf p,q; _gs_opt(0,&p); _gs_opt(0,&q); _ss_opt(0,&p); chain("Shell",strlen("\n"),"\n",1,1,0); } Now storage is allocated temporarily for the option buffers, and you're sending their addresses to the get/set functions (which I think should be correct). The pros will tell us for sure ;-). There are 2 Replies. #: 6121 S3/Languages 14-Aug-90 13:36:36 Sb: #6116-_gs_opt Fm: Dan Charrois 70721,1506 To: Kevin Darling (UG Pres) 76703,4227 (X) Thanks for your suggested fix to my problem. I'll try it out right away and see if it works. Dan #: 6123 S3/Languages 14-Aug-90 15:12:29 Sb: #6116-#_gs_opt Fm: Pete Lyall 76703,4230 To: Kevin Darling (UG Pres) 76703,4227 (X) Kev - Your approach was fine... Pete There is 1 Reply. #: 6129 S3/Languages 14-Aug-90 17:39:16 Sb: #6123-_gs_opt Fm: Kevin Darling (UG Pres) 76703,4227 To: Pete Lyall 76703,4230 (X) Whew. Good. Thanks for the confirmation! #: 6122 S3/Languages 14-Aug-90 15:11:33 Sb: #6113-#_gs_opt Fm: Pete Lyall 76703,4230 To: Dan Charrois 70721,1506 (X) For starters, you DO have pointers, but they don't point to anything... more likely, they point to something they're not supposed to. Simply declaring the line: struct sgbuf *p, *q; sets aside two variables that can HOLD a pointer to a structure of type 'sgbuf'. You never: a) Created a storage area that the data would be stuffed into b) Initialized either of these pointers to point to an area like the one described in a) above. Try: #include char buf1[32], buf2[32]; main() { struct sgbuf *p = buf1, *q = buf2; ... etc. ... } It would have been more proper to allocate buf1 & buf2 as: struct sgbuf buf1, buf2; Pete There is 1 Reply. #: 6133 S3/Languages 14-Aug-90 20:05:40 Sb: #6122-_gs_opt Fm: Dan Charrois 70721,1506 To: Pete Lyall 76703,4230 (X) Thanks for your reply, Pete. I can't believe I made such a mistake in dealing with the pointers. What you and Kev said made a lot of senseactually, it is probably similar to advice I would have given if someone asked me the same question. It's amazing how one overlooks things from time to time. The code fragment I posted was what I had hoped the core of a bug I've found in my program. Evidently, this wasn't the bug, but rather I introduced the bug in the fragment. So, I guess I'm still going to have to debug some more. Thanks a lot for your help. (And, just for the record, I think struct sgbuf buf1,buf2 makes more sense than the other method you mentioned. Glad to hear that that is the proper way! :-) Dan #: 6124 S3/Languages 14-Aug-90 16:37:33 Sb: #6108-F$CpyMem Question Fm: Zack Sessions 76407,1524 To: James Jones 76257,562 (X) Thanks, JJ. SInce posting that question, Mark G. sent me a copy of a program which illustrates that you can define your own register structure and replace the rg_a and rg_b char definitions with a rg_d int declaration. Works like a charm! Zack #: 6128 S3/Languages 14-Aug-90 17:24:34 Sb: #5810-APL INTERPRETER for FREE Fm: Paul K. Ward 73477,2004 To: Greg Morse 72746,3451 Greg, Wow, you're back around these parts! Maybe I've been Rumplestitskin myself, but where the heck have you been? Welcome back! Paul 202 232 4246 #: 6213 S3/Languages 19-Aug-90 23:45:08 Sb: #popen() & pclose() Fm: Dan Charrois 70721,1506 To: all I have another question for all the C programmers out there. In examining source code that someone else had written, I came across their using the popen and pclose calls. From context, it appears as though they deal with pipes, and interestingly enough, the calls only work if compiled using the transcendental library. Unfortunately, I haven't been able to find any documentation - not in the Kreider docs (new version or old version), the Microware manual, or my other C reference book. I know these calls must be documented somewhere out there, or my friend wouldn't have used them. Have I missed them in the Kreider docs or something? Any help would be greatly appreciated...Dan There is 1 Reply. #: 6223 S3/Languages 20-Aug-90 09:17:00 Sb: #6213-#popen() & pclose() Fm: Pete Lyall 76703,4230 To: Dan Charrois 70721,1506 (X) Dan - These calls are supported in the current release of the Kreider library. They are documented in Unix manuals (section 3.. C Functions). The docs were initially left out by mistake (from the Kreider libs). Mark Griffith can probably get you a copy of that page, or if he can't, bug me and I will. You can probably get a good bit of it from usage context. Basically, it's an fopen() call for pipes using the specified command at the other end of the pipe: FILE *woof; ... woof = popen("dir e", "r"); Will fork a dir e command, connect its output via pipe for your program to read, using the buffered stream 'woof'. Don't forget to use a pclose(woof) when you're done with it. Pete P.S. Conversely, you could write to it if properly setup: FILE *arf; ... arf = popen("qsort", "w") while(not(done)) fprintf(woof,"%s", word[count++]); Pete There are 2 Replies. #: 6240 S3/Languages 20-Aug-90 22:51:35 Sb: #6223-#popen() & pclose() Fm: Mark Griffith 76070,41 To: Pete Lyall 76703,4230 (X) Pete, I made up a new set of docs that I'll be uploading soon that includes popen() and pclose() -- also fixes some errors I made in the last ones. Never ending job this (grin). Mark There is 1 Reply. #: 6242 S3/Languages 21-Aug-90 00:13:32 Sb: #6240-popen() & pclose() Fm: Dan Charrois 70721,1506 To: Mark Griffith 76070,41 Whoops - guess I should read the whole thread before replying. I won't bother bugging you for the docs then, if you're working on a new set including popen() and pclose(). Thanks...Dan #: 6241 S3/Languages 21-Aug-90 00:12:16 Sb: #6223-popen() & pclose() Fm: Dan Charrois 70721,1506 To: Pete Lyall 76703,4230 (X) Thanks a lot for your reply, Pete. That does clear things up immensely. I believe your short description filled in the gaps in my understanding on how to properly implement popen() and pclose(). I'm still going to bug Mark though and see if he has a copy of the formal documentation. Once again, thanks a lot for your assistance...Dan #: 6236 S3/Languages 20-Aug-90 22:16:14 Sb: #dl3 Fm: Carl Kreider 71076,76 To: sysop (X) clibt.l under PNN 76703,4230 in dl3 is obsolete and could probably be removed to prevent confusion. There is 1 Reply. #: 6246 S3/Languages 21-Aug-90 05:12:32 Sb: #6236-dl3 Fm: Mike Ward 76703,2013 To: Carl Kreider 71076,76 Thanks Carl, I'll do dat! #: 6237 S3/Languages 20-Aug-90 22:18:55 Sb: #clibs Fm: Carl Kreider 71076,76 To: Mark Griffith 76070,41 (X) Ok Mark. I have uploaded to DL3 two ipc files for clib[t].l that fix the problem with endpwent. I will upload full versions of the libs in a couple days so new folks won't have to get a lib and patch file. There is 1 Reply. #: 6238 S3/Languages 20-Aug-90 22:51:20 Sb: #6237-clibs Fm: Mark Griffith 76070,41 To: Carl Kreider 71076,76 Carl, Thanks Sir! BTW - did I do the docs wrong or is fopen(file,"a+") supposed to create the file if it does not exist? It seems not to do that, but fopen(file, "a") works just fine. Also, no error is returned. Strange. P.S. Sorry to make you work (grin) Mark #: 6258 S3/Languages 21-Aug-90 21:16:55 Sb: #6238-clibs Fm: Carl Kreider 71076,76 To: Mark Griffith 76070,41 (X) Oh my. I will look at it (fopen). I don't remember off the top. #: 6285 S3/Languages 23-Aug-90 17:36:09 Sb: #6237-clibs Fm: Carl Kreider 71076,76 To: Carl Kreider 71076,76 (X) Mark, I don't know what to say about fopen not working. Since the code looked correct, I threw together the following test. ---------------------8<----------------- #include main() { FILE *fp; fp = fopen("test", "a+"); printf("fp = $%04X errno = %d\n", fp, errno); } ---------------------8<---------------- The output was: fp = $0033 errno = 216 which seems correct to me. What now? Carl #: 6722 S3/Languages 16-Sep-90 01:31:10 Sb: #C Libraries Fm: Greg Morse 72746,3451 To: all Is there a way to maintain or build from scratch a library for C? That is assuming I have a .r module (compiled and rma'ed but not linked) can I "append" it or otherwise insert it into clib.l? if not into clib.l can I build a library gmlib.l by simply concatenating a bunch of .r modules together? or do i need a "librarian" program to do all that? tnx - greg morse There are 4 Replies. #: 6725 S3/Languages 16-Sep-90 06:20:23 Sb: #6722-#C Libraries Fm: Kevin Darling (UG Pres) 76703,4227 To: Greg Morse 72746,3451 (X) Greg - as far as I know, you can just append the .r file onto a .l, or even just rename it with ".l" on the end. I do it a lot under OSK. There may be a restriction on sequence of forward/backward references tho... not sure... I'll bet we'll find out in the next answer . There is 1 Reply. #: 6741 S3/Languages 16-Sep-90 23:39:25 Sb: #6725-#C Libraries Fm: Greg Morse 72746,3451 To: Kevin Darling (UG Pres) 76703,4227 (X) Then ho does the search take place? there is no table of contents? how primitive! On another note I have been studying your RAMMER code. Why is it necessary to disable interrupts when doing the mapblock and the byte moves? There are 2 Replies. #: 6752 S3/Languages 17-Sep-90 13:42:45 Sb: #6741-#C Libraries Fm: Kevin Darling (UG Pres) 76703,4227 To: Greg Morse 72746,3451 (X) Greg - Dunno about your OS9, but the Developer's Pak for the CoCo came with an "rdump" util... it shows the table of names/values used in linkable files. I think Carl K is the resident expert on this stuff (well, and JJ of course). I'm a novice at it. Rammer: pretty sleazy piece of code, actually . Correct approach of course is to map in blocks legally. But I was after speed etc, and I see drivers as being able to legally do anything they want (as long as they don't futz up other drivers). Why shut off interrupts? Two main reasons. 1. CoCo interrupts can cause an entire map change due to the need to move to the second 64K system map, where the gfx cursors code is. On return, the original system map is replaced, not the one Rammer may have rammed into the GIME. 2. More importantly, any interrupt requires that the system map be genuine, as OS9 doesn't reset the DAT (at least, on DATs with more than one map available) when it goes into system mode. So the DAT info could be quite bad and the system would crash and burn. In other words, OS9 wouldn't know that someone had diddled with the system DAT info... and it sure wouldn't know how to reset it after an interrupt. Does that make sense? You could insert a good block entry into the system DATImage, and then you'd be legal, but the trouble there was that if the system map is full up, a ramdisk like this couldn't work. - kev There is 1 Reply. #: 6799 S3/Languages 19-Sep-90 23:01:28 Sb: #6752-#C Libraries Fm: Greg Morse 72746,3451 To: Kevin Darling (UG Pres) 76703,4227 (X) Kev - I am looking at a version of RAMMER modified by ?? (name escapes me at momment). Claims yo have made some minor mods. In any case THIS version does an OS9 F$MapBlk which should result in legal dat image. I too wondered about any blocks being free, but it seems to me that OS9 MUST keep at least one DAT slot free as a "scratch" if only to map different I/O pages etc. But I dont know for sure, and maybe in a 4K system it can afford too, but in 8K not. Anyway I figured if RAMMER works with a F$MapBlk then any other I/O modulre should also. In case you are wondering I am looking at rewritting Pipeman Imagine an I/O device using F$LDABX to trnasfer 1 byte at a time. That's 37 cycles per byte minimum, plus the overhead of the SWI2 call! Anyway I figured it was time I tackled a Manager and pipeman is the easiest one to do. Do you still see it necessary to disable interrupts in this case? There is 1 Reply. #: 6800 S3/Languages 19-Sep-90 23:19:30 Sb: #6799-C Libraries Fm: Kevin Darling (UG Pres) 76703,4227 To: Greg Morse 72746,3451 Greg - this is offhand, but... No, I cheated badly and didn't use F$MapBlk at all, so someone did some extensive changes in the version you have. In any case, ummmm, OS9 doesn't keep any blocks in the system map free. So if the MapBlk could fail if things are hot and heavy (less so in your 4K system of course). The kernel's F$LDABX etc commands are hardcoded to directly map in the desired external block at logical $0000 in the system map... for speed, and because OS9 always knows that block 00 is located there. That is, it can always zap the DAT to grab/write a byte, and reset that first DAT block to 00 with impunity. Of course, it shuts off interrupts before doing so . Thus a driver which does the same thing is cool, just not useable on other hardware (just as the kernel isn't). Sounds like fun (messing with Pipeman)... good idea, too, as Pipes are rather slow, as you said. Yell if you need anything! best - kev #: 6754 S3/Languages 17-Sep-90 14:42:41 Sb: #6741-#C Libraries Fm: Pete Lyall 76703,4230 To: Greg Morse 72746,3451 (X) Greg - I forgot about that... the library must be ordered so that all dependencies are successive... that is, if an earlier module makes reference to a symbol '_blerf', then '_blerf' must be defined in a downstream module in the library, I believe. Ther are a few tools for ordering libraries.... see 'lorder'. Also - toggle JJ on this. I believe there's another tool as well. Pete There is 1 Reply. #: 6765 S3/Languages 17-Sep-90 20:45:08 Sb: #6754-C Libraries Fm: James Jones 76257,562 To: Pete Lyall 76703,4230 (X) Yup--lorder output is intended to go into a topological sort program, because in a proper library, that dependency induces a partial ordering, and the .r files have to be in a linearization of said partial order. #: 6727 S3/Languages 16-Sep-90 07:05:43 Sb: #6722-C Libraries Fm: James Jones 76257,562 To: Greg Morse 72746,3451 (X) You can concatenate the .r files together, but they have to be in a particular order if there are references in one .r file to symbols defined in another. I really need to modify the lorder program I uploaded here to handle either .r format (the pre-COMMON and post-COMMON flavors). #: 6743 S3/Languages 17-Sep-90 02:46:58 Sb: #6722-#C Libraries Fm: Bob Taylor 73270,3124 To: Greg Morse 72746,3451 (X) Greg, If you are running OSK, there are two programs called merge and rdump, that will create a library. The best way is to create a file listing the .r modules one per line then typing the command: merge -z=libname.l;rdump -l libname.l;rdump -l main() { long curtime; /* current date time */ struct tm *t, tim; /* tim for sizeof */ pflinit(); /* enable long printing */ curtime = time( (long *) 0); printf("curtime: %ld, curtime/86,400: %ld\n",curtime,curtime/86400); t = localtime( curtime ); printf("tm_sec: %d, tm_min: %d, tm_hour: %d, tm_mday: %d, tm_mon: %d, tm_year: %d\n", t->tm_sec, t->tm_min, t->tm_hour, t->tm_mday, t->tm_mon, t->tm_year); _dump("tm:\n",t, sizeof(tim) ); } OUTPUT: curtime: 653435281, curtime/86,400: 7562 tm_sec: 15, tm_min: 28, tm_hour: 6, tm_mday: 6, tm_mon: 2, tm_year: 206 tm: 1 2 3 4 5 6 7 8 9 a b c d e f 0 123456789abcdef0 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ---------------0211: 00 0f 00 1c 00 06 00 06 00 02 00 ce 00 00 00 24 ...........N...$ 0221: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ Has anyone else had this problem? What am I doing wrong? (I also note that the heading on _dump is wrong and the function sends its output to stderr not stdout as the clib documents say.) Thanks for the help. There are 2 Replies. #: 6736 S3/Languages 16-Sep-90 20:52:38 Sb: #6731-#localtime problem Fm: James Jones 76257,562 To: Ken Drexler 75126,3427 (X) Alas, many Unix-inspired functions take pointers as arguments where one would expect to pass the values instead, and hand back a result by modifying some global variable. I bet localtime() is one such function, and that you get to hand it a pointer of some sort. Look at the docs closely. There is 1 Reply. #: 6772 S3/Languages 19-Sep-90 00:23:16 Sb: #6736-localtime problem Fm: Ken Drexler 75126,3427 To: James Jones 76257,562 (X) Thanks for the suggestion. I'll give them a hard look. Ken #: 6755 S3/Languages 17-Sep-90 14:46:27 Sb: #6731-#localtime problem Fm: Pete Lyall 76703,4230 To: Ken Drexler 75126,3427 (X) Hmm... looks like this may be an age old gotcha.... did you define time() as a function that returns a long? i.e. 'long time(); /* no C */' Pete P.S. Pardon the obligatory C humor... There is 1 Reply. #: 6773 S3/Languages 19-Sep-90 00:29:53 Sb: #6755-#localtime problem Fm: Ken Drexler 75126,3427 To: Pete Lyall 76703,4230 (X) I think so. utime.h includes that declaration so I figured that #including it provided the needed declaration. The output suggests that it does because curtime looks right i.e. 7562 days after 1970 is a day in 1990. Have you used localtime() to break down the value returned by time()? If so (and your code worked) what did it look like? Thanks for the help Ken There is 1 Reply. #: 6779 S3/Languages 19-Sep-90 12:06:33 Sb: #6773-#localtime problem Fm: Pete Lyall 76703,4230 To: Ken Drexler 75126,3427 (X) Ken - Yep - I have used localtime() a lot.... works ducky. One thing that used to screw folks up (me too) was that most of the time related functions called for pointers to the long value. Have a gander at that. Also - let's see you're code segment again (pls)... Pete There are 2 Replies. #: 6831 S3/Languages 21-Sep-90 01:05:34 Sb: #6779-localtime problem Fm: Ken Drexler 75126,3427 To: Pete Lyall 76703,4230 (X) Pete, Thanks for the suggestions. I'll give my code a hard look. Ken #: 6833 S3/Languages 21-Sep-90 01:28:28 Sb: #6779-#localtime problem Fm: Ken Drexler 75126,3427 To: Pete Lyall 76703,4230 (X) Pete, Your guess on my error was right on the money. I changed the argument to localtime to a long pointer and the code worked fine. Funny how those asterisks sneak past me. Thanks for the help. Ken There is 1 Reply. #: 6844 S3/Languages 21-Sep-90 15:35:46 Sb: #6833-localtime problem Fm: Pete Lyall 76703,4230 To: Ken Drexler 75126,3427 Ken - Ahhh... good. Happy to help. Pete #: 7004 S3/Languages 26-Sep-90 18:11:52 Sb: #apl Fm: Tom Napolitano 70215,1130 To: all For those of you who wish to try out apl, recently converted and uploaded by Greg Morse, I uploaded a font and startup file for use with the coco3. Thanks, Greg; and thanks to Mike Haaland for the mvcanvas system that helped out also. Missing are the characters for compression and expansion functions, missing from my apl textbook. Can someone help out here? Thanks, tom n There is 1 Reply. #: 7029 S3/Languages 27-Sep-90 17:45:46 Sb: #7004-#apl Fm: Paul Rinear 73757,1413 To: Tom Napolitano 70215,1130 (X) Where is Greg's APL available ? Sounds interesting. Paul There is 1 Reply. #: 7090 S3/Languages 01-Oct-90 06:42:01 Sb: #7029-#apl Fm: Tom Napolitano 70215,1130 To: Paul Rinear 73757,1413 (X) Paul, Its in DL3, Languages. One file is the docs and executable, and the other is source code, in assembly. tom n There is 1 Reply. #: 7099 S3/Languages 01-Oct-90 17:01:00 Sb: #7090-#apl Fm: Paul Rinear 73757,1413 To: Tom Napolitano 70215,1130 (X) Thanks, I found IAPL and started playing around with it. Very different, not that I understand it. Paul There is 1 Reply. #: 7198 S3/Languages 05-Oct-90 06:37:38 Sb: #7099-#apl Fm: Tom Napolitano 70215,1130 To: Paul Rinear 73757,1413 (X) It takes a while to get used to apl. A text book is essential, then try out some of the exercises you see there. tom n There is 1 Reply. #: 7212 S3/Languages 05-Oct-90 21:21:37 Sb: #7198-#apl Fm: Paul Rinear 73757,1413 To: Tom Napolitano 70215,1130 (X) If I were to buy one textbook for starts, what would you recommend? Paul There is 1 Reply. #: 7247 S3/Languages 08-Oct-90 10:16:18 Sb: #7212-#apl Fm: Tom Napolitano 70215,1130 To: Paul Rinear 73757,1413 (X) Paul, I couldn't recommend the one text I have. It's old, and as I just recently discovered, is quite incomplete. See if Greg Morse has any current texts. Sorry for the negative response, but I don't want to do you a diservice. tom n There is 1 Reply. #: 7260 S3/Languages 09-Oct-90 17:25:47 Sb: #7247-apl Fm: Paul Rinear 73757,1413 To: Tom Napolitano 70215,1130 (X) A negative response is still a response, thanks. #: 7049 S3/Languages 28-Sep-90 23:27:55 Sb: #APL FONT FOR COCO Fm: Greg Morse 72746,3451 To: TOM, 70215,1130 (X) Tom - You are first again. I recall years ago you were one of the first if not the first people to use XCOM9, now you are the first that I know of to do anything with the IAPL!. I would like to enclose your fonts on the disk I send to the international society in the UK. Is that ok? also where are these files? also did you need to modify the source? if not how did you handle underlined characters? In answer to your question I thought that table 4.1 in the docs gav all the char mappings. You might also check the vt220.txt file in dl6 to see if that answers the question. else i will get back to you There is 1 Reply. #: 7091 S3/Languages 01-Oct-90 06:48:52 Sb: #7049-#APL FONT FOR COCO Fm: Tom Napolitano 70215,1130 To: Greg Morse 72746,3451 (X) Hi Greg, Sure, enclose the fonts in your distribution. There was no need to change the source to iapl; I mapped the lower case coco3 font, as well as the other characters such as # to their apl versions. I did nothing with the underline; Should I have? I'll have to use the system more to find out what's going on. The problem I had with compression and expansion was not Table 4.1, but what does the apl character look like. I'll check vt220.txt file to get that. Thanks. My old apl textbook made no mention of those two functions. Thanks, tom n There is 1 Reply. #: 7105 S3/Languages 01-Oct-90 22:09:52 Sb: #7091-#APL FONT FOR COCO Fm: Greg Morse 72746,3451 To: Tom Napolitano 70215,1130 (X) Tom - upon re-reading the vt220 font file does not refer to compression and expansion, but to slash} and slash bar etc. anyway previous info should have defined this for you. Yes there may be aproblem with the coco underlined chars. These chars are not needed by IAPL but they are nice to have for completeness. The vt220 unfortunately does not have 128 downloadable chars, only 94. therefore I had to map the apl char as in #AV to a vt220 version, so the hex value of say a quad internal to the pgm is not the same as the one sent to the vt220. That should not present a problem for cocos if your font just uses the vt220 char not the internal one. The problem comes in the underlined chars. since I didn't ha}ive room for 128 apl chars in a 94 char downloadable font, i omitted the undelined ones. when IAPL/os9 wishes to output an underlined char it outputs a "set underline mode" cmd string, then the normal char, then the "set normal mode" cmd string. This is not compatible with a coco i expect. The best thing would be for you to upload to me a defn of the font you have created similar to table 4.1 but giving the hex value you use, then I can incorporate the font into the pgm itself. (PS do you have the #AV vector map in your textbook?) If not I will upload to you by mail. Then we can do it right {_for the coco. There are 2 Replies. #: 7130 S3/Languages 02-Oct-90 17:48:54 Sb: #7105-#APL FONT FOR COCO Fm: Paul Rinear 73757,1413 To: Greg Morse 72746,3451 (X) The APL fonts look good; the only thing I found annoying was running the demos that came with IAPL with the fonts. The demos have lowercase letters in them that are meant to stay letters. How hard would it be to retain the ASCII lowercase codes and put the special APL characters on the coco ALT keys? Just curious. Paul There is 1 Reply. #: 7218 S3/Languages 05-Oct-90 23:31:12 Sb: #7130-APL FONT FOR COCO Fm: Greg Morse 72746,3451 To: Paul Rinear 73757,1413 (X) in the vt220 you can have both on output, since I expanded the vt220 char set by 94 chars (total=128+94). on input you have to hit the ^T (or the equivalent FK on the coco) to cause lower case letters to be treated as text rather than apl input. I dont know what the coco does. I thought that Tom said he used the coco lower csase font to map apl chars, in which case hitting ^T will get you one or the other but not both. Try it and let me know. please. #: 7199 S3/Languages 05-Oct-90 06:44:50 Sb: #7105-#APL FONT FOR COCO Fm: Tom Napolitano 70215,1130 To: Greg Morse 72746,3451 (X) Greg, let me digest your message. I'll show you my character set map later, but it is simply a mapping of table 4.1 to the coco fonts. By the way, your definition of the compression and expansion characters was sufficient for me to complete the table 4.1 to coco3 mapping. It seems by text was mid 70's vintage, based on apl/360 (!) and lacked two of the iapl functions. By playing around, it was easy to discern what the performed. I think the underlined mode is not completely necessary, but you're right; for complete ness it should be included. tom n There is 1 Reply. #: 7219 S3/Languages 05-Oct-90 23:33:51 Sb: #7199-#APL FONT FOR COCO Fm: Greg Morse 72746,3451 To: Tom Napolitano 70215,1130 (X) Tom - ok will wait for reply. BTW i have found a real dearth of apl books here. Judging from the IAPL newsletter I get the situation in england is MUCH better. I am not much of apl pgmer myself. and here I was with this obsolete textbook trying to test out my interpreter. yech! There is 1 Reply. #: 7248 S3/Languages 08-Oct-90 10:18:49 Sb: #7219-#APL FONT FOR COCO Fm: Tom Napolitano 70215,1130 To: Greg Morse 72746,3451 (X) Greg, According to the coco os9 manual, underlining is turned on by $1f22 and off by $1f23. Did you imply that all I have to do is change a constant string in iapl to make it coco compatible? tom n There is 1 Reply. #: 7340 S3/Languages 13-Oct-90 14:48:00 Sb: #7248-#APL FONT FOR COCO Fm: Greg Morse 72746,3451 To: Tom Napolitano 70215,1130 (X) If so then yes. I have the strings}i null terminated so you would make underline a 3 char string. look at offset $FD for the normal string ($9B,$30,$6D in vt220, and at offset $105 for $9B,$34,$6D for underline. There is 1 Reply. #: 7379 S3/Languages 15-Oct-90 09:31:59 Sb: #7340-#APL FONT FOR COCO Fm: Tom Napolitano 70215,1130 To: Greg Morse 72746,3451 (X) Greg, That should be easy enough, (to make iapl underlining work with the coco3). Thanks. It looks like I couldn't reassemble the package anyhow because I don't have a macro-assembler. Manually expanding is out of the question. I did that once, and am convinced I never want to again. tom n There is 1 Reply. #: 7390 S3/Languages 15-Oct-90 21:08:15 Sb: #7379-#APL FONT FOR COCO Fm: Greg Morse 72746,3451 To: Tom Napolitano 70215,1130 (X) OK TOM. Maube the easiest thing is for me to re-assemble it. thats $1f22 for und line ON and $1f23 for OFF? There is 1 Reply. #: 7417 S3/Languages 16-Oct-90 12:09:19 Sb: #7390-#APL FONT FOR COCO Fm: Tom Napolitano 70215,1130 To: Greg Morse 72746,3451 (X) Greg, NO, no, nein, non, tidak! Lets not have two of that monster floating around! I think I can just put together a debug patch file, or ipatch to customize it for cocoists. Much cheaper in terms of storage. Thanks anyway. Whatever I put together will be shared with the community of course. tom n There is 1 Reply. #: 7441 S3/Languages 16-Oct-90 20:16:16 Sb: #7417-APL FONT FOR COCO Fm: Greg Morse 72746,3451 To: Tom Napolitano 70215,1130 (X) "Tidak"? OK i could probably put a single "machine type" byte in the pgm and execute slightly different code, but having a patch file is probably even easier. BTW where do they keep "modpatch" on this sig? I have tried a "dir mod*.*" on most dl's with no luck. only modpat.txt in the coco dl. #: 7059 S3/Languages 29-Sep-90 22:41:53 Sb: #c_problem Fm: ANDY THIBODEAU 76636,2300 To: all Hey,anyone been having any problems with the getime call in C lately? I have.Does anyone know how to get seconds from it? I'm trying to write a random number generator and all I get is 0. can anyone help me? just wondering, ANDY T. There are 2 Replies. #: 7063 S3/Languages 29-Sep-90 23:29:53 Sb: #7059-#c_problem Fm: Zack Sessions 76407,1524 To: ANDY THIBODEAU 76636,2300 (X) getime() works fine for me. Seconds are in the t_second field as defined in the sgtbuf in time.h. I'm wondering. Why write a random number generator when we already have one inthe Krieder lib? Zack There is 1 Reply. #: 7074 S3/Languages 30-Sep-90 17:41:02 Sb: #7063-#c_problem Fm: ANDY THIBODEAU 76636,2300 To: Zack Sessions 76407,1524 (X) Krieder lib? you mean on cis? Well I guess I've got to look before I torture myself like that.thanks Zack! ANDY T. There is 1 Reply. #: 7075 S3/Languages 30-Sep-90 17:44:55 Sb: #7074-#c_problem Fm: Zack Sessions 76407,1524 To: ANDY THIBODEAU 76636,2300 (X) Check the Utilities lib (I think) for a file called clib.ar. Carl Krieder wrote a replacement library for the C Compiler which includes several functions which should have been in the original. Zack There is 1 Reply. #: 7080 S3/Languages 30-Sep-90 19:14:03 Sb: #7075-#c_problem Fm: ANDY THIBODEAU 76636,2300 To: Zack Sessions 76407,1524 (X) ZACK, Me again,what parameters do I call it with? HELP! ANDY T. There is 1 Reply. #: 7087 S3/Languages 30-Sep-90 21:53:12 Sb: #7080-#c_problem Fm: Zack Sessions 76407,1524 To: ANDY THIBODEAU 76636,2300 (X) You're talking about the rand.c file, right? I don't know, I haven't looked at it. As I mentioned in a previous message, what you found is not what I was talking about. Apparently what you found is a program (maybe?) which generates random numbers? Does it have a main() function or a rand() function? There is 1 Reply. #: 7115 S3/Languages 02-Oct-90 00:43:09 Sb: #7087-#c_problem Fm: ANDY THIBODEAU 76636,2300 To: Zack Sessions 76407,1524 (X) oh,it's rand() all right, is there any way i can get that clib file with CTERM? There is 1 Reply. #: 7126 S3/Languages 02-Oct-90 16:12:22 Sb: #7115-#c_problem Fm: Zack Sessions 76407,1524 To: ANDY THIBODEAU 76636,2300 (X) I am unfamiliar with CTERM. I assume this is the program you mentioned which supports only ASCII downloads. If so, then you can't download clib.ar. There is 1 Reply. #: 7160 S3/Languages 03-Oct-90 17:55:41 Sb: #7126-#c_problem Fm: ANDY THIBODEAU 76636,2300 To: Zack Sessions 76407,1524 (X) well, if you are unfamilliar with CTERM look it up in library 7:telecom after you look at it tell me if you suggest any freeware that i can download that does any better. ANDY There is 1 Reply. #: 7171 S3/Languages 03-Oct-90 22:17:11 Sb: #7160-#c_problem Fm: Zack Sessions 76407,1524 To: ANDY THIBODEAU 76636,2300 (X) I already have at least 5 different OS9 based term programs and really don't have any reason (or time, sorry) to look at any others. Do you have an RS232 interface? If so I would suggest OSTerm. If it's not in the libs, I'll be happy to upload it. Zack There is 1 Reply. #: 7181 S3/Languages 04-Oct-90 19:24:33 Sb: #7171-#c_problem Fm: ANDY THIBODEAU 76636,2300 To: Zack Sessions 76407,1524 (X) ZACK, yes I run off of a RS-rs232 program pack,osterm?don't think I've seen that one here (the limited time i've been here). If i need to get it from you do you garantee there's no VIRUS in it (grin). There is 1 Reply. #: 7184 S3/Languages 04-Oct-90 21:12:23 Sb: #7181-#c_problem Fm: James Jones 76257,562 To: ANDY THIBODEAU 76636,2300 (X) Well, let's put it this way--the author of OSTerm has done various other worthwhile utilities for OS-9/6809 (and I hope he will do some OS-9/68K stuff, too), and they all seem to work well. I think I'd trust him. (In fact, I do--at least once a day, when I use OSTerm.) There is 1 Reply. #: 7208 S3/Languages 05-Oct-90 17:51:27 Sb: #7184-#c_problem Fm: ANDY THIBODEAU 76636,2300 To: James Jones 76257,562 (X) o.k. so if I need it (yes),and if it isn't here (if it is its hiding) might i suggest the person that uploads it uploads a NON-ar version? extreamly curious, ANDY T. There is 1 Reply. #: 7240 S3/Languages 07-Oct-90 21:53:58 Sb: #7208-c_problem Fm: James Jones 76257,562 To: ANDY THIBODEAU 76636,2300 (X) You could suggest that, but I would guess that you wouldn't get far with that suggestion. As the long-ago poster of a package that required about half a dozen or so files, I know first-hand that folks don't much appreciate the hassle of having to download that much stuff, especially when it can be logically grouped together as need be. (For that matter, one could create and feed to AR a tar file, which would let one preserve directory structure in the stuff to be uncrated.) You'll be much better off downloading the AR utility. #: 7097 S3/Languages 01-Oct-90 16:04:30 Sb: #7059-#c_problem Fm: Pete Lyall 76703,4230 To: ANDY THIBODEAU 76636,2300 (X) Andy - Show us your code segment, and we'll be able to provide more specific help. Pete There is 1 Reply. #: 7116 S3/Languages 02-Oct-90 00:55:06 Sb: #7097-#c_problem Fm: ANDY THIBODEAU 76636,2300 To: Pete Lyall 76703,4230 (X) Well Pete, I already foolishly erased the part I was having problems with,but,I think I have a copy somewhere,hmmm,no I guess not,well, it went something like- struct sgtbuf *buffer; main() { int ti; getime(buffer); ti ti=atoi(buffer.t_second); printf(" %u",ti); } There are 2 Replies. #: 7127 S3/Languages 02-Oct-90 16:14:11 Sb: #7116-c_problem Fm: Zack Sessions 76407,1524 To: ANDY THIBODEAU 76636,2300 (X) You are declaring only a pointer to sgtbuf. You need to declare the structure itself and then pass it's address, ie, struct sgtbuf buffer; getime(&buffer); Zack #: 7131 S3/Languages 02-Oct-90 17:51:32 Sb: #7116-#c_problem Fm: Pete Lyall 76703,4230 To: ANDY THIBODEAU 76636,2300 (X) Andy - Couple of things poke me in the eye.... struct sgtbuf *buffer - declares a pointer to a structure of type sgtbuf... BUT... where is the storage for it? Also, how does the pointer get initialized to point to it. Perhaps you'd better try something like: struct sgtbuf buffer, *bp; bp = &buffer; Also - when using pointers to structures, you need to use the '->' connector vice the '.'. Example: buffer->t_sec (or whatever)... Pete There is 1 Reply. #: 7161 S3/Languages 03-Oct-90 18:07:41 Sb: #7131-#c_problem Fm: ANDY THIBODEAU 76636,2300 To: Pete Lyall 76703,4230 (X) (ahem),hey guys i don't know nut'n i just try to survive with what i'm told. the reason i did "buffer.t_second" was thats the way it was structured in the header file,and yes all i want out of getime is the seconds. geting REALLY confused, ANDY T p.s. anyone want to continue this conversation on delphi? I just got an account (thib). There is 1 Reply. #: 7168 S3/Languages 03-Oct-90 20:52:51 Sb: #7161-#c_problem Fm: Pete Lyall 76703,4230 To: ANDY THIBODEAU 76636,2300 (X) Andy - Point is this: If you're going to access stucture members using a pointer (which you were apparently trying to do), you must use the construct: structure_pointer->structure_element If you're wheeling directly off of the name of the structure: structure_name.structure_element. Pete P.S. A good text on C is the "C Primer Plus" by the Waite Group. Easy reading & informative, lots of examples, and a sense of humor as well. P.S.S. DELPHI? "Fightin' words" here (grin).. I help administrate this forum... There is 1 Reply. #: 7182 S3/Languages 04-Oct-90 19:36:26 Sb: #7168-#c_problem Fm: ANDY THIBODEAU 76636,2300 To: Pete Lyall 76703,4230 (X) Pete, huh?,english please. i don't think my compiler manual is wrong( ? ),it says to declare it as a pointer("struct sgtbuf *buffer").(p.3-35). I've got two books on C ,C programming guide 2nd Edition (QUE). to that last post script yes I said (shhh)delphi,you must admit 20 hours for 20 hours is the least expensive.(sorry,grin). There are 2 Replies. #: 7185 S3/Languages 04-Oct-90 21:23:22 Sb: #7182-#c_problem Fm: James Jones 76257,562 To: ANDY THIBODEAU 76636,2300 (X) OK--your compiler manual is *not* wrong. Neither is Pete. This isn't anything like "light is a wave *and* a particle" or even "Certs is a candy mint and a breath mint." Here's the deal: The typical compiler manual shows you what would be the first part of a formal declaration of the function (or what it would be if it were a function, since sometimes it's really a macro). What that shows you is the type of the actual parameter you should pass. Now, in your invocation of the function, you passed it a variable that indeed has the correct type, i.e. pointer to struct sgtbuf. However, the *value* that you passed is not correct, because it is not in fact the address of a struct sgtbuf. Analogy: you call (invoke :-) a sign painter, who comes to your house and asks where the sign to be painted is, i.e. he wants a pointer to the sign you want painted. What you did in your invocation is the moral equivalent of pointing into empty space, that is it was a response of the correct type (pointer to a sign) but with an invalid value (because there was in fact no sign where you pointed). What Pete suggests is analogous to the following: before you call the painter, you build an (unpainted) sign. (In C, you'd declare a struct sgtbuf, "struct sgtbuf buf;".) When you call the painter, and he asks you to point to the sign to be painted, point at the sign you built. (In C, pass getime() the address of the structure you declared: "getime(&buf);".) This is admittedly a dumb analogy, but it's the best I could do on shorot --er, short--notice, while the CIS $$$ meter is ticking. I hope it helps to show what's going on. There is 1 Reply. #: 7191 S3/Languages 04-Oct-90 23:40:10 Sb: #7185-c_problem Fm: Kevin Darling (UG Pres) 76703,4227 To: James Jones 76257,562 (X) That was _English_ ??? See you at the fest! #: 7202 S3/Languages 05-Oct-90 11:42:38 Sb: #7182-#c_problem Fm: Pete Lyall 76703,4230 To: ANDY THIBODEAU 76636,2300 (X) Andy - Not that it necessarily is, but NEVER assume a manual to be Gospel. Too many folks have wasted countless debugging hours on assumptions like that. As far as "English please" goes.... I gave you the way to solve your programming problem in normal C terms. If you find those vague, then you may want to pick up a text on C. I highly reccommend the "C Primer Plus" by the Waite group. As far as your problem goes, I'll make one more attempt. Gettime() requires a pointer to a structure. Just because you have a pointer, doesn't get you anything. You need something for it to POINT TO. In this case, you must either manually declare a structure to hold the time data, or if it's already available in a '.h' file (i.e. time.h), then make sure to include that file. If you want top reference the time data using the pointer, you must use the approach: pointer->data_element; If you want to access the time data using the name of the structure instead, you need to use: structname.data_element; Pete P.S. Please learn to accept help in a more gracious fashion, else you'll find people less than willing to take the time to help you with your problem. There is 1 Reply. #: 7207 S3/Languages 05-Oct-90 17:28:01 Sb: #7202-#c_problem Fm: ANDY THIBODEAU 76636,2300 To: Pete Lyall 76703,4230 (X) sorry guys, I really didn't mean to be rude,and i really appreciate any and all help I get(including all suggestions)but this one C problem has been about a year now and I don't seem to be getting any closer than I was before. as for the book,well,I might want to buy it if it explains pointers a little better than the one I have. p.s. I just got around to trying both suggestions I received and no go,if anyone would like to help me further I would still apreciate(and p.s.s (or psst) hey ,you ,wanna see a listing? There are 2 Replies. #: 7209 S3/Languages 05-Oct-90 18:03:26 Sb: #7207-c_problem Fm: ANDY THIBODEAU 76636,2300 To: ANDY THIBODEAU 76636,2300 (X) er,sorry again, that last part should read "(and welcome)" now that I've read all the help I'm getting around here in one sitting I think it's starting to sink in. but just to make sure I'm correct I'm right, I will leave and try it. thanks for being here, andy #: 7244 S3/Languages 08-Oct-90 09:18:00 Sb: #7207-c_problem Fm: Pete Lyall 76703,4230 To: ANDY THIBODEAU 76636,2300 (X) Andy - Happy to help... let's see the listing. Pete #: 7119 S3/Languages 02-Oct-90 01:37:51 Sb: #c_problem Fm: ANDY THIBODEAU 76636,2300 To: Zack Sessions 76407,1524 (X) does anyone have a program to change an .ar file? There is 1 Reply. #: 7128 S3/Languages 02-Oct-90 16:14:53 Sb: #7119-#c_problem Fm: Zack Sessions 76407,1524 To: ANDY THIBODEAU 76636,2300 (X) Change an ar file? Don't follow you. There is 1 Reply. #: 7162 S3/Languages 03-Oct-90 18:12:24 Sb: #7128-#c_problem Fm: ANDY THIBODEAU 76636,2300 To: Zack Sessions 76407,1524 (X) with that question i'm assuming that files with ".ar" have a protocall i wouldn't be able to use unless i had a program to convert it back. There is 1 Reply. #: 7172 S3/Languages 03-Oct-90 22:20:28 Sb: #7162-c_problem Fm: Zack Sessions 76407,1524 To: ANDY THIBODEAU 76636,2300 (X) Files with an ".ar" extension is an archive file archived with the ar utility, available for downloading in the Utils lib. It is pure binary format and therefore requires something like XModem of B+ protocol for downloading. Umm, that is the program ar.bin _and_ any .ar file are in binary format. Zack #: 7156 S3/Languages 03-Oct-90 16:01:57 Sb: #Need help with C Fm: MAS 76336,3226 To: * Can someone please give me hints on how to port the pipe() and fork() commands from Unix to from Unix to OS-9? Thanks! There are 3 Replies. #: 7158 S3/Languages 03-Oct-90 16:35:44 Sb: #7156-Need help with C Fm: Mark Wuest 74030,332 To: MAS 76336,3226 (X) Haven't done exactly that, but have opened a lot of /pipe's. It would look something like: pipe(fd) int *fd; { fd[0] = open("/pipe","w"); fd[1] = open("/pipe","r"); } Of course, that's not exactly it (I think in pipe() there is only one pipe actually created), but you get the idea. Mark #: 7159 S3/Languages 03-Oct-90 16:40:57 Sb: #7156-Need help with C Fm: Mark Wuest 74030,332 To: MAS 76336,3226 (X) Fork() is a different beastie, as os9 doesn't do your traditional unix fork() and exec() to spawn new processes. Since most of the time you fork() in unix you end up exec()ing the process you really wanted, you replace the fork() and exec() in the unix code with a single os9exec(). If you *really* want to spawn a child that takes up like the unix fork() does (ie: no exec()), you'll have to play some game at the beginning of the program to see if this is the child or the parent and branch (eek - goto in "c") to the appropriate spot. Good luck. Mark #: 7175 S3/Languages 04-Oct-90 02:20:40 Sb: #7156-#Need help with C Fm: Bob Taylor 73270,3124 To: MAS 76336,3226 (X) There is source for Unix popen() pclose() in unixlib.ar (I think) in DL12. The package is written for OSK and may not work for OS-9 LII. Bob There is 1 Reply. #: 7178 S3/Languages 04-Oct-90 11:17:54 Sb: #7175-#Need help with C Fm: Pete Lyall 76703,4230 To: Bob Taylor 73270,3124 (X) Bob - In the current version of the Kreider C Libraries (clib.l and clibt.l) for the 6809, there are working versions of popen() and pclose() for os9/6809'ers. They work just ducky. Compliments of one Simmy Turner. Pete There is 1 Reply. #: 7197 S3/Languages 05-Oct-90 03:59:25 Sb: #7178-Need help with C Fm: Bob Taylor 73270,3124 To: Pete Lyall 76703,4230 (X) Pete, Of course, the Kreider libs! Sorry, I should have thought first! :-) Bob #: 7224 S3/Languages 06-Oct-90 01:23:03 Sb: #real time languages Fm: Bob van der Poel 76510,2203 To: all I just got finished reading a most interesting book *Computer Languages* (by Naomi S. Baron). Some nice comparisons and interesting perspectives. But what has me somewhat confused is the comment that C is *not* a language for real time programming. "Dennis Ritchie makes it quite clear that C was not desinged to handle more than one operation at a time (that is, it was never intended to do multiprogramming, which is a necessary component of real-time programming). . . . there are no facilities for multiprogramming, parallel operations, synchronization, or process control." For this kind of stuff we have to use Ada or Modula-2. Hmmm, I wonder how real-time systems (like OS-9) manage to do anything at all in light of the above. Or is there more than one definition of "real-time"? /ex post There is 1 Reply. #: 7250 S3/Languages 08-Oct-90 13:11:31 Sb: #7224-#real time languages Fm: Pete Lyall 76703,4230 To: Bob van der Poel 76510,2203 (X) Multiple definitions of real-time, I'm afraid. When I was working weapons systems, real time meant that each submodule had a time budget, and overall system cycle time was crucial (for things like launcher order extrapolation, future target position estimation, and so on). If time overran it's set limit, a note was made and a time loan was established. This was effectively taken from segments that didn't use all of their allocated time. If a consistent offense was noted, that module was flagged and faulted out to the executive. Other people consider real time environments those that allow for dynamic inputs, and simultaneously produce resultant output. A pitch shifter (in a recording studio) is a good example.. a sound goes in, the processor performs transforms on it, and that same sound is emitted from the outputs (in its shifted form) almost at the same moment. Other folks take real time to mean "not batch" (or deferred) processing. Unfortunately, people think that "real time" is a sexy term, and will misuse it to make something sound slick. Bet that this is the most common case. I, for one, don't consider OS9 to be real time. It doesn't have finite periods during which it must accomplish things, nor does it have the mechanisms to enforce that kind of operation with its applications. Back to C, ADA, and multiple concurrent operation. Using C under OS9/Unix, the OPERATING system provides the facilities. Under ADA, tasking, rendevous, and the likes are features of the language. I think that's where the distinction lies. Pete There is 1 Reply. #: 7257 S3/Languages 09-Oct-90 09:45:20 Sb: #7250-#real time languages Fm: Mark Wuest 74030,332 To: Pete Lyall 76703,4230 (X) WHAT!? OS-9 not real time!? (Lucky for you none of their sales reps are on here ) Seriously, the thing that makes OS-9 (and VRTX, and PSOS, etc) real-time is the predictability of performance when it's needed. That is the very thing HP put into HP-UX to make a "real-time" version of Unix. If you always know exactly (within reason) how long a process or code segment is going to take, then it is real-time. OS-9 user-state processes don't qualify, as they are subject to scheduling (time-slicing) and interrupts. What we have done is to put timing-critical processes in system state and let them "share" by tsleep()ing if and when it knows it has nothing to do. Although one could argue that we aren't using OS-9 (or any OS) while we are in system state, (in fact, there are points where the system clock is masked) it is nice to have the kernel there to facilitate things such as fork()ing the process in the first place and providing a systematic interface to the outside world (i/o). Geez, I can't believe I jumped into a discussion about "real-time" . Mark There is 1 Reply. #: 7258 S3/Languages 09-Oct-90 12:47:07 Sb: #7257-real time languages Fm: Pete Lyall 76703,4230 To: Mark Wuest 74030,332 (X) Mark - I'd say you were on target... at that point, you've become a 'kernel extension', and aren't a typical OS9 app. Also, your tsleep() approach is clock dependant, and may not operate the same way on another architecture (i.e. in 6809/os9, ticks/slice was altered between SS-50 and coco type systems). I've already done a bit of dueling on the topic with Kim Kempf on USENET sometime ago. Basically (if I recall), he said something to the effect of "well, it all depends what you call real time...". Pete #: 7232 S3/Languages 06-Oct-90 23:17:56 Sb: #Os9 Pascal Eoln Function Fm: Steven Barlett 71635,1562 To: All Users I am Writing a program in OS9 Pascal and am having some troble Inputing With The Eoln Function..... After I Enter a string Varable into A Read Statement in a While loop and press the Charage Return The rest of the inputs That are set up to Be read are skipped as The Eoln Boolean is being set to True.... How Can I reset the Eoln Function back to False before The next varable read... Is it Possible... If not could anyone please make some suggestions... Your help would be appreciated. There is 1 Reply. #: 7233 S3/Languages 07-Oct-90 02:53:47 Sb: #7232-#Os9 Pascal Eoln Function Fm: Bob Taylor 73270,3124 To: Steven Barlett 71635,1562 (X) Steven, Its been about 8 years since I wrote any Pascal. I don't have OS9 Pascal. However, if my memory serves me correctly I think I had to do a rewind function call to reset the input file. You might try this and see what happens. I presume you have read the manual? Bob There is 1 Reply. #: 7234 S3/Languages 07-Oct-90 09:29:05 Sb: #7233-Os9 Pascal Eoln Function Fm: Steven Barlett 71635,1562 To: Bob Taylor 73270,3124 (X) Hi Mr Taylor I will give it a try and let you know if it worked out... thanks..... #: 7323 S3/Languages 13-Oct-90 05:26:15 Sb: #c_problem Fm: ANDY THIBODEAU 76636,2300 To: pete lyall hi pete, here is the new version of the same problem(C 'getime',remember?) #include #include main() struct sgtbuf buffer; int(ti); ti=0; { getime(&buffer); ti=atoi(buffer.t_second); printf(" "%u%u,ti); } it still gives me 0 when i run it! what am i doing wrong?(besides trying to swim with cement shoes!:-) There is 1 Reply. #: 7414 S3/Languages 16-Oct-90 11:48:54 Sb: #7323-c_problem Fm: Pete Lyall 76703,4230 To: ANDY THIBODEAU 76636,2300 Andy - Would have seen your message sooner had you included my PPN on it. Also, if trying to send a listing (or other formatted text) that you don't want CIS's editor to 'fix' for you, make sure that instead of just [s]aving it, you [s]ave [u]nformatted. A number of problems: 1. You are declaring variables after main() but before the 1st curly brace. The only thing that should be in here is those parameters that are going to be passed to main (like argv, argc, if used). You should either have declared them ABOVE main (making them global to all functions, or after the curly brace '{', making them locally known to the 'main()' procedure only. 2. You are performing an atoi() function on something that's not ASCII to begin with (atoi converts ASCII to its INTEGER equivalent). 3. Your printf() statement had no terminating quote, and contained an unusual formatting list (i.e. "u%u ... or something close). Try something along these lines: #include #include main(argc,argv) /* args optional here */ { int ti; /* a place to stuff 'minutes' */ struct sgtbug timejunk;/* a place to hold the time */ getime(&timejunk); /* tell the system to go get it */ ti = timejunk.t_minutes; /* go get a copy of the minutes */ printf("The number of minutes is: %d\n", ti); } NOTE: I'm just scratch typing at work, and haven't compiled this under os9. Also, you could omit the 'ti' stuff and just: printf("The number of minutes is: %d\n", timejunk.t_minutes); Pete #: 7330 S3/Languages 13-Oct-90 09:47:12 Sb: RE: c_problem Fm: Zack Sessions 76407,1524 To: 76636,2300 Andy, Try it this way. Look at the differences and if there is anything you don't understand, then ask more questions. Oh, to store a forum message unformatted enter a SU at the Post Action Menu Prompt. #include #include main() { struct sgtbuf buffer; getime(&buffer); printf("Seconds = %d",(int) buffer.t_second); } #: 7498 S3/Languages 17-Oct-90 23:12:16 Sb: #strftime() Fm: Bob van der Poel 76510,2203 To: all Does anyone know what the correct format for digit conversion in the function strftime() is? I've just ported a version of this to MW-6809, but I'm not completely happy with it. The version I snarfed has all the different values being displayed as 2 digits (eg. 01, 09, 31, etc.). I'm not sure that the leading '0' should appear on most of the options. My reference does not specify the number of digits to display (just that day of week is 0 to 6 and day of month is 1 to 31, etc.). Anyone got a better text than mine? Once I get this working properly I'll post it.... There is 1 Reply. #: 7519 S3/Languages 18-Oct-90 12:11:11 Sb: #7498-#strftime() Fm: Pete Lyall 76703,4230 To: Bob van der Poel 76510,2203 (X) Bob - I don't recognize that function.... Where did it come from? Pete There is 1 Reply. #: 7574 S3/Languages 19-Oct-90 21:23:57 Sb: #7519-#strftime() Fm: Bob van der Poel 76510,2203 To: Pete Lyall 76703,4230 (X) Pete, strftime() is an ANSI C function which converts time to a formatted stirng. Lots of options, similar to printf(), let you set the format just as you need. I got the docs from "C: The Complete Reference", Schil and "stole" the source from the Mix C complier for the IBM. Schildt's book does not talk about precision, the Mix C stuff left pads all the numbers with 0's. Does this help? There is 1 Reply. #: 7597 S3/Languages 20-Oct-90 09:53:00 Sb: #7574-strftime() Fm: Pete Lyall 76703,4230 To: Bob van der Poel 76510,2203 Bob - That explains my ignorance... I'm largely ANSI C ignorant (blush), except for function prototyping. Well, that 'fessed up, how can I help you make your code work? Pete #: 7608 S3/Languages 20-Oct-90 19:55:30 Sb: #RMA woes Fm: Richard Ries 76057,3534 To: All I am trying to write a subroutine for BASIC09 using the RMA. It simply causes the screen to "BEEP". Unfortunately, it dumps me out of BASIC09 into OS-9 when I am finished. Any help would be greatly appreciated! The Listing isI$Write equ $8A F$Exit equ $06 psect beep,$21,$81,0,0,start start: leax char,pc lda #1 ldy #1 OS9 I$Write clrb OS9 F$Exit * Using RTS has the same effect char: fcb $07 endsect Thanks, Rich There are 3 Replies. #: 7611 S3/Languages 20-Oct-90 20:06:44 Sb: #7608-RMA woes Fm: Pete Lyall 76703,4230 To: Richard Ries 76057,3534 Richard - F$EXIT would assuredly blow you back to os9... that's voluntary termination. How are you interfacing with the routine (i.e. what caling convention are you using)? There are some rules in the B09 (and C) manuals regarding interfacing to external modules... Pete #: 7621 S3/Languages 21-Oct-90 01:37:01 Sb: #7608-RMA woes Fm: Kevin Darling (UG Pres) 76703,4227 To: Richard Ries 76057,3534 Rich - basic09 subroutines are, well, subroutines... not programs. That's the key. Basic09/runb executes a subroutine like it was part of its own code. Therefore your F$Exit was actually run by basic09 and so basic09 exited. I know you said "rts" didn't work... dunno why. Worked here with the same program for me: psect beep,$21,$81,revs,0,0,entry I$Write equ $8A F$Exit equ $06 entry leax char,pc lda #1 ldy #1 os9 I$Write clrb rts char fcb $07 ends ******************* PROCEDURE Beeptest RUN beep END However, you'll need guidance on passing parameters when you get to that kind of thing... let me know. - kev #: 7624 S3/Languages 21-Oct-90 11:05:03 Sb: #7608-RMA woes Fm: Zack Sessions 76407,1524 To: Richard Ries 76057,3534 Why not just use RUN gfx2("BELL")? #: 7612 S3/Languages 20-Oct-90 22:14:35 Sb: Cross Compiler Fm: Greg Morse 72746,3451 To: 76703,4230 Pete - you remember Fred Fierling? He is looking for a cross compiler that would run under unix and produce code for a 68000 series chip suitable for embedded applications. I dont think the embedded applications will use OS9. could you leave me your UNIX email address (he now has a Usenet feed) or phone number or give him a call at (604) 879-8004. Tnx #: 7647 S3/Languages 22-Oct-90 08:04:54 Sb: #7612-#Cross Compiler Fm: Pete Lyall 76703,4230 To: Greg Morse 72746,3451 (X) Greg - Best address for me is: pete@wlbr.imsd.contel.com -or- pete%wlbr@wlv.imsd.contel.com Assuming that he has access to the Internet (BITNET/ARPANET/MILNET).. If not, I'll have to scounge up a UUCP address. Re: Greenhills... last time I was associated with it was around 5 years back, and I'm pretty out of date. I do painfully little code generation these days... mostly proposals (sigh). BTW, did you hear that Contel is being bought by GTE? Pete There is 1 Reply. #: 7733 S3/Languages 24-Oct-90 20:12:37 Sb: #7647-Cross Compiler Fm: Greg Morse 72746,3451 To: Pete Lyall 76703,4230 (X) Yes. As a loyal GTE employee I suppose I should bve glad. Still sprint was owned by GTE and it is the only long distance company to lose money. Wonder what the future holds for CONTEL? tnx #: 7651 S3/Languages 22-Oct-90 11:57:10 Sb: #7621-RMA woes Fm: Richard Ries 76057,3534 To: Kevin Darling (UG Pres) 76703,4227 (X) Thanks, Kev. Unfortunately, my Coco 3 blew up. Nothing dramatic, it just blanked out. I think it's the 6809. However, I can't find any decent software for my like of work (Embedded Systems Programmer), so I'm going to dump almost all the Coco stuff and concentrate on the MS-DOS stuff. Yeah, I know the OS stinks (to put it mildly), but that's where the apps are. The advanced BASICs (Quick BASIC & Turbo BASIC are almost as good as BASIC09, and there are a number of other languages for a couple bucks each. Of course, if I get a 386 machine, and the price comes down, I'll probably get OS/9000. I'll be around here for a while, then switch over mostly to the Software Engineering Group at the CLM forum. Thanks again, RIch #: 7652 S3/Languages 22-Oct-90 11:58:54 Sb: #7624-#RMA woes Fm: Richard Ries 76057,3534 To: Zack Sessions 76407,1524 (X) The idea was to learn how to do my own assembly interfacing. ( I could also use "PRINT CHR$(7)", but...) Rich There is 1 Reply. #: 7655 S3/Languages 22-Oct-90 15:17:23 Sb: #7652-RMA woes Fm: Zack Sessions 76407,1524 To: Richard Ries 76057,3534 Yeah, that's what I figgered. Just wanted to bug ya! Zack #: 7796 S3/Languages 27-Oct-90 11:04:16 Sb: #C loop Fm: Jay Truesdale 72176,3565 To: all This short OSK C program fragment prints the last structure record twice! Since the check in the while loop is at the start of the loop I'd figure that EOF ought to be detected properly. I checked the file using dump and the last record is only in the file once. Any ideas?? main() { struct example_record record; FILE *in_file; while( feof(in_file)==0 ) { fread(&record, sizeof(record), 1, in_file); printf("%9d %25s %25s %15s %5s %5d\n", record.ssn, record.name, record.addr, record.city, record.state, record.zip); } /* end of while */ fclose(in_file); } /* End of main */ There are 2 Replies. #: 7803 S3/Languages 27-Oct-90 16:09:44 Sb: #7796-#C loop Fm: James Jones 76257,562 To: Jay Truesdale 72176,3565 (X) C standard I/O is set up such that feof(fp) is true, aside from questions of attempts to explicitly set or clear it outside of library code, only when one has attempted to read past the end of the file. The standard I/O routines don't attempt to tell whether the current read has read the last byte of the file and set the EOF flag in the FILE structure in that case, which is what would have to happen for the code in your message to behave the way you expected. There is 1 Reply. #: 7834 S3/Languages 28-Oct-90 11:00:26 Sb: #7803-#C loop Fm: Jay Truesdale 72176,3565 To: James Jones 76257,562 (X) Ok, I understand what you're saying. The MW OSK C Manual p. 61 says "A non-zero value is returned if the file is *at* end-of-file, otherwise a zero is returned." (emphasis added) which is what I based my code on. I'll scribble in a note in my manual, maybe you could nudge the manual writers to add this in to a future revision? Thanks a bunch! -J There is 1 Reply. #: 7853 S3/Languages 28-Oct-90 17:24:23 Sb: #7834-C loop Fm: James Jones 76257,562 To: Jay Truesdale 72176,3565 (X) I'll bring the topic up; there is definitely a chance for confusion. #: 7828 S3/Languages 28-Oct-90 08:53:24 Sb: #7796-#C loop Fm: Pete Lyall 76703,4230 To: Jay Truesdale 72176,3565 (X) Jay - In the code fragment, there is nowhere where the file is opened. Other than that, it looks basically okay. I prefer the construct: while(!feof(file)) { ... Pete There is 1 Reply. #: 7835 S3/Languages 28-Oct-90 11:00:43 Sb: #7828-#C loop Fm: Jay Truesdale 72176,3565 To: Pete Lyall 76703,4230 (X) Pete, The file was opened previously in the code. I did try "!feof" but for some reason I changed it while trying to solve some other problem, can't recall what it was at the moment. James Jones said that you have to actually read past EOF. There is 1 Reply. #: 7842 S3/Languages 28-Oct-90 14:01:57 Sb: #7835-#C loop Fm: Pete Lyall 76703,4230 To: Jay Truesdale 72176,3565 (X) Hmm- That may be cloaked by the library, because something like this works ducky: ... open file ... while(!feof(file)) { fgets(buffer,MAX, file); puts(buffer); } ... close file ... Pete There is 1 Reply. #: 7852 S3/Languages 28-Oct-90 17:23:23 Sb: #7842-C loop Fm: James Jones 76257,562 To: Pete Lyall 76703,4230 (X) If you look close, you may find an extra \n in the output. Do a dump of the output file. #: 7798 S3/Languages 27-Oct-90 12:20:22 Sb: #OSK C Fm: Jay Truesdale 72176,3565 To: all OK, I must be confused! The C book I am using shows something like this: while( (ch=getchar()) |='Y' && ch |='y' && ch |= 'N' && ch |= 'n') printf("Please enter a Y or a N\n"); "ch" is defined like this: int ch; As I understand it, getchar returns an integer so this should be ok. When I compile this with the MW OSK C compiler I get: "prog9.c", line 59: **** lvalue required **** while( (ch=getc((&_iob[0]))) |='Y' && ch |='y' && ch |= 'N' && ch |= 'n') ^ and this continues for each ocurrence of "ch" in the statement. The error messages in the C manual state that this means that the item to the left of the assignment operator must be able to be stored into. I thought you could store a char into an int. So what obvious fact am I overlooking this time? -J There are 3 Replies. #: 7800 S3/Languages 27-Oct-90 14:02:10 Sb: #7798-#OSK C Fm: David Betz 76704,47 To: Jay Truesdale 72176,3565 (X) You should be using '!=' instead of '|='. The vertical bar is the bitwise or operator and combined with '=', it is the bitwise or assignment operator. There is 1 Reply. #: 7836 S3/Languages 28-Oct-90 11:00:54 Sb: #7800-OSK C Fm: Jay Truesdale 72176,3565 To: David Betz 76704,47 (X) Argh! (insert sound of palm contacting forehead here) I DID mean to type "!=" ! I KNEW it had to be something simple, Thanks! #: 7804 S3/Languages 27-Oct-90 16:13:00 Sb: #7798-#OSK C Fm: James Jones 76257,562 To: Jay Truesdale 72176,3565 (X) You typed |= and you probably meant !=. A subtle difference, but a crucial one! The reason the caret points at the = is that it's the left-hand side of the |= assignment operator, or rather, the = is the root node of the expression tree that's the left child of the |=. Actually, you're pretty darned lucky; the rest of the |= should have been != too, but because just ch (which is an lvalue) was the LHS, the compiler would have blithely done what you told it to do, and your loop would have run forever! There is 1 Reply. #: 7837 S3/Languages 28-Oct-90 11:01:55 Sb: #7804-OSK C Fm: Jay Truesdale 72176,3565 To: James Jones 76257,562 (X) Argh! (insert sound of palm contacting forehead here) I DID mean to type "!=" ! I KNEW it had to be something simple, Thanks! #: 7829 S3/Languages 28-Oct-90 08:58:55 Sb: #7798-#OSK C Fm: Pete Lyall 76703,4230 To: Jay Truesdale 72176,3565 (X) Jay - Did you really mean to use "or equals" (|=), or rather "not equals" (!=)? Also - better to break it down, either explicitly, or with parentheses, into more digestable chunks: c = getc(iobuf_mine); if(c != 'Y' && c != 'y' .... Pete There is 1 Reply. #: 7838 S3/Languages 28-Oct-90 11:02:18 Sb: #7829-OSK C Fm: Jay Truesdale 72176,3565 To: Pete Lyall 76703,4230 (X) I agree with breaking the code down in to more manageble chunks, makes it much easier to remember later what in the heck you were trying to do! I generally try to keep things simple, this was an example that I swiped from a book and then modified. I'm trying to get stuff done ASAP when I don't fully understand all of the nuances of C. No real surprises, just lots of "oh yeahs" followed by the sound of my palm impacting my forehead. There was a joke or something about this that connected the slapping of one's forehead with one's palm to a growing forehead/receeding hairline but it escapes me at the moment. Thanks, -J #: 7959 S3/Languages 03-Nov-90 10:24:07 Sb: #6809 make? Fm: Ken Drexler 75126,3427 To: All Help. I an looking for a copy of the 6809 version of Microware's make. I have tried to get the Development System from Radio Shack and Computer Plus. Both report that the product has been discontinued and out of stock. I have about 250K worth of a Basic09 attorney's time recording system which I want to rewrite in c. The program will numerous modules which are compiled in various configurations -- just the job for make and a bear without it. (Also I want to be able to move the source code to an OSK machine which I have and make it there using the OSK make.) Can any one suggest a source for 6809 make? Now that RS and MSC have checked out of supporting OS-9, I am out of ideas. Ken Drexler 75126,3427 There is 1 Reply. #: 7970 S3/Languages 03-Nov-90 18:25:53 Sb: #7959-6809 make? Fm: Pete Lyall 76703,4230 To: Ken Drexler 75126,3427 Ken - If you can't find the DEV PAK make, Carl Kreider also has a version in the OS9 UG lib. Spawned from the same concept, although the options, defaults, and grammar may be a bit different. Also - check DDJFORUM ... they have sources for a PD make, I believe. USENET sees PD MAKEs frequently too. Pete #: 7996 S3/Languages 04-Nov-90 22:11:13 Sb: C help Fm: Robert A. Larson 75126,723 To: 76336,3226 (X) Newsgroups: compuserve.os9.osk Subject: Re: Help with C References: Distribution: compuserve In article 76336.3226@compuserve.com (MAS) writes: >create and access a login shell >from within an OS-9 program. On osk, a login shell starts with "-" in argv[0]. Also pay attention to the enviornment you pass it. (login creates PORT, HOME, SHELL, USER, and PATH, and should but doesn't pass TZ along.) pipe0 = open("/pipe", S_IREAD | S_IWRITE); pipe1 = open("/pipe", S_IREAD | S_IWRITE); save0 = dup(0); save1 = dup(1); save2 = dup(2); close(0); dup(pipe0); close(1); dup(pipe1); close(2); dup(pipe1); child = os9exec(os9forkc, "shell", argv, envp, 0, 0, 3); close(0); dup(save0); close(1); dup(save1); close(2); dup(save2); #: 8077 S3/Languages 08-Nov-90 01:15:05 Sb: #7970-6809 make? Fm: Ken Drexler 75126,3427 To: Pete Lyall 76703,4230 (X) Pete, Thanks for the ideas. I did not know that Carl had one in the UG lib. I will looking for it. Ken #: 8134 S3/Languages 12-Nov-90 10:33:35 Sb: #global labels in "c" Fm: Mark Wuest 74030,332 To: all I just tried to put my very first label in a "c" program to no avail. I've never used "goto", and do not need it now. What I want is to put a global label in so that sysdbg can be used to put a breakpoint in the code without having to disasemble a rather lengthy function looking for the right place. Here's what my code looked like: if(a){ dothis(); dothat(); } else{ FOO: x = -1; } When I tried to find FOO in the symbol table with sysdbg, I could not find it. When I tried to put a breakpoint at it ("b FOO"), sysdbg complained with "breakpoint at odd address" and did not put one there. Ok, all you non-structured (and proud of it!) goto'ers out there, how do I put a global label in a function? (We worked around it with a function that just did the "x = -1" and returned.) Mark There is 1 Reply. #: 8148 S3/Languages 12-Nov-90 17:48:38 Sb: #8134-#global labels in "c" Fm: James Jones 76257,562 To: Mark Wuest 74030,332 (X) Sorry, but if you look close you'll notice that the C compiler output contains labels of the form _ which do not appear in .r files corresponding to labels, since they're known only in the function. If you are determined, you'll have to do something like edit the assembly language output, find the label that corresponds to FOO, and tack a colon on the end to make it global. There is 1 Reply. #: 8174 S3/Languages 13-Nov-90 10:47:28 Sb: #8148-global labels in "c" Fm: Mark Wuest 74030,332 To: James Jones 76257,562 (X) I was hoping you'd say something like "labels in C are supposed to be so-and-so" Oh well. We effectively did what you said by compiling to the .a with source imbedded as comments to help us find the spot, then went to a separate function. Too bad we don't have our imbedded application on a network so we could use srcdbg! Thanks mucho, Mark #: 8233 S3/Languages 16-Nov-90 09:09:37 Sb: #shell+ Fm: Tom Napolitano 70215,1130 To: 72467,1111 (X) Mike, A few days ago you mentioned a bug in shell+ that causes it to grab 8k for every processs it spawns. Well, to check it out I started up mvcanvas under the original shell+ 2.1, changed $130f to 00, then started a second mvcanvas. PMap shows the same amount of memory being used by each process. What am I missing here? Do I understand correctly that malloc() will grab memory until the 64k process space is used, irrespective of whether I specify the full shot of memory, either at link time or by the #XXk command line option? Thanks for your time, tom n There is 1 Reply. #: 8304 S3/Languages 18-Nov-90 18:05:10 Sb: #8233-#shell+ Fm: Mike Knudsen 72467,1111 To: Tom Napolitano 70215,1130 (X) Malloc() will grab memory until there are no 8K bolcks left in your proc's 64K space, yes. But first it will take whatever's left in the highest 8K block of your original process allocation. Now here's the hooker: the way C's startup routine works, and extra memory you give it on the command linea with #K (or Shell+ gives it behind your back), that memory can only be used for extra STACK space. [Read "any" for "and" above.] This memory is DEINIED to malloc(), which always starts beyond your stack space. Thus shell+, by giving your program extra stack space, causes malloc() to start off with that much LESS memory available. It all makes sense now, after Greg Law and Zack Sessions helped figure it out on the low-priced service (sometimes cheaper is better, eh?). But it took 3-4 people to put all the pieces of evidence togehter. WHo says there's no science in COmputer Science? --mike k PS: MVCanvas might *not* be one of the programs affected, maybe I was wrong or was thinking of the older version. There is 1 Reply. #: 8359 S3/Languages 21-Nov-90 07:20:17 Sb: #8304-shell+ Fm: Tom Napolitano 70215,1130 To: Mike Knudsen 72467,1111 Mike, Thanks for the explanation; now the light shines through the darkness. tom n #: 8314 S3/Languages 19-Nov-90 00:33:45 Sb: #Make Utility Fm: Tony Cappellini 76370,2104 To: Carl Krieder Karl I have just downloaded ar v1.3 from Delphi. I noticed in the archive that there was a makefile, but I don't have the make utility. Can you tell me where I can find it? Ar there more than one ? Are there any advantages to one over the others ? I have been looking for a make utility for os9 lII for sometime now. I tried to make one using the new script features of shell plus 2.0, but they don't work to well, but it's better than typing the cc comman line over and over. Thanks. TC There are 2 Replies. #: 8332 S3/Languages 19-Nov-90 09:53:50 Sb: #8314-Make Utility Fm: Pete Lyall 76703,4230 To: Tony Cappellini 76370,2104 Tony - Carl's at 71076,76, and doesn't get on too often these days. The 'make' he used initially was his own. It should be available in the UGLIB DL. If it's not there, Mike Ward probaby has it archived offline, and will be happy to upload it for you (76703,2013). Carl's 'make' was good (in a void), but I prefer the dev pak make. It's closer to both Unix and 68k make's. There are also sources floating about (USENET, PC Forums, DDJ Forum, etc.) for public domain make's, so you could also roll your own if you like. Pete #: 8337 S3/Languages 19-Nov-90 16:23:19 Sb: #8314-Make Utility Fm: Zack Sessions 76407,1524 To: Tony Cappellini 76370,2104 Tim Kientzle has written a replacement MAKE utility. I will upload it here when I get the chance. Zack #: 8339 S3/Languages 19-Nov-90 18:14:58 Sb: #C programming Fm: MAS 76336,3226 To: sysop (X) Hello again, I have another question on OS9 C programming. How can I do a Non-Blocking keyboard read? (like inkey$ in basic). At the moment, I am using getstat(1,0) to chec to check if there is something in 'stdin'; if there is i use fgets() to read thin one char at a time. The problem with this is that a need two returns '\n's to end a line before it recognises the first lin end the line before it recognises the first line. many thanks, robert There are 3 Replies. #: 8340 S3/Languages 19-Nov-90 19:01:40 Sb: #8339-C programming Fm: James Jones 76257,562 To: MAS 76336,3226 (X) Two things: one, fgets() is set up to always read up until either a \n is seen or the buffer you hand it fills up; two, the FILE structure for stdin is, if you have it hooked up to a terminal, going to by default use readln() for input. (Gee, I just split an infinitive! :=) The getstat is sufficiently system-dependent that I probably would hide the whole thing under a function interface (that could buffer stuff for you if more than one character were ready, for efficiency's sake) and not bother to use C standard I/O. #: 8342 S3/Languages 19-Nov-90 19:54:43 Sb: #8339-C programming Fm: Pete Lyall 76703,4230 To: MAS 76336,3226 (X) Your approach using the getsYour approach using the getstat call is correct. Fgets() is the wrong way to read in one character at a time. You could either use: a) read() - low level, raw I/O b) getc(fp) - high level. When using buffered (high level) I/O, and you want character granularity, you may want to unbuffer standard input like this: setbuf(stdin, NULL); Pete #: 8348 S3/Languages 20-Nov-90 10:00:04 Sb: #8339-C programming Fm: Mark Wuest 74030,332 To: MAS 76336,3226 (X) Robert, Here's a quick-and-dirty routine to get one byte from a path you have previously opened with open() (or use path = 0 for stdin). cread(path,buf) int path; char *buf; { int cnt; if((cnt = _gs_rdy(path)) < 0) return(cnt); if(cnt == 0) return(cnt); return(read(path,buf,1); } This should read just one byte. If there is nothing there, it returns 0. Obviously if there is an error, it returns -1. Hope this is a good starting place for you. Mark #: 8344 S3/Languages 19-Nov-90 21:55:53 Sb: #C programming Fm: MAS 76336,3226 To: sysop (X) Thanks guys for the non-blocking keyboard read tips. I have a few more puzzle that I can not solve. (I really hate porting this progam from UNIX to OS9!) 1. Is there a user validation function on Os9? Something like pwdauth(username,password) on UNIX? or do I have to look in the password file mys file myself. 2. I can find mknod() or makdir() on OS9, but how do I remove a directory? 3. Is there a function to check file access permission ? 4. how can I get the current directory? I have look through the microware language manual a couple times and it is getting me nowhere. Can you recommand me some books or articles that can speed up my learing process on OS9? Thanks again Robert. There is 1 Reply. #: 8352 S3/Languages 20-Nov-90 11:28:23 Sb: #8344-C programming Fm: Pete Lyall 76703,4230 To: MAS 76336,3226 (X) (system is going down in 5 mins, so I have to be quick): A) Use the password related functions available in the Kreider libraries. We all use them instead of the MW libraries. See LIB 3. b) Sorry - no easy way... Wait.. did you try 'unlink()'? Dunno if it works on a directory (never tried it).. worst case you could "system("deldir {dirname})" Pete #: 8375 S3/Languages 22-Nov-90 12:12:48 Sb: #conversion of B09 REALS Fm: Zack Sessions 76407,1524 To: ALL Has anyone written a routine to convert BASIC09 REAL variable type to a C FLOAT datatype? Zack There is 1 Reply. #: 8377 S3/Languages 22-Nov-90 16:13:46 Sb: #8375-#conversion of B09 REALS Fm: James Jones 76257,562 To: Zack Sessions 76407,1524 (X) No, but I bet that since the range is probably the same, that one might be able to get away with chucking the least significant byte and stuffing it in a C float on the 6809. Give that a shot; even if it doesn't work, it's easy to try! :-) There is 1 Reply. #: 8382 S3/Languages 22-Nov-90 22:05:06 Sb: #8377-#conversion of B09 REALS Fm: Zack Sessions 76407,1524 To: James Jones 76257,562 (X) The main problem is that the sign bit is on opposite sides of the mantissa! I think it may have to be done by an assembler subroutine. There is 1 Reply. #: 8383 S3/Languages 23-Nov-90 11:37:19 Sb: #8382-#conversion of B09 REALS Fm: Pete Lyall 76703,4230 To: Zack Sessions 76407,1524 (X) Zack - Why? Is byte manipulation out of the range of B09's capanilities? What about LOR, LAND, pointers, and byte arrays? Pete There are 2 Replies. #: 8384 S3/Languages 23-Nov-90 11:37:39 Sb: #8383-conversion of B09 REALS Fm: Pete Lyall 76703,4230 To: Pete Lyall 76703,4230 (X) Whoops.... capaBilities. #: 8385 S3/Languages 23-Nov-90 16:36:09 Sb: #8383-conversion of B09 REALS Fm: Zack Sessions 76407,1524 To: Pete Lyall 76703,4230 I am not using BASIC09, I am having to interpet some files written with BASIC09 with C and some fields are BASIC09 REAL datatype which is funcky compared to C's double. Fortunatly, Greg Law reminded me that the Microware C manual has some subroutines which convert REAL to double and back, and they work just fine. Zack #: 8398 S3/Languages 24-Nov-90 11:29:27 Sb: #8385-conversion of B09 REALS Fm: Pete Lyall 76703,4230 To: Zack Sessions 76407,1524 (X) Ahh - great. I just saw your reference to using ASSEMBLER, and didn't see any reason to... Pete #: 8409 S3/Languages 25-Nov-90 12:32:29 Sb: #stack space Fm: Steve Wegert 76703,4255 To: Kev or ??? 76703,4227 (X) Kev, Is there a spot in the module header that either tells or points to, how much stack space was given during the compile? In modifying some code in the suite of tools for mtsmon, I ran into a **stack overflow** error when executing Pete's mkuser utility. I recompiled and added an extra 256 bytes with the -m=1 option on the compiler and that seemed to do the trick, but I was wondering if there was a better way than the add-a-page-until-the-error-goes-away approach. Steve There is 1 Reply. #: 8411 S3/Languages 25-Nov-90 14:57:17 Sb: #8409-#stack space Fm: Pete Lyall 76703,4230 To: Steve Wegert 76703,4255 (X) Steve - No - not inherently. You're doing it the right way.... Pete There is 1 Reply. #: 8416 S3/Languages 25-Nov-90 20:46:05 Sb: #8411-stack space Fm: Steve Wegert 76703,4255 To: Pete Lyall 76703,4230 (X) Thanks for the feed back, Pete.