79363402

Date: 2025-01-17 01:02:28
Score: 0.5
Natty:
Report link

All this dates back to the early days of QuickBasic (for DOS) where there was no direct concept of DataTyping your variables. i.e. you couldn't do: Dim A As Integer Instead, there were symbols to represent the different data types. As I recall, they were:

  1. $ for strings
  2. ! for single-precision numbers
  3. # for double-precision numbers
  4. % for standard integers
  5. & for long integers

You may have noticed that if you try to concatenate variables, like A&B, you get an error, but A &B works. What seems to be happening is that the archaic data-typing still exists, so it interprets A&B as "Take the long integer variable A, aka A&, and the untyped variable B and, oops...no operator between them so it's an error." If you were to use A&&B, it would work because that's interpreted as "Take the long integer variable A, aka A&, and concatenate it (&) with untyped variable B"

It seems that the "^" must also be included in that group of type symbols, although I don't recall ever running into it. By putting the space (or parentheses) before the symbol, it separates the variable from its archaic data type. Similar to &, it seems that doubling the ^ applies one as the data type for the first variable, then applies the power operate from the first to the second value. It's also why you can't use the ^ twice because it's like using ++ or // to add or divide.

So the answer is to always use a space before any symbol at the end of a variable to avoid this archaic interpretation.

Reasons:
  • Long answer (-1):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Rob Dogo Spahitz