HP Forums
HP-71B IMAGE and PRINT USING - 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: HP-71B IMAGE and PRINT USING (/thread-15309.html)



HP-71B IMAGE and PRINT USING - Garth Wilson - 07-04-2020 09:50 PM

I need to resurrect an HP-71 program that I wrote in the 1990's. I apparently neglected to store it on tape (yes, my tape drive and all my tapes still work perfectly); but I had a printout, so I keyed it back in. Perhaps the printout was from before the last bug was fixed—at this point I have no idea—but I did successfully use the program many times in the past.

However now I get an "Invalid IMAGE" error message. As any serious 71 user knows, IMAGE lines (or image strings used in PRINT USING statements) do not get checked upon entry like other program lines do. I've never had any trouble understanding the extremely well written manuals, except for the IMAGE pages in the reference manual, pages 136 to 150! What an incomprehensible mess! I've tried lots of small changes in my image, yet it's still a no-go. Hopefully someone here can tell me what I'm doing wrong.

'IMG': is just a label, and I'm not using a line starting with IMAGE since the image is too long for one line; so I form it in pieces in I$ which is dimensioned for 150 characters. The CHR$(248) is the degree symbol in the DOS/ANSI character set which I have also installed on the 71 for use with any Epson dot-matrix impact printer which used to be ubiquitous. Here's what I have now:

[attachment=8600]

Here's a sample printout I was getting before when it worked, although I could get rid of the parentheses and commas (the commas aren't in the right place anyway, but that's minor):

[attachment=8601]

In all the years I've been on this forum, this is the first time I have asked for any programming help. Thanks for any help you can give.

Uh-oh, the attachments don't show in the preview. Hopefully they will in the post.


RE: HP-71B IMAGE and PRINT USING - rprosperi - 07-04-2020 11:02 PM

I suspect the problem is this: "'&CHR$(248)&'" which is intended to insert the degree symbol.

As written, it would seem to be trying to treat the entire '&CHR$(248)&' as a literal string, when I think you are simply trying to append CHR$(248).

Also, consider using the "B" Special Output Symbol - it may be easier to use in this complex image string.


RE: HP-71B IMAGE and PRINT USING - Garth Wilson - 07-05-2020 01:12 AM

Thanks. I should have mentioned that it sends the printer the 500Hz V3= and then seems to choke on the ,SDD.D, . I'm having trouble understanding when the commas are needed and when they're not. In the middle of page 146 of the reference manual, there's the example, 100 IMAGE DDD" dollars and "DD" cents.",2XK"day" .

