?TYPE MISMATCH ERROR
Apple Apple II
Severity: MinorWhat Does This Error Mean?
?TYPE MISMATCH ERROR means you mixed up strings and numbers in an expression. You tried to add a string to a number, or use a string where a number is needed. Check variable types — names ending in $ are strings, others are numbers.
Affected Models
- Apple II
- Apple II Plus
- Apple IIe
- Apple IIc
- Apple IIGS
- AppleWin emulator
Common Causes
- Adding a string to a number (A$ + 5)
- Using a string variable where a number is expected
- Assigning a number to a string variable without STR$()
- Comparing a string with a number
- Passing the wrong variable type to a function
How to Fix It
-
Check variable types — $ means string.
A is a number. A$ is a string. They are different variables. Using the wrong one causes TYPE MISMATCH.
-
Use VAL() to convert strings to numbers.
If A$ contains "42", use VAL(A$) to get the number 42. This is needed when converting user input to a number for calculations.
-
Use STR$() to convert numbers to strings.
If you need to build a message with a number: PRINT "SCORE: " + STR$(S)
Frequently Asked Questions
Can A and A$ exist at the same time?
Yes. A (number) and A$ (string) are completely separate variables. They can have different values and exist simultaneously in the same program.
Does Applesoft BASIC support integer variables?
Applesoft BASIC has only floating-point numeric variables and string variables. Unlike some BASICs, it does not support integer variables with a % suffix.