home *** CD-ROM | disk | FTP | other *** search
/ Programming Tool Box / SIMS_2.iso / compiler / sample6.bas < prev    next >
BASIC Source File  |  1993-06-21  |  5KB  |  266 lines

  1.  
  2. rem
  3. rem Here is a demonstration of buttons that does not require Windows
  4. rem
  5. rem Dumb terminal program
  6. rem
  7.  
  8.  
  9.   rem
  10.   rem is there mouse
  11.   rem
  12.   mouseflag=mouseon
  13.  
  14.  
  15.   rem
  16.   REM
  17.   REM LAYOUT SCREEN
  18.   REM
  19.   CLS
  20.  
  21.   rem
  22.   rem make red bar at top
  23.   rem
  24.   color 7,4
  25.   locate 1,1
  26.   print space$(80);
  27.   locate 2,1
  28.   print space$(80);
  29.   locate 3,1
  30.   print space$(80);
  31.  
  32.   if mouseflag<>0 then
  33.  
  34.     rem
  35.     rem make my push buttons
  36.     rem
  37.     CBUTTON "Exit",1068,0,"Push",0,1,1,8,3,7,1
  38.     CBUTTON "Hangup",1059,0,"Push",0,71,1,10,3,7,1
  39.  
  40.     rem
  41.     rem make and turn on correct radio buttons
  42.     rem
  43.     cbutton " Full Duplex",1060,0,"Radio",0,12,1,13,1,7,4
  44.     cbutton " Half Duplex",1061,0,"Radio",0,12,2,13,1,7,4
  45.     Radioon 1061
  46.     cbutton " 8 data bits",1062,0,"Radio",0,27,1,13,1,7,4
  47.     cbutton " 7 data bits",1063,0,"Radio",0,27,2,13,1,7,4
  48.     Radioon 1062
  49.     cbutton " 2400 baud",1064,0,"Radio",0,42,1,12,1,7,4
  50.     cbutton " 1200 baud",1065,0,"Radio",0,42,2,12,1,7,4
  51.     cbutton " 300 baud",1066,0,"Radio",0,42,3,12,1,7,4
  52.     Radioon 1065
  53.  
  54.   else
  55.  
  56.     rem
  57.     rem make my push buttons
  58.     rem
  59.     CBUTTON "F10-Exit",1068,0,"Push",0,1,1,10,3,7,4
  60.     CBUTTON "F1-Hangup",1059,0,"Push",0,68,1,13,3,7,4
  61.  
  62.     rem
  63.     rem make and turn on correct radio buttons
  64.     rem
  65.     cbutton " F2-Full",1060,0,"Radio",0,12,1,13,1,7,4
  66.     cbutton " F3-Half",1061,0,"Radio",0,12,3,13,1,7,4
  67.     Radioon 1061
  68.     cbutton " F4-8 data",1062,0,"Radio",0,27,1,13,1,7,4
  69.     cbutton " F5-7 data",1063,0,"Radio",0,27,2,13,1,7,4
  70.     Radioon 1062
  71.     cbutton " F6-2400",1064,0,"Radio",0,42,1,12,1,7,4
  72.     cbutton " F7-1200",1065,0,"Radio",0,42,2,12,1,7,4
  73.     cbutton " F8-300",1066,0,"Radio",0,42,3,12,1,7,4
  74.     Radioon 1065
  75.   end if
  76.  
  77.   rem
  78.   rem default states
  79.   rem
  80.   fullhalf=1061
  81.   bits$="8,"
  82.   parity$="N,"
  83.   speed$="1200,"
  84.   stop$="1,"
  85.  
  86.   rem
  87.   rem define scrollable area (so it doesn't scroll buttons)
  88.   rem
  89.   scrollarea 1,4,80,25
  90.   color 7,0
  91.   locate 4,1
  92.  
  93.  
  94.   rem
  95.   rem open communications port
  96.   rem
  97.    open "com2:"+speed$+parity$+bits$+stop$ for random as #1 len=2048
  98.  
  99.    rem
  100.    rem misc.
  101.    rem
  102.    lf$=chr$(10)
  103.  
  104. 100
  105.  
  106. rem
  107. rem get input from communications port
  108. rem
  109. rem
  110. rem Strip out LF characters
  111. rem
  112.  
  113.   t = LOC(1)
  114.   IF t > 0 THEN
  115.     a$=input$(t,1)
  116.     if len(a$)>0 then
  117. nocr:
  118.       if lastchar$=chr$(13)
  119.         l=len(a$)
  120.         t=instr(a$,lf$)
  121.         if t>0 then
  122.          if l>1 then
  123.           a$=left$(a$,t-1)+right$(a$,l-t)
  124.           goto nocr
  125.          else
  126.           goto 100
  127.          end if
  128.         end if
  129.      end if
  130.      PRINT a$;
  131.      lastchar$=a$
  132.     ELSE
  133.  
  134.       rem come here if some kind of comm error
  135.     end if
  136.  
  137.  
  138.   END IF
  139.  
  140.  
  141.  
  142. rem
  143. rem get input from keyboard
  144. rem
  145.  
  146.   b$ = INKEY$
  147.  
  148.  
  149.   IF b$ <> "" THEN
  150.  
  151.     rem
  152.     rem look for function keys
  153.     rem
  154.  
  155.     if len(b$)>1 then
  156.  
  157.       if asc(right$(b$,1))=68 then
  158.  
  159.          rem
  160.          rem F10 exit
  161.          rem
  162.          close #1
  163.          stop
  164.  
  165.       elseif asc(right$(b$,1))=59 then
  166.  
  167.          rem
  168.          rem F1- Hangup
  169.          rem
  170.          beep             :rem positive sign button was pushed
  171.          print #1,"+++";
  172.          for t=0 to 4000
  173.          next t
  174.          print #1,"ATH";chr$(13);
  175.  
  176.       elseif asc(right$(b$,1))=60 then
  177.          rem
  178.          rem make full duplex
  179.          rem
  180.          fullhalf=0
  181.          Radiooff 1061
  182.          Radioon 1060
  183.  
  184.       elseif asc(right$(b$,1))=61 then
  185.          rem
  186.          rem make half duplex
  187.          rem
  188.          fullhalf=1
  189.          Radiooff 1060
  190.          Radioon 1061
  191.  
  192.       elseif asc(right$(b$,1))=62 then
  193.          rem
  194.          rem make 8 data bits
  195.          rem
  196.          bits$="8,"
  197.          parity$="N,"
  198.          stop$="1,"
  199.          Radiooff 1063
  200.          Radioon 1062
  201.          setcom 1,","+parity$+bits$+stop$
  202.  
  203.       elseif asc(right$(b$,1))=63 then
  204.          rem
  205.          rem make 7 data bits
  206.          rem
  207.          bits$="7,"
  208.          Parity$="E,"
  209.          stop$="1,"
  210.          Radiooff 1062
  211.          Radioon 1063
  212.          setcom 1,","+parity$+bits$+stop$
  213.  
  214.       elseif asc(right$(b$,1))=64 then
  215.          rem
  216.          rem make 2400 baud
  217.          rem
  218.          speed$="2400,"
  219.          Radiooff 1065
  220.          Radiooff 1066
  221.          Radioon 1064
  222.          setcom 1,speed$
  223.  
  224.       elseif asc(right$(b$,1))=65 then
  225.          rem
  226.          rem make 1200 baud
  227.          rem
  228.          speed$="1200,"
  229.          Radiooff 1064
  230.          Radiooff 1066
  231.          Radioon 1065
  232.          setcom 1,speed$
  233.  
  234.       elseif asc(right$(b$,1))=66 then
  235.          rem
  236.          rem make 300 baud
  237.          rem
  238.          speed$="300,"
  239.          Radiooff 1064
  240.          Radiooff 1065
  241.          Radioon 1066
  242.          setcom 1,speed$
  243.  
  244.  
  245.       end if
  246.  
  247.       goto 100
  248.  
  249.     else
  250.  
  251.       if fullhalf=0 then
  252.          print b$;
  253.       end if
  254.       PRINT #1, b$;
  255.  
  256.     end if
  257.  
  258.   END IF
  259.  
  260.   GOTO 100
  261.  
  262.  
  263.  
  264.  
  265.  
  266.