home *** CD-ROM | disk | FTP | other *** search
/ PC User 2001 August / APC_Aug2001_CD2.iso / features / devtools / files / lb202win.exe / LB202W.EXE / GRAFDEMO.BAS < prev    next >
Encoding:
BASIC Source File  |  2000-11-09  |  2.3 KB  |  99 lines

  1.  
  2.  
  3.     'This new version of grafdemo.bas takes advantage of the
  4.     'new !contents and !contents? commands, and it also uses
  5.     'an empty edit menu to place the default edit menu after
  6.     'File on the menu bar (a new LB feature).
  7.  
  8.     nomainwin
  9.  
  10.     texteditor #main.text, 10, 10, 175, 200
  11.     menu #main, "&File", "&Open File", [load], "&Save File", [save], "&Print Text", [print], |, "E&xit Grafdemo", [quit]
  12.     menu #main, "edit"
  13.     menu #main, "&Action", "&Draw Graphic", [go]
  14.     WindowWidth = 500 : WindowHeight = 265
  15.     open "Graf Demo" for graphics_nsb as #main
  16.     print #main, "when leftButtonDown [getPoint]"
  17.     print #main, "when rightButtonDown [menu]"
  18.     print #main, "trapclose [quit]"
  19.  
  20. [inputLoop]
  21.  
  22.     input r$ 
  23.     goto [inputLoop]
  24.  
  25. [go]
  26.  
  27.     print #main.text, "!lines" ;
  28.     input #main.text, lines
  29.     print #main, "cls" ;
  30.     for x = 1 to lines
  31.     print #main.text, "!line " ; x ;
  32.     input #main.text, line$ 
  33.  
  34.     if word$( line$, 1 ) = "times" and x < lines then
  35.         i = val(word$(line$, 2))
  36.         x = x + 1
  37.         print #main.text, "!line "; x ;
  38.         input #main.text, line$
  39.         for x = 1 to i
  40.             print #main, line$
  41.         next x
  42.     else
  43.         print #main, line$ ;
  44.     end if
  45.  
  46.     next x
  47.     print #main, "flush" ;
  48.     goto [inputLoop]
  49.  
  50. [getPoint]
  51.  
  52.     print #main.text, "place " ; MouseX ; " " ; MouseY
  53.     goto [inputLoop]
  54.  
  55. [load]
  56.  
  57.     filedialog "Load GrafDemo Text", "*.gdt", fname$
  58.     if fname$ = "" then [inputLoop]
  59.     open fname$ for input as #1
  60.     line$ = input$(#1, lof(#1))
  61.     print #main.text, "!contents line$";
  62.     close #1
  63.     goto [inputLoop]
  64.  
  65. [save]
  66.  
  67.     filedialog "Save GrafDemo Text", "*.gdt", fname$ 
  68.     if fname$ = "" then [inputLoop]
  69.     open fname$ for output as #1
  70.         print #main.text, "!contents?";
  71.         input #main.text, line$
  72.         print #1, line$
  73.     close #1
  74.     goto [inputLoop]
  75.  
  76. [print]
  77.  
  78.     print #main.text, "!lines";
  79.     input #main.text, lineCount
  80.     for x = 1 to lineCount
  81.         print #main.text, "!line "; x ;
  82.         input #main.text, lineOfText$
  83.         lprint lineOfText$
  84.     next x
  85.     dump
  86.  
  87.     goto [inputLoop]
  88.  
  89. [menu]
  90.  
  91.     popupmenu "&Draw Graphic", [go]
  92.     goto [inputLoop]
  93.  
  94.  
  95. [quit]   'exit grafdemo.bas
  96.  
  97.     close #main
  98.     end
  99.