You might consider using a combination of implicit data typing as described in 
section 2.3.1 of the Programming In R:BASE manual and the CVTYPE function.

2.3.1 Implicit Data Typing
In addition to defining a variable value, the SET VARIABLE command is used to 
establish the data type
of a variable. Quite often the data type is implied by the variable contents.
R:BASE uses the following rules in the order listed to determine the implicit 
data type of a variable.
· A TEXT data type results if the variable has more than 30 characters or has 
zero characters (null
variable).
· An INTEGER data type results if a variable value is a non-decimal number and 
has nine or less
digits.
· A DOUBLE data type results if the variable value is numeric with 15 or less 
digits and one of the
following:
· The variable value contains a decimal point
· The variable value is a decimal point (interpreted as 0.0)
· The variable value is in scientific notation using a decimal point (for 
example, 1.0E6)
· A DATE data type results if the variable value matches the current date input 
format and contains a
valid date value.
· A TIME data type results if the variable value matches the current time input 
format and contains a
valid time value.
· A DATETIME data type results if the variable value matches the current 
date/time input format and
contains a valid date / time value.
· A CURRENCY data type results if either of the following is true:
· The variable value contains the current currency symbol followed by numerals
· The value is 10 to 17 numeric places
· A TEXT data type results if the variable value cannot be assigned any other 
data type based on the
above rules

 Jim Bentley
American Celiac Society
[email protected]
tel: 1-504-737-3293



----- Original Message ----
From: MikeB <[email protected]>
To: RBASE-L Mailing List <[email protected]>
Sent: Sat, October 31, 2009 1:08:54 PM
Subject: [RBASE-L] - Re: How do I check the data type of user entered data?

> IF vslashchk = 0 and vdashchk = 0 and vlengthchk >= 7 and vdigitchk = 1 THEN
>  GOTO phone
> ENDIF

Couldn't there be a dash in a phone #.  I have done: (999)999-9999  and 
999.999.9999 and 9999999999.  I am sure others have done variations on this.
I was part of a small discussion on this issue at the conference.  Phone 
numbers can be real pissers.  In your case, I might just check for digits and 
if TRUE, then count digits to be certain there are 10.  You might use SSUB and 
SLEN to march through the characters, counting the occurances of digits.

----- Original Message ----- From: "Michael J. Sinclair" <[email protected]>
To: "RBASE-L Mailing List" <[email protected]>
Sent: Saturday, October 31, 2009 1:58 PM
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?
>> > >>
>> > >
>> >
>> >
>> 
>> 
> 


--------------------------------------------------------------------------------


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?
> > >>
> > >
> >
> >
>
> 





Reply via email to