How does that respond to this as input:
103009 (will be interpreted as a patient number) … or … 10302009 (not handled by your code) … or … 20091030 (will be interpreted as a phone number). Three date values that your code will not handle. Or, as Mike has pointed out: 724-733-0053 will also break your code (will be interpreted as a date.) If your code isn’t bullet-proof, the first time a real user touches it, it will break. Call that a “programmer’s first law.” I used to have a boss that, when I put something in front of him, could always break the code because he immediately tried all the insane stuff a typical user might do. He taught me well. What you’ve done here is start thinking “How can I figure out whether the input is a number, a name or a date?” You’ve handled some obvious cases, but not all cases are obvious or straightforward. I submit that you need to take off those blinders and rethink the process, doing something like I initially suggested. Then, when you know the user’s intent, validations and lookups become easy. Emmitt Dove Manager, Converting Applications Development Evergreen Packaging, Inc. [email protected] (203) 214-5683 m (203) 643-8022 o (203) 643-8086 f [email protected] From: [email protected] [mailto:[email protected]] On Behalf Of Michael J. Sinclair Sent: Saturday, October 31, 2009 1:59 PM To: RBASE-L Mailing List Subject: [RBASE-L] - Re: How do I check the data type of user entered data? Thanks..I understand. FWIW, this code is working pretty well... SET V vslashchk = (SLOC(.vinput,'/')) SET V vdashchk = (SLOC(.vinput,'-')) SET V valphachk = (ISALPHA(.vinput)) SET V vdigitchk = (ISDIGIT(.vinput)) SET V vlengthchk = (SLEN(.vinput)) If vslashchk <> 0 OR vdashchk <> 0 AND vdigitchk = 1 THEN GOTO birthday ENDIF IF vslashchk = 0 and vdashchk = 0 and vlengthchk <= 6 THEN GOTO patnumbr ENDIF IF vslashchk = 0 and vdashchk = 0 and vlengthchk >= 7 and vdigitchk = 1 THEN GOTO phone ENDIF IF valphachk = 1 THEN GOTO lastname ENDIF Mike -------------- Original message from "MikeB" <[email protected]>: -------------- > That won't work. The "DataType" of TEXT is always going to be TEXT. > > You would best follow Emmitt's suggestion in some way. > > The only DataType that can hold multiple types of DataTypes is a Variant, > which we don't have. > > It could be useful because it can hold Objects as well as data. > > It would be unlikely this would come into mainstream RBase without > considerable (engine) effort. > > > ----- Original Message ----- > From: "Michael J. Sinclair" > To: "RBASE-L Mailing List" > Sent: Saturday, October 31, 2009 10:47 AM > Subject: [RBASE-L] - Re: How do I check the data type of user entered data? > > > > Do you think it would be useful to request an enhancement, ie a new > > function, perhaps something called DATATYPE > > > > (DATATYPE(text)) > > > > Determines the type of data contained in text. > > > > In the following example, the value of vdatatype is DATE, > > > > SET VAR vdatatype = (DATATYPE('10/31/2009')) > > > > > > The way I have done it so far (not very elegant, but it works) is to > > assign the value of whatever the user typed in to a predetermined variable > > with the data type set in advance, like this... > > > > SET V vdata TEXT > > FILLIN vdata USING 'Enter data' > > SET V vdate DATE > > SET V vdate = .vdata > > IF vdata IS NOT NULL THEN > > --ok, its a date, deal with it > > GOTO nextstep > > ENDIF > > > > SET V vnumber INTEGER > > SET V vnumber = .vdata > > IF vnumber is NOT NULL THEN > > --ok it is a number, deal with it > > GOTO nextstep > > ENDIF > > > > etc... > > > > Mike > > -------------- Original message from "MikeB" > > : -------------- > > > > > >> > There is a function called CVTYPE you can use to determine data type. > >> > >> That won't be of much help if the collection method is always of type > >> TEXT. Emmitt's approach will be the least troublesome / unwieldy to use > >> for > >> a universal search value emanating from a DIALOG. > >> > >> ----- Original Message ----- > >> From: "jan johansen" > >> To: "RBASE-L Mailing List" > >> Sent: Saturday, October 31, 2009 9:06 AM > >> Subject: [RBASE-L] - Re: How do I check the data type of user entered > >> data? > >> > >> > >> > There is a function called CVTYPE you can use to determine data type. > >> > > >> > What I did was to create a custom search form with a > >> > Variable Edit to contain the string to search for, > >> > Variable Radio Group to select what to search, > >> > and a Variable List View to display the search results. > >> > > >> > There is another pretty slick method to search all your desired > >> > columns but it is an example shown in the Super Advanced training. > >> > So I don't believe I am at liberty to share it. If Razzak wants to > >> > share it he can. > >> > > >> > Jan > >> > > >> > > >> > > >> > -----Original Message----- > >> > From: mjsmd > >> > To: [email protected] (RBASE-L Mailing List) > >> > Date: Sat, 31 Oct 2009 08:11:47 -0400 > >> > Subject: [RBASE-L] - How do I check the data type of user entered data? > >> > > >> > > >> > Hi all, > >> > I want my user to be able to have the option of entering a birthday, > >> > last name, client ID (an integer less than 999999) or a phone number > >> > (a number greater than 1000000) in order to select the desired client. > >> > What is the best way to determine the type of data that was entered? > >> > Is there a funtion that returns the data type? > >> >> > >> > > >> > >> > > > > > -------------------------------------------------------------------------------- > > > > Do you think it would be useful to request an enhancement, ie a new > function, perhaps something called DATATYPE > > (DATATYPE(text)) > > Determines the type of data contained in text. > > In the following example, the value of vdatatype is DATE, > > SET VAR vdatatype = (DATATYPE('10/31/2009')) > > > The way I have done it so far (not very elegant, but it works) is to assign > the value of whatever the user typed in to a predetermined variable with the > data type set in advance, like this... > > SET V vdata TEXT > FILLIN vdata USING 'Enter data' > SET V vdate DATE > SET V vdate = .vdata > IF vdata IS NOT NULL THEN > --ok, its a date, deal with it > GOTO nextstep > ENDIF > > SET V vnumber INTEGER > SET V vnumber = .vdata > IF vnumber is NOT NULL THEN > --ok it is a number, deal with it > GOTO nextstep > ENDIF > > etc... > > Mike > -------------- Original message from "MikeB" > : -------------- > > > > > There is a function called CVTYPE you can use to determine data type. > > > > That won't be of much help if the collection method is always of type > > TEXT. Emmitt's approach will be the least troublesome / unwieldy to use > for > > a universal search value emanating from a DIALOG. > > > > ----- Original Message ----- > > From: "jan johansen" > > To: "RBASE-L Mailing List" > > Sent: Saturday, October 31, 2009 9:06 AM > > Subject: [RBASE-L] - Re: How do I check the data type of user entered > data? > > > > > > > There is a function called CVTYPE you can use to determine data type. > > > > > > What I did was to create a custom search form with a > > > Variable Edit to contain the string to search for, > > > Variable Radio Group to select what to search, > > > and a Variable List View to display the search results. > > > > > > There is another pretty slick method to search all your desired > > > columns but it is an example shown in the Super Advanced training. > > > So I don't believe I am at liberty to share it. If Razzak wants to > > > share it he can. > > > > > > Jan > > > > > > > > > > > > -----Original Message----- > > > From: mjsmd > > > To: [email protected] (RBASE-L Mailing List) > > > Date: Sat, 31 Oct 2009 08:11:47 -0400 > > > Subject: [RBASE-L] - How do I check the data type of user entered > data? > > > > > > > > > Hi all, > > > I want my user to be able to have the option of entering a birthday, > > > last name, client ID (an integer less than 999999) or a phone number > > > (a number greater than 1000000) in order to select the desired client. > > > What is the best way to determine the type of data that was entered? > > > Is there a funtion that returns the data type? > > >> > > > > > > > > >

