home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / baslib2.zip / ASC-CHR.BAS next >
BASIC Source File  |  1987-03-27  |  2KB  |  86 lines

  1. 'ASC & CHR Function Demos By John Craig, Jeff Bretz
  2. 'Additional rwts & conversion toi Quickbasic 2.01 by Dennis Dreyer
  3. 'ASC-CHR.BAS
  4.  
  5. clear
  6. view print 1 to 7
  7. cls
  8. locate 2,30:Print    "                    "
  9. locate 3,30,0:Print "    ASC/CHR DEMO    "
  10. locate 4,30:Print " In Quickbasic 2.01 "
  11. locate 5,30:Print    "                    "
  12. color 1,4,1:locate 6,30:Print "                    "
  13. locate 1,30:Print "                    "
  14.  
  15. REPEAT:
  16. view print 8 to 24
  17. color 14,6:cls
  18. locate 9, 27,0: Print " Selection Demo you desire."
  19. locate 11,27:Print "1}    ASC Demonastration"
  20. locate 12,27:print "2}    CHR Demonastration"
  21. locate 13,27:print "3}    To Quit Program"
  22.  
  23. locate 15,27:input "Enter (1 or 2) and press <ENTER> :-> ",ANS
  24.  
  25. If ANS = 1 then  CALL PGMASC
  26. IF ANS = 2 then  CALL PGMCHR
  27. if ans = 3 then color 15,0,0:view print:cls:end
  28.  
  29. GOTO REPEAT
  30.  
  31. SUB PGMASC STATIC
  32. cls:Quote$=chr$(34)
  33.  
  34.  
  35. locate 10,25,0:Print "Demonstration of the ASC function,"
  36. locate 11,25,0:print "which produces the ASCII code number"
  37. locate 12,25,0:print "for any character.":print
  38. locate 14,25,0:print "Type any character ...":print
  39. locate 16,25,0:print "Press <ESC> key to return to menu."
  40.  
  41. GETT:
  42. K$=INKEY$
  43. if K$=chr$(27) then goto RRETURN
  44. if K$=chr$(13) then goto GETT
  45. if K$=chr$(10) then goto GETT:     ' {Traps Control M,L,Etc....
  46. if K$=chr$(12) then goto GETT
  47. if K$=chr$(11) then goto GETT
  48.  
  49. If K$ ="" then goto GETT
  50.  
  51.  
  52. view print 20 to 22
  53. cls
  54. locate 20,25,0:Print "ASC (";QUOTE$;K$;QUOTE$;") = ";ASC(K$);
  55. if len(K$) =2 then print ASC(right$(k$,1));
  56.  
  57. GOTO GETT
  58.  
  59. RRETURN:
  60. end sub
  61.  
  62.  
  63. SUB PGMCHR STATIC
  64. cls:Quote$=chr$(34)
  65.  
  66. locate 10,25,0:Print "Demonstration of the CHR$ function,"
  67. locate 11,25,0:print "which produces the character for"
  68. locate 12,25,0:print "any ASCII number (0 to 255).":print
  69. locate 14,25,0:print "Type any ASCII number ...":print
  70. locate 16,25,0:print "Press <0> key to return to menu."
  71.  
  72. GETTT:
  73. locate 20,25:INPUT "ASCII number & press <ENTER> ->: ";n
  74. if n <0 or N>255 or N <> int(N) then goto GETTT
  75. if N=0 then goto RRRETURN
  76.  
  77. view print 20 to 23
  78. cls
  79. locate 22,25:print "CHR$(";N;") = ";QUOTE$;CHR$(N);QUOTE$
  80.  
  81. GOTO GETTT
  82.  
  83.  
  84. RRRETURN:
  85. END SUB
  86.