Regarding the CHR$(248), I originally had deg in there rather than the degree symbol (and it didn't work then either) but I replaced it with what I posted above. It is confusing with the double quote marks in the image string itself and the single quote marks used in the process of forming I$ which contains the image. The ' (single quote) at the beginning ends the section that started with I$=' ... IOW, these are bracketing the parts before and after the &CHR$(248)& , not the degree-symbol portion. That's might be most clear at the end of the first line with the &'",4X,' (Note the single quote followed immediately by the double quote. The complementary double quote is later in the I$ as it continues getting formed on the next line.)

Your suggestion for the B option does look easier though. I'll try that.

I totally forgot about the math pac's C(,) addition to the image capabilities, for complex numbers. That is no doubt where I got what I had in the original form of the program. It's on the bottom of page 22 of the math pac manual. I had wondered why I had that in there, and I removed it.


RE: HP-71B IMAGE and PRINT USING - rprosperi - 07-05-2020 02:09 AM

Regarding where the commas are needed, I think the rule is basically you should have a comma in the image string corresponding with each comma in the argument list being displayed/printed/written; in other words in both the string and argument list, the commas equally delimit the respective fields.

I understand now what you explained about the single quotes. It's not clear to me how to insert CHR$(N) into a format string, hence my suggestion for using B.

And I must agree, this section of the manual is not at all well written. By it's nature, this stuff is tedious and persnickety and not easy to describe, but that's all the more reason they should have taken extra pains to document this more clearly and with many more complex and illustrative examples.

Please do explain the solution you eventually find, and feel free to ask more, it's interesting.


RE: HP-71B IMAGE and PRINT USING - J-F Garnier - 07-05-2020 08:32 AM

Hi Garth, I entered your statements and they seem to work as expected:

Code:
10 DIM I$[256]
790 'IMG': I$='6D.D,"Hz    V3=",SDD.D,"dB ",S3D,"'&CHR$(248)&'",4X,'
795 I$=I$&'"V6=",SDD.D,"dB ",S3D,"'&CHR$(248)&'",'
800 I$=I$&'4X,"V6-V3=",SDD.D,"dB ",S3D,"'&CHR$(248)&'",'
805 I$=I$&'"   V7=",SDD.D,"dB ",S3D,"'&CHR$(248)&'"'
820 PRINT USING I$;250,2,-13,4,-27,2,-14,-0,-44

   250.0Hz    V3= +2.0dB  -13ø    V6= +4.0dB  -27ø    V6-V3= +2.0dB  -14ø   V7= -0.0dB  -44ø

Note that the result doesn't exactly match your sample printout.

PRINT USING is one of the most complex and confusing feature of the HP BASIC in general (not only the HP-71B).

J-F


RE: HP-71B IMAGE and PRINT USING - rprosperi - 07-05-2020 01:45 PM

Possibly I$ was not initially allocated large enough? The OP says it was dimensioned to 150 chars, but JFG's at 256 works. Maybe it's that simple?


RE: HP-71B IMAGE and PRINT USING - J-F Garnier - 07-05-2020 02:30 PM

(07-05-2020 01:45 PM)rprosperi Wrote:  Possibly I$ was not initially allocated large enough? The OP says it was dimensioned to 150 chars, but JFG's at 256 works. Maybe it's that simple?
No, 150 char dim works as well and the image fields are correct for real values.
The problem is that a complex image field C(..,..) must be used if complex variables are used.
But I'm sure Garth already figured it out :-)

[Added:]
Here is a compact solution with complex fields and values:
Code:
10 DIM I$[150]
155 I$='6D.D,"Hz ",4(3X,K,C(SDD.D,"dB",S3D,"'&CHR$(248)&'"))'
160 PRINT USING I$;250,"V3=",(2,-13),"V6=",(4,-27),"V6-V3=",(2,-14),"V7=",(-0,-44)

   250.0Hz    V3=( +2.0dB, -13ø)   V6=( +4.0dB, -27ø)   V6-V3=( +2.0dB, -14ø)   V7=( -0.0dB, -44ø)

J-F


RE: HP-71B IMAGE and PRINT USING - rprosperi - 07-05-2020 07:12 PM

(07-05-2020 02:30 PM)J-F Garnier Wrote:  
(07-05-2020 01:45 PM)rprosperi Wrote:  Possibly I$ was not initially allocated large enough? The OP says it was dimensioned to 150 chars, but JFG's at 256 works. Maybe it's that simple?
No, 150 char dim works as well and the image fields are correct for real values.
The problem is that a complex image field C(..,..) must be used if complex variables are used.
But I'm sure Garth already figured it out :-)

[Added:]
Here is a compact solution with complex fields and values:
Code:
10 DIM I$[150]
155 I$='6D.D,"Hz ",4(3X,K,C(SDD.D,"dB",S3D,"'&CHR$(248)&'"))'
160 PRINT USING I$;250,"V3=",(2,-13),"V6=",(4,-27),"V6-V3=",(2,-14),"V7=",(-0,-44)

   250.0Hz    V3=( +2.0dB, -13ø)   V6=( +4.0dB, -27ø)   V6-V3=( +2.0dB, -14ø)   V7=( -0.0dB, -44ø)

J-F

This all reminds me of FORTRAN FORMAT statements, back in the day....

Requiring complex variables for a complex field makes perfect sense of course; the full listing (or at least a summary of the variable types) would have been a handy hint.

I had completely forgotten about the C( , ) enhancement in the MATH ROM, though I should have noticed it when looking at the manual recently after seeing your update.

Thanks for the compact solution demonstrating the 4( ) multiplier.


RE: HP-71B IMAGE and PRINT USING - Garth Wilson - 07-07-2020 05:23 AM

Thanks everyone. It was a busy weekend with grandkids and all, but I was able to work on this more tonight, and got the output working and looking like I wanted. I was forgetting about some of the implications of mixing the complex numbers in there. I ended up with splitting each of them into two real numbers and displaying as such so they wouldn't show the parentheses, by doing REPT(V3), IMPT(V3), etc..