Range
Result = Range(Value, LowerLimit, UpperLimit)
 
Parameters:

    Value=Value to test
    LowerLimit=The lower limit of the range
    UpperLimit=The upper limit of the range
Returns:

    Result
 

      Range() returns 1 if a value is within a given range else it returns 0.




FACTS:


      * A value is within a range even if it equals the upper or lower limits.


Example

This example uses range to detech is the mouse is within a box region on the screen



  
; Calculate Box position and dimension
  X1 = GetScreenWidth() / 2 - 20
  Y1 = GetScreenHeight() / 2 - 20
  X2 = X1 + 40
  Y2 = Y1 + 40
  
; White Color
  White = RGB(255,255,255)
  
; Red Colour
  Red = RGB(255,0,0)
  
  Repeat
   ; Clear the screen
     
     Cls RGB(0,10,20)
     
   ; Display message
     Print "Move the Mouse Over the Box"
     
     
   ; set the Box colour
     ThisCOlour=White
     
   ; Grab the current position of the mouse
     PointX=MouseX()
     PointY=MouseY()
     
   ; Check if X coored is within the Rect range
     If Range(PointX,X1,X2)
        If Range(PointY,Y1,Y2)
         ; change the box colour if the mouse is over it
           ThisCOlour=Red
        EndIf
     EndIf
     
   ; Draw a Box to the screen
   ; it'll should red when the mouse is over it and white
   ; when it's not
     BoxC X1, Y1, X2, Y2, 1, ThisColour
     
     Sync
  Until EscKey()
  
  


 
Related Info: ClipRange | ClipRange# | Comparisons | MidPoint | Operators | PointInBox | PointIntersectCircle | Swap :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com