Post your INCLUDE files here


+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924

    Default Post your INCLUDE files here

    Lester has provided a way to help document the user contributed INCLUDES.

    Please use the link below to submit your INCLUDE file.
    http://www.picbasic.co.uk/forum/misc.php?do=form&fid=1
    If you have already posted an INCLUDE here please submit it via the above link.

    Thank you.
    Last edited by mackrackit; - 17th September 2011 at 00:50.
    Dave
    Always wear safety glasses while programming.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Post your INCLUDE files here

    Contributed by Charles Linquist.

    Since people like INCLUDE files, here is one (KBNumberInput.bas) that some may find useful. It allows keyboard input of numbers, and unlike HSERIN [DEC x], it echoes each character and allows for backspaces to rub out errors.

    If the var ALLLOWSIGN is set to 1, it will accept a "-" or a "+" in the first position. You can also set the maximum number of chars that the user is allowed to input. If no input is received within a certain period of time (also user settable), the file exits with a RESULT of 0. The program has defaults, but can be over-ridden by setting any of them before calling the routine.

    I have included a little test program (GetNumber.bas) that explains the use.
    KBNumberInput.bas
    Code:
    ;---------------------------------------------------------------------
    ; Numeric Input Routine by Charles Linquist
    ; Set MaxNum to maximum number of digits you will take (default = 5)
    ; Set KInputTimeout to the number of secs you will wait before giving up.
    ; If you will accept a sign ("+" or "-") then set AllowSign to 1 in your
    ; program it will over-ride these values
    ; 
    ; RESULT is , well, the result.
    
            Keyin var byte
            Maxnum var byte
            YY var word
            POSN var byte
            IsNeg var bit
            AllowSign var bit
            TimedOut var bit
            KInputString var byte [10]
            KResult Var word
            KInputTimeout var Word
            XN var byte
    
            BS CON 8
            ESC cON 27
            LF con 10
            SP con 32
            CR con 13
            MaxNum = 5
            KInputTimeout = 10000 ; 10 sec
            AllowSign = 0
            
            goto OverKInput 
            
            
    GetNum:
           
            KResult = 0
            YY = 1
            POSN=0
            IsNeg = 0
            TimedOut = 0
            ArrayWrite KInputString,[Rep $FF\8]  ; Fill with $FF
     
    GetMoreN:              
            HSERIN KInputTimeout,DeadAtKeyboard,[Keyin]
                IF Keyin = ESC THEN ZeroNum
                If Keyin = CR THEN DunInputn
                If AllowSign then
                IF Posn = 0 THEN 
                  If Keyin = "-" THEN
                      IsNeg = 1
                      Hserout ["-"]
                      goto GetMoreN
                   endif    
                   if Keyin = "+" then
                      Hserout ["+"]   
                      goto GetMoreN
                   endif   
                ENDIF 
                endif   
                IF Keyin = BS THEN
                   HSEROUT [BS,SP,BS]
                   IF POSN > 0 THEN
                      POSN = POSN - 1
                      KInputString [POSN] = $FF
                      GOTO GetMoreN
                   ENDIF   
                ENDIF
            iF POSN >= MaxNum THEN goto DunInputN    
            IF Keyin < "0" or Keyin > "9" THEN GetMoreN 
            HSEROUT [Keyin]
            KInputString [POSN] = Keyin - "0"
           
            POSN = POSN +1
            GOTO GetMoreN
    DunInputN:
            For xN = 7 to 0 STEP - 1 
               IF KInputString[XN]= 255 THEN NoMoreNum
                KResult = KResult + (KInputString[xN]*YY)
                YY = YY *10
    NoMoreNum:            
            Next XN
            
            If Isneg then
              If Kresult < 32768 then
                   KResult = 0 - KResult
              else
                   hserout [CR,LF,"Error",CR,LF]
                   goto zeronum
              endif          
            endif  
            Return
            
    DeadAtKeyboard:        
            TimedOut = 1
    ZeroNum:
            KResult = 0
            RETURN 
         
    
    OverKInput:
    GetNumber.bas
    Code:
    '**************************************************************** 
    '*  Name    : Number Input routine                             *
    '*  Author  : Charles Linquist                                  *
    '*  Notice  : 2011 Charles Linquist               *
    '*          : All Rights Reserved                               *
    '*  Date    : 9/13/2011                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : For the forum                                     *
    '*          :                                                   *
    '****************************************************************
    
            DEFINE OSC 40                                                           
            DEFINE NO_CLRWDT 1
            DEFINE _18F8723 1
            DEFINE HSER_RCSTA 90H
            DEFINE HSER_TXSTA 20H                                                   
            DEFINE HSER_CLROERR 1
            define HSER_BAUD 9600
    
           
    
    
    
            TRISC = %10111111  ; Just for the serial port
            
     ;       The following vars are created by the include and may be changed before using
     ;       the structure  GOSUB GetNum
     ;    
     ;       MaxNum    - default = 5
     ;       KInputTimeout  - default = 10000 = 10 sec
     ;       AllowSign   - default = 0 ("no")
     ;
     ;       The result is returned in the WORD var KRESULT
            
            include "kbnumberinput.bas"
    
    topp:        
          
            
       hserout [CR,Lf,"Input a number "]
       gosub getnum
       hserout [CR,LF,"You entered "]
       
       IF isneg = 1 then 
          Hserout [SDEC KResult,CR,LF]
        ELSE
          hserout [dec KResult,CR,LF]
        ENDIF  
       
       Goto topp
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Post your INCLUDE files here

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: Post your INCLUDE files here

    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default Re: Post your INCLUDE files here

    Lester has provided a way to help document the user contributed INCLUDES.

    Please use the link below to submit your INCLUDE file.
    http://www.picbasic.co.uk/forum/misc.php?do=form&fid=1
    If you have already posted an INCLUDE here please submit it via the above link.

    Thank you.
    Dave
    Always wear safety glasses while programming.

Members who have read this thread : 4

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts