Post Reply 
An HP71 does not like F as a variable
12-11-2023, 03:32 AM
Post: #1
An HP71 does not like F as a variable
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"
Find all posts by this user
Quote this message in a reply
12-11-2023, 01:01 PM
Post: #2
RE: An HP71 does not like F as a variable
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.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
12-11-2023, 03:53 PM (This post was last modified: 12-11-2023 03:54 PM by Valentin Albillo.)
Post: #3
RE: An HP71 does not like F as a variable
(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.

  
All My Articles & other Materials here:  Valentin Albillo's HP Collection
 
Visit this user's website Find all posts by this user
Quote this message in a reply
12-12-2023, 02:43 AM
Post: #4
RE: An HP71 does not like F as a variable
Using F as a scalar variable works fine on my 71.
Find all posts by this user
Quote this message in a reply
12-12-2023, 05:35 AM
Post: #5
RE: An HP71 does not like F as a variable
The error message could definitely be more informative.
Likewise, why shouldn't the assignment just work?
Find all posts by this user
Quote this message in a reply
12-12-2023, 08:27 AM
Post: #6
RE: An HP71 does not like F as a variable
(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
Visit this user's website Find all posts by this user
Quote this message in a reply
12-12-2023, 09:49 AM
Post: #7
RE: An HP71 does not like F as a variable
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
Find all posts by this user
Quote this message in a reply
12-12-2023, 08:53 PM
Post: #8
RE: An HP71 does not like F as a variable
(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

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
12-13-2023, 01:04 PM
Post: #9
RE: An HP71 does not like F as a variable
(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.

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
12-13-2023, 01:52 PM
Post: #10
RE: An HP71 does not like F as a variable
(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 :-)
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 3 Guest(s)