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
Bookmarks