1. Standard Input Max Length Limitation
- Posted by Bryan So <sohim at yahoo.com> Jun 25, 2007
- 815 views
I realized after a little experimentation that gets(0) has a pretty small max limit. I think it can get only 128 characters. Is there a simple command to expand this limit? Or must one write a complex getkey() input routine to get around this for longer (say 1K max) input? I think getkey style input routine will involve complex screen scrolling/cursor positioning handling too, correct? Thanks for any pointers. Bryan
2. Re: Standard Input Max Length Limitation
- Posted by Robert Craig <rds at RapidEuphoria.com> Jun 25, 2007
- 752 views
- Last edited Jun 26, 2007
Bryan So wrote: > I realized after a little experimentation that gets(0) has a pretty small max > limit. I think it can get only 128 characters. There is no limit on gets(). Perhaps you are running into some sort of DOS or Windows limit on the maximum length of a typed input line at a command prompt, or something. Or maybe your DOS input contains a new-line character or control-Z (26), that you aren't aware of. What are you doing exactly? Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
3. Re: Standard Input Max Length Limitation
- Posted by CChris <christian.cuvier at agriculture.gouv.fr> Jun 25, 2007
- 749 views
- Last edited Jun 26, 2007
Bryan So wrote: > > I realized after a little experimentation that gets(0) has a pretty small max > limit. I think it can get only 128 characters. > > Is there a simple command to expand this limit? > > Or must one write a complex getkey() input routine to get around this for > longer > (say 1K max) input? I think getkey style input routine will involve complex > screen scrolling/cursor positioning handling too, correct? > > Thanks for any pointers. > > Bryan I assume you are using vanilla DOS. For .COM files, DOS stores the command line tail at CS:#081 in a buffer that ends at CS:#0FF. As a result, the command line under 16-bit DOS is at most 127 byte long. I don't know whether tehe Causeway extender does anything about it. CChris
4. Re: Standard Input Max Length Limitation
- Posted by Bryan So <sohim at yahoo.com> Jun 25, 2007
- 750 views
- Last edited Jun 26, 2007
OK, the real problem in detail: Here is the 4-line program: include get.e sequence s s = gets(0) printf(1, "Length: %d\n", length(s)) Under Windows XP, I run DOS Command Prompt. Then do EX TEST.EX Start to type. It will not allow you to type more than 128 characters. The cursor simply stays put after typing a while. I have also tried the TCSH shell using Cygwin. Same issue. I'm writing a language interpreter and really want user to be able to enter long command lines, e.g. print("a long string .... etc etc") Thanks Bryan ps... regarding "running under Vanilla DOS" comment. I am under the impression that ex.exe is supposed to be run under vanilla DOS, right? What else is available that is more recommended. Thanks.
5. Re: Standard Input Max Length Limitation
- Posted by Derek Parnell <ddparnell at bigpond.com> Jun 26, 2007
- 756 views
Bryan So wrote: > It will not allow you to type more than 128 characters. The > cursor simply stays put after typing a while.
include get.e function Console_Get() sequence lInput integer lChar lInput = {} lChar = wait_key() while lChar != '\r' do if lChar >= ' ' and lChar < 127 or lChar = '\t' then puts(1, lChar) lInput &= lChar end if lChar = wait_key() end while return lInput end function sequence s s = Console_Get() printf(1, "\nLength: %d\n", length(s))
-- Derek Parnell Melbourne, Australia Skype name: derek.j.parnell
6. Re: Standard Input Max Length Limitation
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Jun 26, 2007
- 772 views
Bryan So wrote: > > I have also tried the TCSH shell using Cygwin. Same issue. > > I'm writing a language interpreter and really want user to be able to enter > long command lines, e.g. print("a long string .... etc etc") > > Thanks > > Bryan > > ps... regarding "running under Vanilla DOS" comment. I am under the > impression > that ex.exe is supposed to be run under vanilla DOS, right? What else is > available > that is more recommended. Thanks. Is there a particular reason why you want to run under DOS instead of windows? You can use exwc.exe, which is the console version of the interpreter for windows. Or you could build it for cygwin (it'll probably take some work, but start by trying to build as bsd). Whenever I need something to work from the console, I use either exwc or exu. Using the windows version, as opposed to the DOS version opens up many more opportunities, since you can access dynamic libraries, and use the resources of the full operating system. Matt
7. Re: Standard Input Max Length Limitation
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Jun 26, 2007
- 745 views
Matt Lewis wrote: > Is there a particular reason why you want to run under DOS instead of > windows? You can use exwc.exe, which is the console version of the > interpreter for windows. I thought about that but a test showed it limited input to 79 characters! Pete
8. Re: Standard Input Max Length Limitation
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Jun 26, 2007
- 770 views
Pete Lomax wrote: > > Matt Lewis wrote: > > Is there a particular reason why you want to run under DOS instead of > > windows? You can use exwc.exe, which is the console version of the > > interpreter for windows. > I thought about that but a test showed it limited input to 79 characters! > Whoops, you're correct, of course. Since I've piped things much bigger than that through stdin, I assumed that it would work, but it seems that euphoria detects whether stdin is really the keyboard, and modifies behavior accordingly. There's nothing obvious (to me) that's limiting the input size. My suspicion is that it has something to do with the way Rob handles stdin/stdout under windows. In particular, this line from be_w.c looks suspicious: screen_loc.Right = 79; Matt
9. Re: Standard Input Max Length Limitation
- Posted by Robert Craig <rds at RapidEuphoria.com> Jun 26, 2007
- 767 views
Pete Lomax wrote: > Matt Lewis wrote: > > Is there a particular reason why you want to run under DOS instead of > > windows? You can use exwc.exe, which is the console version of the > > interpreter for windows. > I thought about that but a test showed it limited input to 79 characters! I'm not sure why that is, but there's no magic number built into Euphoria itself that limits gets(0). It will happily malloc space for millions of characters. If I open a command-prompt window with XP, and hold down the 'x' key, it complains that "'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' is not recognized as an internal or external command, operable program or batch file" But when I reach 259 x-characters it changes the complaint to: "The input line is too long." Note, I'm not running a Euphoria program at all, just entering a command at the prompt. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com
10. Re: Standard Input Max Length Limitation
- Posted by Matt Lewis <matthewwalkerlewis at gmail.com> Jun 26, 2007
- 796 views
Robert Craig wrote: > > Pete Lomax wrote: > > Matt Lewis wrote: > > > Is there a particular reason why you want to run under DOS instead of > > > windows? You can use exwc.exe, which is the console version of the > > > interpreter for windows. > > I thought about that but a test showed it limited input to 79 characters! > > I'm not sure why that is, but there's no magic number built into > Euphoria itself that limits gets(0). It will happily malloc > space for millions of characters. Yep, and it works as expected if you pipe stdio instead of typing it. > If I open a command-prompt window with XP, > and hold down the 'x' key, it complains that > "'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' is not recognized as an internal > or external command, operable program or batch file" > > But when I reach 259 x-characters it changes the complaint to: > "The input line is too long." > > Note, I'm not running a Euphoria program at all, > just entering a command at the prompt. Yeah, I'm that's a limitation of cmd.exe, but I was surprised to find that I could only get 79 characters typed into the console when I run this code:
? length( gets(0) & 0 ) - 1
I suspect that it's something to do with the console buffer not wanting to do a line wrap, but I haven't dug deep enough to figure out if that's true. I haven't tried at all with linux. Matt
11. Re: Standard Input Max Length Limitation
- Posted by Kenneth Rhodes <ken_rhodes30436 at yahoo.com> Jun 26, 2007
- 767 views
Matt Lewis wrote: > I was surprised to find that > I could only get 79 characters typed into the console when I run this code: > }}} <eucode> > ? length( gets(0) & 0 ) - 1 > </eucode> {{{ > I suspect that it's something to do with the console buffer not wanting to > do a line wrap, but I haven't dug deep enough to figure out if that's true. > > I haven't tried at all with linux. > > Matt For what its worth... I ran the code above on my Linux system up to about 1000 characters. No problem. Ken Rhodes Folding at Home: http://folding.stanford.edu/ 100% MicroSoft Free SuSE Linux 10.0 No AdWare, SpyWare, or Viruses! Life is Good,
12. Re: Standard Input Max Length Limitation
- Posted by Bryan So <sohim at yahoo.com> Jun 26, 2007
- 742 views
Yes, I have tried exw and exwc before but have to give up since they have fewer limits. It is probably unrelated to the limitation of cmd.exe because cmd has 259 max not 128. 259 is probably fine for a command line interpreter interface like the one I'm working on but 128 is just not enough for me. Derek, thanks for the console_gets code. But it will not fly because it is very, very complicated to add support for backspace (with proper screen scrolling and cursor positioning when line length is longer than say 255). I will now adapt the csh-like backslash convention to concatenate two input lines into one. But this seems to be an arbitrary burden to the user. It would be really nice if there is a native solution to gets(stdin). Thanks. Bryan
13. Re: Standard Input Max Length Limitation
- Posted by Fernando Bauer <fmbauer at hotmail.com> Jun 27, 2007
- 736 views
Matt Lewis wrote: > > Robert Craig wrote: > > > > Pete Lomax wrote: > > > Matt Lewis wrote: > > > > Is there a particular reason why you want to run under DOS instead of > > > > windows? You can use exwc.exe, which is the console version of the > > > > interpreter for windows. > > > I thought about that but a test showed it limited input to 79 characters! > > > > I'm not sure why that is, but there's no magic number built into > > Euphoria itself that limits gets(0). It will happily malloc > > space for millions of characters. > > Yep, and it works as expected if you pipe stdio instead of typing it. > > > If I open a command-prompt window with XP, > > and hold down the 'x' key, it complains that > > "'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx' is not recognized as an internal > > or external command, operable program or batch file" > > > > But when I reach 259 x-characters it changes the complaint to: > > "The input line is too long." > > > > Note, I'm not running a Euphoria program at all, > > just entering a command at the prompt. > > Yeah, I'm that's a limitation of cmd.exe, but I was surprised to find that > I could only get 79 characters typed into the console when I run this code: > }}} <eucode> > ? length( gets(0) & 0 ) - 1 > </eucode> {{{ > I suspect that it's something to do with the console buffer not wanting to > do a line wrap, but I haven't dug deep enough to figure out if that's true. > > I haven't tried at all with linux. > > Matt Hi, If you run for DOS (ex.exe) it results 128 in my system (WinXP). If I am right, the result obtained (79) in case of Windows is related to the position, not to the quantity of characters. Try this: position(1,70) ? length( gets(0) & 0 ) - 1 In file be_runtime.c we can read in the function key_gets() (from line 4529 of version 3.0.2): if (column < 79) { len = strlen(input_string); one_char[0] = c; ... This function is called by wingetch() which is called by EGets(). If the exw.exe is compiled with BORLAND or LCC, probably the result will be different, because key_gets() isn't called. Maybe Rob could better explain that limit for Windows? Regards, Fernando Porto Alegre/RS Brazil
14. Re: Standard Input Max Length Limitation
- Posted by Robert Craig <rds at RapidEuphoria.com> Jun 28, 2007
- 771 views
Fernando Bauer wrote: > If you run for DOS (ex.exe) it results 128 in my system (WinXP). > If I am right, the result obtained (79) in case of Windows is related to the > position, not to the quantity of characters. > Try this: > position(1,70) > ? length( gets(0) & 0 ) - 1 > > In file be_runtime.c we can read in the function key_gets() (from line 4529 > of version 3.0.2): > if (column < 79) { > len = strlen(input_string); > one_char[0] = c; > ... > This function is called by wingetch() which is called by EGets(). > If the exw.exe is compiled with BORLAND or LCC, probably the result will be > different, because key_gets() isn't called. > Maybe Rob could better explain that limit for Windows? Thanks for pointing out that code. I thought I was using key_gets() just for input during the interactive trace, but see now I'm also using it more generally when WATCOM for Windows is the C compiler used, i.e. in exw.exe and exwc.exe. key_gets() also handles backspaces, left-arrow etc. If anyone wants to experiment with increasing the 79 limit, feel free. I'm not sure it will work though in an 80-character wide Windows console. Regards, Rob Craig Rapid Deployment Software http://www.RapidEuphoria.com