>I am trying to creat a table from an array, but it is giving me error
>that "Unrecognized value".
>
>How can I creat this array?
>
>ccross(3,2) = "C"
>ccross(3,3) = "35"
>
>ccross(4,1) = "map_id"
>ccross(4,2) = "I"
>ccross(4,3) = 5
>ccross(4,4) = 0
>ccross(4,5) = .T.
>
>
>ccross(5,1) = "variable"
>ccross(5,2) = "C"
>ccross(5,3) = "15"
>
>
>
>
> CREATE TABLE CROSS FREE (crossw_id I,type_id I,DESCRIPT C(35),map_id I,variable C(15))
This statement actually creates a table, you've explicitly stated the parameters in the expression contained in the () portion of the command. You could add modifiers like NULL to fields within the expression as appropriate if you created the table as an exact line of code.
If you wanted to create an array whose columns were defined in an array cCross, you'd say:
CREATE TABLE Cross FREE FROM ARRAY cCross
cCross would need to be defined as an array of n Row of either 5 or 16 columns each (only 5 for a free table, 16 for a table as a part of a database), matching the format of AFIELDS() for values for each row as applicable. The columns are:
Column number Field info,Data type
1 Field name,Character
2 Field type:
C = Character
D = Date
L = Logical
M = Memo
N = Numeric
F = Float
I = Integer
B = Double
Y = Currency
T = DateTime
G = General
3 Field width, Numeric
4 Decimal places, Numeric
5 Null values allowed, Logical
6 Code page translation not allowed, Logical
7 Field validation expression, Character
8 Field validation text, Character
9 Field default value, Character
10 Table validation expression, Character
11 Table validation text, Character
12 Long table name, Character
13 Insert trigger expression, Character
14 Update trigger expression, Character
15 Delete trigger expression, Character
16 Table comment, Character
For free tables, the content of columns 6-16 are ignored if present. You might run into situations where the array was built with 16 columns where building a free table IAC if perhaps you started with an array created by the AFIELDS() function and then added or deleted rows to the array, or wanted to change some properties of the original array definition when creating another similar array using it as a start point.
You'd then fill it as appropriate. For example, to build a free table Temp1 with three columns, cCharFld10, C(10), iIntWNulls, an integer data field with nulls allowed, and NumFld6_2, N(6,2):
declare atemp(3,5)
atemp[1,1] = 'CharFld10'
atemp[1,2] = 'C'
atemp[1,3] = 10
atemp[2,1] = 'IntWNulls'
atemp[2,2] = 'I'
atemp[2,5] = .t.
atemp[3,1] = 'NumFld6_2'
atemp[3,2] = 'N'
atemp[3,3] = 6
atemp[3,4] = 2
create table temp1 from array atemp
display structure
this would make the same table as:
CREATE TABLE Temp1 (CharFld10 C(10), IntWNulls I NULL, NumFld6_2 N(6,2))
You may be able to use a 6 column array when creating a free table if there's a need to disable codepage translation for a particular field of a free table; I've never tried it, and normally run with code page translation disabled for all situations (SET COLLATE MACHINE) so the issue is unimportant for my applications - you need to disable codepage translation for character and memo fields where you intend to store binary data in them.