Main Menu

KB#00641-Possible cause of an !Error 46 when attempting to write to an MKEYED file

Title:

Possible cause of an !Error 46 when attempting to write to an MKEYED file

Description:

Consider the following MKEYED statement: 

MKEYED "mk",[1:1:6],[2:1:10],0,136 

This should work fine, however notice that we are defining a second field in the second key here. With that second field defined, it is required that we identify that second field. Without the file being able to identify that second field you will get an error 46. 

Consider the following with the above file created. 

a$="NAME:c(6),ID:c(10),ANY:c(120)" 
DIM b$:a$ 
B.NAME$="ROBERT" 
B.ID$="0000012345" 
B.ANY$="This could be just about anything" 

OPEN (1)"mk" 
WRITE RECORD (1)B$ 

This produces an !ERROR=46 

The reason is because there are no delimiters here so that the file can not distinguish between field 1 and field 2 (which we defined in the MKEYED statement).

Resolution:

To correct this we can do one of two things. First, we can change the way the keys are organized in the file: 

MKEYED "mk",[1:1:6],[1:7:10],0,136 

Note that this only defines one field now. The other method is to change the string template so that it includes delimiters: 

a$="NAME:c(6*),ID:c(10),ANY:c(120)" 

Note that the (6*) defines a variable length field with a field terminator at the end. Either of these will correct the error 46 and which one you use depends on the situation and what you are trying to do.



Last Modified: 07/27/1998 Product: PRO/5 Operating System: N/A Error Number: 46

BASIS structures five components of their technology into the BBx Generations.

  Google+ View BASIS LinkedIN Profile Visit our Twitter Feed Check out our Facebook Public Profile Click to View the BASIS youTube channel