Announcement

Collapse
No announcement yet.

Who Knew This RE PB3.5? FUNCTION (params) AS TYPE

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Who Knew This RE PB3.5? FUNCTION (params) AS TYPE

    Greetings ...

    Who knew this about PB-3.5 DOS ??

    I purchased PB-3.5 DOS back in 1997. The two books that came with it (USERS, Reference) each stated that FUNCTIONs (FUNCTION / END FUNCTION, to be precise) did not return string-type data, and did not show any examples with the beginning line FUNCTION (Parameters) AS [TYPE]. However, in the program's built-in help section, the AS [TYPE] is mentioned, although it didn't specify what TYPEs were usable.

    For the longest time I didn't try to use FUNCTION/END FUNCTION to return anything other than simple numeric data. But when I got into using PBCC 4xx (and later 5xx) and discovered the versatility of FUNCTION/END FUNCTION therein, I decided to go back to PB-3.5 and experiment, using the following code ..
    Code:
    $Compile Memory
     CLS
     Color 15: ? "TEST";Rudder(11);Rudder(22): ?: ?
     END
    
     Function Rudder (GGAA) AS String
       IF GGAA=11 THEN Rudder=" One"+CHR$(35)
       IF GGAA=22 THEN Rudder=" Two"+CHR$(155)
     END Function
    Worked like a charm, giving me the result --- TEST One# Two¢

    The thing of it is that I never got any notice (or maybe just missed seeing it) that PB-3.5's FUNCTION/END FUNCTION could return strings. I wish I could've known it at the start, because so many possibilities were left untapped. Incredibly, there was a demo posted sometime after 1997, using a custom FUNCTION to incorporate row-col cursor positioning into PRINT statements and it did have "AS String". However, it did not then register in me the real significance of "AS String".

    Just two closing thoughts -- (1) Did anyone else not realize the enhanced versatility of PB3.5's FUNCTION/END FUNCTION until much later? (2) Was the printed documentation as well as the built-in IDE helper upgraded after 1997 to point out FUNCTION's enhanced capabilities?

    FUNCTION Thanx-A-Lot AS Very Humbled Gratitude
    Last edited by Frank Ferrell; 30 Oct 2018, 08:26 AM. Reason: Clarified FUNCTION as FUNCTION/END FUNCTION

  • #2
    Sorry, I do not remember a no strings limitation on FUNCTIONs in PBDOS. In fact string handling was a strong point of BASIC (not just PB). There would have been a 32K (maybe 65K) byte string length limit ((maybe even less!))

    I take it you have a Win XP, or older, PC to run PBDOS and compiled programs on?

    Now something else I don't remember. I use "?" as short for PRINT in PBCC, and short for MSGBOX in PBWin (makes it easier to write one demo for both). But I do not remember using "?" for PRINT in PBDOS. Did I type out PRINT more often than I had to?

    I think that if the documents (from the time) said no string return from a function, I'd remember that. So I do not think there was a change in documentation or IDE.

    Also at the time I had a program (DLL?) that helped (made possible?) using PBDOS to code for Windows 2, and or, 3. I do not remember the name, except it started with "Z". Back then I didn't associate that with the "Z" in Zale. Seems obvious now .

    Cheers,
    Dale

    Comment


    • #3
      Originally posted by Dale Yarker View Post
      Sorry, I do not remember a no strings limitation on FUNCTIONs in PBDOS. In fact string handling was a strong point of BASIC (not just PB). There would have been a 32K (maybe 65K) byte string length limit ((maybe even less!)) ... Cheers,
      My apologies -- I should have specificly stated that I was talking about FUNCTION/END FUNCTION. In the sections of the two accompanying books (Users, Reference) that I read regarding FUNCTION/END FUNCTION, I never saw any mention of "AS TYPE". However, "AS TYPE" is mentioned in the program IDE's help menu, but doesn't elaborate. At least my original copy didn't.

      Apparently --- and no one's fault I might add -- when the manuals were updated from PBDOS 3.2 to 3.5, the book editors for whatever reason omitted mention of "AS TYPE" as well as the fact that it allowed for FUNCTION/END FUNCTION to handle strings. Again, as I say the books don't mention "AS TYPE", the program IDE's help menu does. And I never received an addendum or was otherwise made aware of the "AS TYPE" enhancement. I programmed in PBDOS-3.5 for several years without realizing that the beauty of AS TYPE was hiding in plain sight.

      Comment


      • #4
        Page 138 of the PowerBASIC user guide from 1997 which includes references to PBDos3.5:
        "Function data types
        Functions can return any of the eleven numeric types .. as well as regular strings"

        Comment


        • #5
          Originally posted by Paul Dixon View Post
          Page 138 of the PowerBASIC user guide from 1997 which includes references to PBDos3.5:
          "Function data types
          Functions can return any of the eleven numeric types .. as well as regular strings"
          Thanks -- In my copy, page 139 shows an DEF FN example with "AS TYPE"

          The "11 numeric types as well as strings" mention occurs on page 142.

          However "AS TYPE" is not mentioned in association with FUNCTION/END FUNCTION on pg 143 of my copy. But now I see underneath that a sentence saying both numeric and string data can be returned. Still with no mention of "AS TYPE" in the User or Reference Guides (may an example elsewhere does and I just missed it) which actually were more detailed and easier to access and read versus the program IDE helper, I was in kind of a no man's land.

          Thanks for pointing this out. BTW -- the pages of my book copies are starting to peel, but I still have them all.

          Comment


          • #6
            I at one time had two copies of each of the two manuals, one from ver 3.2 and one from ver 3.5. Both just stated ver 3 on the title page. I remember thinking that I need not have ordered new manuals with the new compiler, but I did eventually find differences. There were a few differences so I wore out the earlier version. I still have the one I received second and it has no mention of the AS TYPE that I can find. I think I received the last manual before 1997. As for the PRINT or ?, page 218 of the reference manual mentions that feature as the last item before the See Also section under PRINT.
            Rod
            "To every unsung hero in the universe
            To those who roam the skies and those who roam the earth
            To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

            Comment


            • #7
              About The ? Question Mark used in place of PRINT --- That of course goes back to the original BASIC Interpreter versions. I had become familiar with the ? Mark using Commodore PET Basic. When QBASIC and QUICKBASIC arrived, they allowed the question mark to be written but then substituted PRINT when the next line was composed. PowerBASIC lets the ? mark stay "as is".

              Comment


              • #8
                I knew you were talking about FUNCTION/END FUNCTION.

                Paul and Rod either still have the books, or better memories.

                I guess I typed "PRINT" more than needed. Or didn't see the point if the IDE changed it.

                Cheers,
                Dale

                Comment


                • #9
                  I don't recall PB changing the ? to PRINT, but then I'd almost finished typing PRINT by the time I remembered the ? option. Still have Turbo Basic and the last two PB ver 3 manuals, but not a great memory! Prior to Turbo, I used Atari basic, and have no recollection of anything particular to it, except that there was something about bank switching. As in memory bank, not infiltrating.
                  Rod
                  "To every unsung hero in the universe
                  To those who roam the skies and those who roam the earth
                  To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

                  Comment

                  Working...
                  X