home *** CD-ROM | disk | FTP | other *** search
/ Program Metropolis - Software Boutique 95 / SOFTWARECD.iso / pct2win / disk5 / writsamp.sc_ / WRITSAMP.SCT
Encoding:
Text File  |  1994-01-12  |  3.6 KB  |  138 lines

  1. ;;;;;;;;;;
  2. ;;  Write Demo - WRITSAMP.SCT
  3. ;;    Version 1.0
  4. ;;
  5. ;;    Copyright 1993 Central Point Software, Inc.
  6. ;;
  7. ;;Purpose:
  8. ;;        To demonstrate the use of the Write application with ScriptTools
  9. ;;
  10. ;;Commands Used:
  11. ;;        Messagebox(
  12. ;;        Running(
  13. ;;        Attach
  14. ;;        ComboBox
  15. ;;        ComboText
  16. ;;        Exec
  17. ;;        Exit
  18. ;;        If
  19. ;;        MenuSelect
  20. ;;        Pause
  21. ;;        ScrollBar
  22. ;;        SysMenuSelect
  23. ;;      
  24. ;;;;;;;;;;
  25.  
  26. if Running("write.exe")=1
  27.     Messagebox("Error","Please close the Write application before running this script.",0)
  28.     Exit
  29. endif
  30.  
  31. Exec "Write"    ;Load the Write application
  32. Attach "WRITE_Write"
  33. SysMenuSelect -4048
  34. Attach "WRITE_MSWRITE_DOC1"
  35. Type "This script is an example of how ScriptTools works with Write.{Return}{Return}{Return}"
  36. Pause 1
  37. type "We'll choose the Fonts command and look at the available fonts.{Return}{Return}"
  38. pause 1 sec
  39.  
  40. Attach "WRITE_Write"
  41. MenuSelect 4168                ;Select the fonts menu item
  42. Pause 1 sec
  43.  
  44. ;Get the text from the combo boxes in the Font dialog box.
  45. ;Usually you don't need to attach to them first but it doesn't hurt.
  46. Attach "WRITE_ComboLBox1"
  47. A$=Capture$("WRITE_ComboLBox1",1,1)
  48. Pause 1 sec
  49.  
  50. Attach "WRITE_Font"
  51. Button 2 SingleClick            ;Click the Cancel button
  52. attach "WRITE_MSWRITE_DOC1"
  53. if a$!="" then
  54.     Type "The fonts I saw were:{Return}{Return}"
  55.     type_special(a$)            ;This is a special type routine to handle CRLF correctly.
  56.     Type "We'll choose a font.{Return}{Return}"
  57.     pause 1 sec
  58. endif
  59.  
  60. Attach "WRITE_Write"
  61. MenuSelect 4168                    ;Select the Fonts menu item
  62. pause 1 sec
  63.  
  64. if a$="" then                    ;If we get here, we found no fonts installed.
  65.     Attach "WRITE_Font"
  66.     Button 2 SingleClick        ;Click the Cancel button
  67.     attach "WRITE_MSWRITE_DOC1"
  68.     Type "I can't display any other fonts because I didn't find any in the Fonts dialog box.{Return}"
  69. else
  70.     pos=instr(a$,chr$(13))        ;If there is more than 1 font, just use the first.
  71.     if pos!=-1 then
  72.         font$ = Left$(a$,pos)    ;Grab the first one in the return-delimited list
  73.     else
  74.         font$=a$                ;Just copy if only one font in the list
  75.     endif
  76.     Attach "WRITE_Font"
  77.     ComboText 1136 font$        ;I got the 1136 number from the Attach Name dialog
  78.  
  79.     B$=Capture$("WRITE_ComboLBox2",1,1)
  80.     C$=Capture$("WRITE_ComboLBox3",1,1)
  81.  
  82.     Attach "WRITE_Font"
  83.     Button 1 SingleClick        ;Click the OK button
  84.  
  85.     Attach "WRITE_MSWRITE_DOC1"
  86.     Type "{Return}This is the "+font$+" font.{Return}{Return}"
  87.     if b$!="" then
  88.         Type "The styles I saw for this font were:{Return}{Return}"
  89.         type_special(b$)        ;This is a special type routine
  90.     endif
  91.  
  92.     if c$!="" then
  93.         Type "{Return}The point sizes I saw for this font were:{Return}{Return}"
  94.         type_special(c$)        ;Special type routine again
  95.     endif
  96. endif
  97.  
  98.  
  99.  
  100. Attach "WRITE_MSWRITE_DOC1"
  101.     Type "ScriptTools can launch help by choosing Contents from the Help menu.{Return}"
  102. Pause 1
  103. Attach "WRITE_Write"
  104.     MenuSelect 4608
  105. Pause 5
  106. Attach "WINHELP_Write Help1"
  107.     MenuSelect 1105
  108. Attach "WRITE_MSWRITE_DOC1"
  109.     Type "{Return}{Return}"
  110.     Type "Thanks for using this script.{Return}"
  111.     Type "Good-bye for now."
  112. Pause 1
  113. Attach "WRITE_Write"
  114.     MenuSelect 4104
  115. Attach "WRITE_Write"
  116.     Button 7 SingleClick    ;Click No when asked to save
  117.  
  118.  
  119. Function Type_Special(string$)
  120. ;This routine types the string in the Attached window.
  121. ;This will be a little different than just using the Type command because
  122. ;we will be looking for CHR$(13) and then typing "{Return}" in its place.
  123.  
  124.     local x
  125.     if length(string$)!=0
  126.         x=0
  127.         while x<length(string$)
  128.             if substr$(string$,x,x)!=chr$(13)
  129.                 type substr$(string$,x,x)
  130.             else
  131.                 type "{Return}"
  132.             endif
  133.             x=x+1
  134.         endwhile
  135.     endif
  136.     type "{Return}"
  137. EndFunction
  138.