HP Forums
An HP71 does not like F as a variable - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: An HP71 does not like F as a variable (/thread-20966.html)



An HP71 does not like F as a variable - waspentalive - 12-11-2023 03:32 AM

1030 F=2
run
ERR L1030:Data Type

>F=0
ERR:Data Type

Replace F with J throughout my program - now it works?? Why is there a problem with a variable named "F"


RE: An HP71 does not like F as a variable - rprosperi - 12-11-2023 01:01 PM

Was a function previously defined as in DEF FNF={some equation} ?

F is commonly used in examples in the manuals, etc. and so is then also commonly used when writing programs when folks are creating initial 71B programs.


RE: An HP71 does not like F as a variable - Valentin Albillo - 12-11-2023 03:53 PM

(12-11-2023 03:32 AM)waspentalive Wrote:  1030 F=2
run
ERR L1030:Data Type

>F=0
ERR:Data Type

Replace F with J throughout my program - now it works?? Why is there a problem with a variable named "F"

Variable F already existed as a different type, say a matrix, so trying to use it as an scalar is doomed to fail. Simply execute DESTROY ALL either from the command prompt or as the very first executable statement in a program and afterwards you may use F to your heart's content.

The takeaway: always include DESTROY ALL as the first executable statement in your programs, like this:

10 DESTROY ALL

See if that helps.

V.


RE: An HP71 does not like F as a variable - cruff - 12-12-2023 02:43 AM

Using F as a scalar variable works fine on my 71.


RE: An HP71 does not like F as a variable - Paul Dale - 12-12-2023 05:35 AM

The error message could definitely be more informative.
Likewise, why shouldn't the assignment just work?


RE: An HP71 does not like F as a variable - J-F Garnier - 12-12-2023 08:27 AM

(12-12-2023 05:35 AM)Paul Dale Wrote:  The error message could definitely be more informative.

I agree, for beginners. But once you know it, it's clear: one or both parts of the assign operation are not of the right types.
The error message could be "Not Scalar Type", but I'm not sure it would help beginners so much.

Quote:Likewise, why shouldn't the assignment just work?

Well no. In classic BASIC, you can assign a scalar value to an entire array only with:
MAT F=(2)

However, you can directly do, Z being a COMPLEX type variable:
Z=2
instead of an explicit Z=(2,0)
because the complex type is considered as a scalar type (in opposition to arrays) so implicit real to complex type conversion is possible.
The opposite (complex to real conversion) is not possible : -> Data Type error.

J-F


RE: An HP71 does not like F as a variable - Paul Dale - 12-12-2023 09:49 AM

I agree that assigning the scalar to the entire array isn't sensible. However, F=2 should replace the array with a scalar.

The praxis of "least surprise" really ought to apply.


Pauli


RE: An HP71 does not like F as a variable - toml_12953 - 12-12-2023 08:53 PM

(12-12-2023 09:49 AM)Paul Dale Wrote:  I agree that assigning the scalar to the entire array isn't sensible. However, F=2 should replace the array with a scalar.

The praxis of "least surprise" really ought to apply.


Pauli

Does the HP71 have strict typing (an anathema to us old BASIC programmers)? If so then you can't assign a different type of data to a variable unless you re-initialize the variable in some way (in HP71-speak, DESTROY?)

If the HP71 is consistent, then this should throw an error instead of truncating or rounding:

INTEGER X
X=5.7

See the bottom of page 59 of this document:
https://holyjoe.net/HP71/HP71BME.pdf


RE: An HP71 does not like F as a variable - rprosperi - 12-13-2023 01:04 PM

(12-12-2023 08:53 PM)toml_12953 Wrote:  Does the HP71 have strict typing (an anathema to us old BASIC programmers)? If so then you can't assign a different type of data to a variable unless you re-initialize the variable in some way (in HP71-speak, DESTROY?)

If the HP71 is consistent, then this should throw an error instead of truncating or rounding:

INTEGER X
X=5.7

Doing that on a 71B does not show an error, it sets the value of X to be equal to 6 (the integer value closest to 5.7), which is a whole lot more useful than an error message. I don't think that's inconsistent, I think that was darned clever of the designers.


RE: An HP71 does not like F as a variable - vaklaff - 12-13-2023 01:52 PM

(12-13-2023 01:04 PM)rprosperi Wrote:  Doing that on a 71B does not show an error, it sets the value of X to be equal to 6 (the integer value closest to 5.7), which is a whole lot more useful than an error message. I don't think that's inconsistent, I think that was darned clever of the designers.
It may be darned clever and useful and practical and convenient - yet inconsistent. I agree with toml_12953. Not that it matters half a century after the fact :-)