[Address for email replies below.]
I previously wrote
> Date: 23 Apr 1997 14:58:04 GMT
>
> It is often useful for a program to get some input from the user. For
> many purposes readline works very nicely.
>
> ...
> So I thought I would write a program to open a ved buffer and wait till
> you've hit return in that buffer and then take the line you've typed and
> make a list of text items. This works just fine, as follows, using the
> procedure veddiscin
>
> define veddiscin(filename) -> repeater;
> ;;; Get a character repeater for the VED file with the name.
>
> lvars dev = consveddevice(sysfileok(filename), 0, true);
>
> define lconstant newcharin(dev) -> char;
> lconstant string = '0';
> sysread(dev, string, 1) ->;
> fast_subscrs(1, string) -> char
> enddefine;
>
> newcharin(%dev%) -> repeater;
> enddefine;
>
>
> define vedreadlinefrom(filename, defaults, save) -> list;
> ;;; filename: a string
> ;;; defaults: false or vedhelpdefaults, or vedveddefaults ,etc.
> ;;; save: if true, then save the buffer, otherwise quit
>
> unless defaults then vedhelpdefaults -> defaults endunless;
>
> vededit(filename, defaults);
>
> lvars item, list,
> newcharin = veddiscin(filename),
> procedure rep = incharitem(newcharin); ;;; item repeater
>
> dlocal popnewline = true, popprompt = pop_readline_prompt;
>
> ;;; Make a list of items to next newline
> [% until (rep() ->> item) == newline do item enduntil %] -> list;
>
> unless save then
> if vedwriteable then ved_wq() else ved_q() endif;
> endunless;
> enddefine;
>
> ;;; test it
> vedreadlinefrom('INTERACT', false, false) =>
>
> That works fine in a normal program. But if it is invoked by a
> mouse-selected button, i.e. in a callback I find that it produces errors
> of this form:
>
> ;;; MISHAP - NUMBER(S) NEEDED
> ;;; INVOLVING: <false> 1
etc.
Thanks to very prompt help from John Williams at Sussex I have
learnt the source of the problem and how to fix it.
The source of the problem is an assumption made by the read
procedure associated with consveddevice that it is being called in
the context of the procedure ved_apply_action which takes a
procedure as argument and runs it. It looks up the calling chain to
that point and uses consproc_to to create a process, which can be
resumed after Ved has been run.
Unfortunately in a callback the read procedure does not find the
call of ved_apply_action. The solution is for my event handler to
invoke the required procedure through ved_apply_action. So I can now
have a callback asking the user to provide input text via a Ved
buffer.
Another would allow the the procedure to read in a whole marked
range of text instead of just one line.
Aaron
--
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs )
School of Computer Science, The University of Birmingham, B15 2TT, England
EMAIL A. Sloman @ cs. bham.ac.in uk(||| MAKE UNSOLICITED EMAIL ADVERTS ILLEGAL |||)
Phone: +44-121-414-4775 (Sec 3711) Fax: +44-121-414-4281
|