Announcement

Collapse
No announcement yet.

RANGE as a RESERVED word

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

  • RANGE as a RESERVED word

    Hi all,
    I don't know if a RRESERVED word excess that would do what I will
    call RANGE. Where RANGE would set the limits, above and below a
    given value that would be acceptable. A sample statement might be:
    IF a = b RANGE(.001) THEN... This would be equivalent to:
    IF a < (b + .001) AND a > (b - .001) THEN... Also when comparing
    two strings the use of RANGE$(no.); where RANGE$(no.) would comp-
    are two strings of the same length and consider them acceptable
    if not more than (no.) of characters are different between the two
    strings. A sample statement might be: IF a$ = B$ RANGE$(1) THEN...
    For example my last name is KATZEL, but often people spell it
    CATZEL. If the above statement were used it would be acceptable.
    I notice in a number of spell checkers this being done along with a
    number of suggested correctly spelled words.
    Do such RESERVED words excess in PowerBASIC or is it possible
    to have them in future versions of PowerBASIC?
    Fred K

    ------------------

  • #2
    Sounds like an opportunity for a group of functions, actually.
    I'll put it on the wish list.

    ------------------
    Tom Hanlin
    PowerBASIC Staff

    Comment


    • #3
      Code:
      FUNCTION Range (A AS SINGLE, B AS SINGLE, Limit AS SINGLE) AS INTEGER
      
         IF ABS (B-A) <=Limit THEN
           RANGE = -1
         ELSE
           RANGE = 0
          END IF
      END FUNCTION
      
      IF RANGE (A, B, .001!) THEN.....
      MCM
      (Edit 7/02/01: added missing END FUNCTION)




      [This message has been edited by Michael Mattias (edited July 02, 2002).]
      Michael Mattias
      Tal Systems Inc. (retired)
      Racine WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        Not quite what Fred was looking for, I think-- although it's a good
        step along the way. A "real short" function like this may be better
        expressed as a MACRO, by the way (or may not be, but I'd normally
        lean in that direction).

        Code:
        MACRO range(a, b, limit) = (ABS(b - a) <= limit)
        Note that the macro isn't sensitive to what numeric types you've
        chosen. We're dealing with text substitution here.

        If you're old enough, you may remember DEF FN. This particular kind
        of macro works very much the same way.

        Michael, the reason your indentation is off is by way of having lost
        the END FUNCTION. Of course, one of the reasons proper indentation
        is such a Good Thing(TM) lies in how it makes such problems evident.
        Stick with the Proper Form, guys, it's not just a formality. It Will
        Help You. Let it!

        ------------------
        Tom Hanlin
        PowerBASIC Staff

        Comment


        • #5
          MACROs in PB/DOS? Can't find that in my manuals, and I've been using "the latest release" for about four years.

          Old enough to remember DEF FN? I'm a Truman baby, does that qualify? No? How about I can remember DEF USRn? (Not quite the same thing, but dissapeared before DEF FN). How about I remember when variable names could not begin with the letters, "F-N?" I still pause when I type "fname" ....

          MCM


          Michael Mattias
          Tal Systems Inc. (retired)
          Racine WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            No macros in PB/DOS, yet; but it does still support DEF FN. So:

            def fnrange(a, b, limit) = (ABS(b - a) <= limit)

            ------------------
            Tom Hanlin
            PowerBASIC Staff

            Comment

            Working...
            X