BBC BASIC for Windows
Programming >> BBC BASIC language >> help with restricting inputs
http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1322579650

help with restricting inputs
Post by malladinben on Nov 29th, 2011, 2:14pm

Hi,

Probably a stoopid noob question, but I've been trying to create a simple invoice entry table and can't seem to find how to restrict the number of characters a user can enter at an input prompt, so that their input doesn't end up moving into the next column.

Is there a way to manage this?

Thanks in advance,

Ben
Re: help with restricting inputs
Post by admin on Nov 29th, 2011, 3:01pm

on Nov 29th, 2011, 2:14pm, malladinben wrote:
Probably a stoopid noob question, but I've been trying to create a simple invoice entry table and can't seem to find how to restrict the number of characters a user can enter at an input prompt, so that their input doesn't end up moving into the next column.

If your input is by means of a dialogue box or edit box (which is the way most modern programs work) you can limit the number of characters that can be entered by sending the EM_LIMITTEXT message:

http://msdn.microsoft.com/en-us/library/windows/desktop/bb761607.aspx

If entry is by means of an 'old fashioned' method such as an INPUT statement you could write your own custom replacement, with a built-in limit, by adapting the FNinput function in the NOWAIT library:

http://www.bbcbasic.co.uk/bbcwin/manual/bbcwing.html#fninput

Other possibilities which come to mind are to provide a separate input field, which is then transferred to the correct place in the table like a spreadsheet (see the supplied example program SHEET.BBC) or to allow the entry to extend too far and then overwrite it afterwards.

As a final suggestion you could dynamically change the text viewport, which would cause the input to wrap onto the next row rather than to overwrite the next column.

Using a proper Windows GUI, such as an Edit Box or a List View is probably the best method, but it hardly meets your requirement of being simple!

Richard.