Link to home
Start Free TrialLog in
Avatar of tomercohen
tomercohen

asked on

input history?

I've done a program which output strings from the user using the gets() function. Now, as far as I see, with F3 (under DOS) I can print the last entered string, and with the arrows I can edit the string.

Now, I wish to replace the function with something else, which offer me history options, with the up and down arrows, like in doskey, for example, with the minimum changes to the whole program, if any.

Well, I guess TC/BC doesn't has it, so I wish anyone over here to help. Thanks.
Avatar of djbusychild
djbusychild

you'll first need to store however many commands the user enters (you may need to limit this to say 10, etc) then
you can detect the up/down arrow key to traverse that list and output that.

did you want a sample code?
Avatar of tomercohen

ASKER

Sure I want to. That's emergency. ;-)
ASKER CERTIFIED SOLUTION
Avatar of djbusychild
djbusychild

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
this is a rought, it's not really using a circular queue but just a simple array, so it's not truly circular. I haven't dealt with the situation where you go beyond the history limit and you have to push the others away... Instead I just start overwriting from index 0.

you get the idea, though.
as a default,the DOS also has up to 10(if i am not mistaken) commands back.if you press up further,it simply returns you to the last command.this means that if you recieve more hten 10 "up"s you reset your counter,and start all over again.
tomer-(fonetic hebrew)tikanes laatar shel rotter,ulai yuchlu laazor lecha sham.yesh sham harbe anashiim shemevinim besi.
Hi, did this help at all?
Yabelson, I guess you wrong. DOS has no built-in history options at all, except the F3 key, for the last command. This let me use gets() with only one line of history. In other operating system, this is not the same.

Oh, (in fonetic hebrew) - Ani lo ohev et haatar shel rotter. En sham anashim nechmadim. ;-)
tomercohen, did the code help?
djbusychild, not at all, I made it with another way.
Thanks anyway. ;-)