Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!sdd.hp.com!decwrl!dogie.macc.wisc.edu!vms.macc.wisc.edu From: gilmore@vms.macc.wisc.edu (Neil Gilmore) Newsgroups: comp.sys.amiga.tech Subject: Excruciatingly simple programming question... Message-ID: <4106@dogie.macc.wisc.edu> Date: 27 Jul 90 21:58:24 GMT Sender: news@dogie.macc.wisc.edu Organization: University of Wisconsin Academic Computing Center Lines: 78 This is much simpler than the discussions which normally come up here, but the only other Amiga programmer I see regularly doesn't know how to do anything other than open a new screen (but at least now he programs so that he exits cleanly, though the program grabs the entire system while it's running). What I'm using: Manx 3.6b? (question on the 'b', not the 3.6) Amiga 2000, ProRam with 2 megs 1.3 roms, Workbench 34.28(?) The AmigaDOS Manual (2nd edition) Programmer's Guide to the Amiga, by Rob Peck. The problem program (listing 2.2 in Peck) (reproduced here without permission): #include "libraries/dosextens.h" extren struct FileHandle *Open(); main() { char userinput[256]; int howmany; struct FileHandle *dos_fh; dos_fh = Open("CON:10/10/500/150/New Window",MODE_NEWFILE); Write(dos_fh,"Please type an input line, then press RETURN\n", 45); howmany = Read(dos_fh,userinput,255); userinput[howmany] = '\0'; printf("You typed %ld characters:\n",howmany); printf("and here they are:\n"); printf("%ls\n",userinput); Close(dos_fh); } Looks simple, huh? Assume that syntax errors you find here are the result of my typing, as I get no errors when I compile and link. The problem: Open() works fine. Write() causes the string to be written, but the third arguement (length) seems to be ignored, causing endless streams of accented characters, screen flashes, and control codes to print. It also causes the mouse pointer to cease responding after any click. When I remove the Write(), the Read() works only if I do not type too many characters to the created CON: window. Too many is 'some more' than 255. Again, length seems to be ignored, but the AD MAnual does not explicitly say that only length characters will be read. Typing too many characters results in the 'Task Held' requester, and a guru. After spending much time trying to get this to work, I gave up and tried listing 2.2, essentially the same program using a RAW: window. Though this program had no Write(), Read() again acted in an unexpected fashion. Read() would return after each character typed, presumably returning the correct character code, but actualLength was gibberish, not 0, 1, -1, or any recognizable number. There is probably a one sentence explanation for this, perhaps one of the differences between Manx and Lattice, but until I can get this sort of program to work, there isn't much hope for producing anything useful. Respond here or by email. Thank you. +-----------------------------------------------------------------------+ | Kitakaze Tatsu Raito Neil Gilmore internet:gilmore@macc.wisc.edu | | Jararvellir, MACC, UW-Madison bitnet: gilmore@wiscmac3 | | Middle Kingdom Madison, Wi DoD #00000064 (no ints here) | +-----------------------------------------------------------------------+