bug-guile-ncurses
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-guile-ncurses] set-field-type! problems


From: Mike Gran
Subject: Re: [Bug-guile-ncurses] set-field-type! problems
Date: Sat, 23 Feb 2013 07:50:59 -0800 (PST)

>Hi,

>
>I am having problems with set-field-type!  e.g.
>if I go into one of the example code fragments such as below and insert 
>(set-field-type! (first field) TYPE_ALPHA 10)
>
>I get the error message:
>
>ERROR: Unbound variable: TYPE_ALPHA
>
>Same with other types.  The code works fine with that line commented out
> , so I am importing the correct modules and have things otherwise properly
> configured.  I need to use TYPE_ENUM.  Any suggestions?


Looks like I didn't export a constant named TYPE_ALPHA.
You can work around the bug by prefacing TYPE_ALPHA with a
quote, like so.


(set-field-type! (first field) 'TYPE_ALPHA 10)

I'll patch that in the next release.


Note that once you add that in, you'll get an error if the user
enters less than 10 characters.  The error will occur in the next
call to form-driver that tries to move to the next field.  So that's 

where you'll have to catch the error and beep or do some warning
for the user.

Something like this

;; Loop through to get user requests
(let loop ((ch (getch my-form-win)))
  (if (not (eqv? ch (key-f 2)))
      (cond
       ((eqv? ch KEY_DOWN)
        (begin
          ;; Go to the end of the next field
          (if (false-if-exception (form-driver my-form REQ_NEXT_FIELD))
              (form-driver my-form REQ_END_LINE)
              (beep))
          (loop (getch my-form-win))))
       ((eqv? ch KEY_UP)
        (begin
          ;; Go to the end of the previous field
          (if (false-if-exception (form-driver my-form REQ_PREV_FIELD))
              (form-driver my-form REQ_END_LINE)
              (beep))
          (loop (getch my-form-win))))
       (else
        (begin
          ;; Print any normal character
          (form-driver my-form ch)
          (loop (getch my-form-win)))))))

Thanks,

Mike




reply via email to

[Prev in Thread] Current Thread [Next in Thread]