PRB: TYPE Function Does Not Indicate Character(Binary) (157194)
The information in this article applies to:
- Microsoft Visual FoxPro for Windows 5.0
- Microsoft Visual FoxPro for Windows 6.0
This article was previously published under Q157194 SYMPTOMS
The TYPE() function does not differentiate between Character and
Character(binary) or Memo and Memo(binary) field types. The Type() function
simply returns a "C" or an "M," respectively.
WORKAROUND
Use the AFIELDS() function to create an array that contains information on
each field in the table. The procedure listed below, bin_fld, contains code
that determines whether a character or memo field is binary. Before
executing this code, issue the CREATE TABLE syntax provided in step 1 of
the "Steps To Reproduce Behavior" section below.
- Create a program called Test that contains the following code:
**** Begin Program Example ****
PROC bin_fld
PARAMETER a
IF TYPE(a)= "C" OR TYPE(a) ="M"
=AFIELDS(test)
IF ASCAN(test,UPPER(a)) > 0
fldtype=ASCAN(test,UPPER(a))+1
IF test(ASCAN(test,UPPER(a))+5)=.T.
retvalu= "Field Type: "+ test[fldtype]+ " Binary"
ELSE
retvalu= "Field Type: "+ test[fldtype]+ ' Not Binary'
ENDIF
ENDIF
ELSE
retvalu= TYPE(a)
ENDIF
RETURN retvalu
**** End program example ****
- Type SET PROCEDURE TO Test in the Command window.
- Type ? Bin_fld("memo1") in the Command window.
The values returned from the bin_fld procedure for character and memo
fields indicate not only the field's type but also whether the field is
binary.
The AFIELDS() function creates an array with specific information on each
field in a chosen table. For example, the sixth element of the array
created by the AFIELDS() function shows whether code page translation is
allowed. This field contain a true (.T.) or false (.F.) value. If this
element contains a true value in a Character or Memo field type, the field
is binary. The TYPE() command handles any other field types. Entry of a
nonexistent field name produces a "U," indicating undefined.
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 10/15/2003 |
---|
Keywords: | KB157194 |
---|
|