Microsoft KB Archive/120536

{| = ERR: Not a Numeric Expression =
 * width="100%"|

ID: Q120536

2.5x 2.6x 3.00 | 2.00 2.5x 2.6x

WINDOWS       | MS-DOS The information in this article applies to:
 * Microsoft Visual FoxPro for Windows, version 3.0
 * Microsoft FoxPro for Windows, versions 2.5x, 2.6x
 * Microsoft FoxPro for MS-DOS, versions 2.0, 2.5x, 2.6x

SYMPTOMS
You receive the error message "Not a numeric expression" after any of four types of @ ... GETs: buttons, radio buttons, popups, and list boxes.

CAUSE
The FoxPro for Windows "Developer's Guide" for versions 2.5x and 2.6x states on page B-26 that the error "Not a numeric expression" occurs when "An attempt was made to use the SUM command on a non-numeric field."

Another cause for this error message is using a variable that has not been initialized after being declared in a button, radio button, popup, or list box.

RESOLUTION
If a variable is declared, but not initialized, it contains the value of false (.F.). If you then use this variable as the variable for specific types of @ ... GET commands, you will see the "Not a numeric expression" error when you run the code.

The solution is to initialize the variable to a number, or to not declare the variable at all.

Steps to Reproduce Behavior
1. Place the following code in a program called TEST.PRG:

CLEAR RELEASE ALL PUBLIC var1, var2, var3, var4 DIMENSION myarray(4,1) myarray(1,1)="LIST1" myarray(2,1)="LIST2" myarray(3,1)="LIST3" myarray(4,1)="LIST4"

DEFINE WINDOW main AT 0,0; SIZE 17.875,70.286 ; FONT "MS Sans Serif", 8 ; FLOAT ; NOCLOSE ; MINIMIZE ; SYSTEM

ACTIVATE WINDOW main

@ 4.500,3.429 GET var1 ; PICTURE "@*HN BUTTON1; BUTTON2" ; SIZE 1.625,11.875,0.500 ; DEFAULT 1

@ 6.688,3.429 GET var2 ; PICTURE "@*RVN RADIO1; RADIO2" ; SIZE 1.063,7.750,0.250 ; DEFAULT 1

@ 1.375,42.857 GET var3 ; PICTURE "@^ POPUP1; POPUP2" ; SIZE 1.500,15.125 ; DEFAULT 1

@ 4.438,44.714 GET var4 ; PICTURE "@&N" ; FROM myarray ; SIZE 4.500,17.000 ; DEFAULT 1

READ CYCLE

RELEASE WINDOW main 2. Run the program. The "Not a Numeric Expression" error will occur. 3. Choose the Ignore button. The error will occur again for each @ ... GET

defined in the program. If you keep choosing Ignore, the program will run through to the end.

Workaround
There are two ways to resolve this problem:

 Remove the line "PUBLIC var1, var2, var3, var4" from the program, and run it again. It should work as expected. -or- After declaring them, initialize VAR1, VAR2, VAR3, and VAR4 to 1. The program should no longer display the error.