Nice neat code posts


Closed Thread
Results 1 to 40 of 40

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Nice neat code posts

    I always have MCSP set to "convert tabs to spaces". I tried to attach my source but, it didn't "take". I'll send you a link instead.

    http://dl.dropbox.com/u/566712/GetNumber_part.bas
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default Re: Nice neat code posts

    Straight from the link...
    Who knows... but what browser do you use? It maybe something other than the code editor.
    Code:
    '**************************************************************** 
    '*  Name    : Number Input routine                             *
    '*  Author  : Charles Linquist                                  *
    '*  Notice  : Copyright (c) 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
    
           
    
            Keyin var byte
            Maxnum var byte
            YY var word
            POSN var byte
            IsNeg var bit
            AllowNeg var bit
            TimedOut var bit
            InputString var byte [10]
            Result Var word
            XN var byte
    
            BS CON 8
            ESC cON 27
            LF con 10
            SP con 32
            CR con 13
    
            TRISC = %10111111  ; Just for the serial port
    topp:        
           allowneg = 1
            
      hserout [CR,Lf,"Input a number "]
       gosub getnum
       hserout [CR,LF,"You entered "]
       
       IF isneg = 1 then 
          Hserout [SDEC Result,CR,LF]
        ELSE
          hserout [dec Result,CR,LF]
        ENDIF  
       
       Goto topp        
            
    
    GetNum:
            Result = 0
            MaxNum = 5     ; set for max number of digits you will accept
            YY = 1
            POSN=0
            IsNeg = 0
            TimedOut = 0
            ArrayWrite InputString,[Rep $FF\8]  ; Fill with $FF
     
    GetMoreN:              
            HSERIN 9000,InputTimeout,[Keyin]
                IF Keyin = ESC THEN ZeroNum
                If Keyin = CR THEN DunInputn
                If allowNeg then
                IF Keyin = "-" and Posn = 0 THEN 
                    IsNeg = 1
                    Hserout ["-"]
                    goto GetMoreN
                ENDIF 
                endif   
                IF Keyin = BS THEN
                   HSEROUT [BS,SP,BS]
                   IF POSN > 0 THEN
                      POSN = POSN - 1
                      InputString [POSN] = $FF
                      GOTO GetMoreN
                   ENDIF   
                ENDIF
            IF Keyin < "0" or Keyin > "9" THEN GetMoreN 
            HSEROUT [Keyin]
            InputString [POSN] = Keyin - "0"
            IF POSN >= (MaxNum -1) THEN DunInputN
            POSN = POSN +1
            GOTO GetMoreN
    DunInputN:
    
           More code here
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Nice neat code posts

    I guess next time I'll just send you my code and you can post it!
    Charles Linquist

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


    Did you find this post helpful? Yes | No

    Default Re: Nice neat code posts

    Quote Originally Posted by Charles Linquis View Post
    I guess next time I'll just send you my code and you can post it!
    OK, That will work too
    Dave
    Always wear safety glasses while programming.

  5. #5
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: Nice neat code posts

    Hey Dave,

    I went into my PIC files and found that way back when... I had saved a copy of the LCDbargraphs thread as a "web page complete".

    I looked at it and it looks complete. I have attached it. I wonder if you (or Darrel) can use it to rebuild that thread.

    If NOT then others can down load this attachment and they should be able to get the gist of the LCD bargraphs from it.
    (It coud be attached to that thread also as a downloadable file)

    here ya go...
    P.S. I had to zip it up because it was causing an error when I tried to upload the .mht file.
    Attached Files Attached Files
    Last edited by Heckler; - 14th September 2011 at 22:39.
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

  6. #6
    Join Date
    Dec 2005
    Posts
    1,073


    Did you find this post helpful? Yes | No

    Default Re: Nice neat code posts

    Anyone who wants to see it can unzip it and open it in Internet Explorer. It's probably viewable in other browsers - I just double-clicked and IE loaded the MHTML file.

    In fact, one can probably convert it to PDF or any other desired form.

  7. #7
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default Re: Nice neat code posts

    I normally use IE9. I'll try it with FireFox.
    Charles Linquist

Members who have read this thread : 0

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