Page 1 of 1

PostPosted: Mon Jan 28, 2002 2:08 pm
by awschwab
There are some quirks to the way PToolboxLib Fields accept text. Here is a small program that demonstrates what I mean, with a description in the comments.

<pre id=code><font face=courier size=2 id=code>//FieldQuirks.pc
// Demonstrates quirks of PToolboxLib Fields.
Both text fields are set to 12 maximum characters. Graffitti text
entry is limited to 12 characters, alphanumeric in the text field,
and numeric alone in the numeric field. The point of this program is
to demonstrate that:
1) Text added by Fctl(INSERT,&string) is not limited to numeric in
the numeric field, but is limited by the field character maximum.
2) Text added by FsetText(Id, string) is not limited by numeric type,
nor by character maximum. The ability to add more text than was
allocated can be dangerous.

Conclusion: Fctl(INSERT, ... is safer than FsetText().
library "PToolboxLib"
include "Fctl.h"

#define LTEXT 256
#define LNUM 257
#define FORM1 3000
#define FTEXT 3010
#define FNUM 3011
#define BINSERT 3020
#define BSET 3021
#define BQUIT 3022

int higt, x, y = 40, width = 80, maxChar = 12;
int e, Id;
string crud = "abc123", stuff;

higt = FontHeight();

Form(FORM1, "Field Quirks");
Field(FTEXT, 1, 70, y, width, higt, maxChar, "");
Label(LTEXT, 5, y, "Text Field");
Field(FNUM, 0x1001, 70, y + higt, width, higt, maxChar, "");
Label(LNUM, 5, y + higt, "Numeric Field");

x = Button(BQUIT, 0, 0, 15, 0, 0, "Quit");
x = Button(BINSERT, 0, x, 15, 0, 0, "Insert");
Button(BSET, 0, x, 15, 0, 0, "Set Text");


while (BQUIT != (e = Fevent(1)))
if (e == BINSERT)
Fctl(INSERT, &crud);
else if (e == BSET)
Id = Fctl(GETFOCUS);
stuff = FgetText(Id);
FsetText(Id, stuff + "A3");
</font id=code></pre id=code>

Edited by - awschwab on 01/28/2002 09:05:39

PostPosted: Mon Jan 28, 2002 3:14 pm
by jstadolnik
I'll fix all these problems.



The PToolboxLib guy.

PostPosted: Mon Jan 28, 2002 4:15 pm
by awschwab
It may actually be useful to retain the ability to put some alphanumeric characters into a numeric field in some circumstances. This allows negative numbers and scientific notation. One could imagine a field where the user can change the sign of a number by tapping a button, but would be allowed only to enter digits into the field.

PostPosted: Tue Jan 29, 2002 2:46 pm
by jstadolnik
I'll just fix the FsetText one then.


The PToolboxLib guy.

PostPosted: Tue Jan 29, 2002 5:36 pm
by awschwab
Would it be easy to make it possible to check whether a field is numeric at run time? This is not crucial; obviously one can just keep track of which field one is dealing with.

PostPosted: Wed Jan 30, 2002 3:41 am
by jstadolnik
It's possible, and it's not that much work, but at this point I'm inclined not to implement such a feature. As you pointed out the user really already has this information. If you have a compelling reason for having it, I'll reconsider it though.

I just overhauled the v7.1.7 Sort function. It like rocks! It has natural, caseless, and reverse sort options. It can handle any data type. It can sort data structures (blocks of array elements as opposed to individual elements) and can do up to 3 levels of sorting, and it's bloody fast. I also have a complete Handbase and Pilot-DB database interface implemented (but that will be out in 7.2 due to the documentation complexity). Version 7.1.7 should be out in a few days.


The PToolboxLib guy.

PostPosted: Wed Jan 30, 2002 5:34 pm
by awschwab