Posted By

TopcatSoftware on 01/09/11


Tagged

hta


Versions (?)

GUI for AWK Scripts in Windows


 / Published in: Awk
 

URL: http://www.topcat.hypermart.net/index.html

Quick & dirty gui for awk scripts under Windows using an 'HTA' (hyper text application)

  1. <!--
  2.  
  3. Instant GUI for AWK output - Topcat Software LLC. 2009
  4. http://www.topcat.hypermart.net/index.html
  5.  
  6. This example will capture the output of your AWK program
  7. and render that output dynamically to an HTML stream
  8. within a graphical window.
  9.  
  10. Requires Windows, and the WSH scripting host, both
  11. of which are native to any modern Windows installation.
  12.  
  13. To use this example, follow these three steps:
  14.  
  15. 1. Save this example to a file with an extension of 'HTA'
  16. eg - 'example.hta' (HTA meaning 'HyperText Application'
  17. is a proprietary format for Internet Explorer).
  18.  
  19. 2. Edit the line below containing 'program.awk datafile'
  20. and replace with your AWK program file, and your datafile.
  21.  
  22. 3. double click your HTA file to run it.
  23.  
  24. -->
  25.  
  26. <html>
  27. <head>
  28. <title>My application</title>
  29.  
  30. <hta:application
  31. id="MyApp"
  32. applicationName="My application"
  33. border="thick"
  34. borderStyle="normal"
  35. caption="yes"
  36. contextMenu="yes"
  37. icon=""
  38. innerBorder="no"
  39. maximizeButton="yes"
  40. minimizeButton="yes"
  41. navigable="yes"
  42. scroll="yes"
  43. scrollFlat="no"
  44. selection="yes"
  45. showInTaskBar="yes"
  46. singleInstance="yes"
  47. sysMenu="yes"
  48. version="1.0"
  49. windowState="normal">
  50.  
  51. </head>
  52. <body>
  53.  
  54. <script type="text/vbscript">
  55. Set wsh = CreateObject("Wscript.Shell")
  56. Set fso = CreateObject("Scripting.FileSystemObject")
  57. TempFile = fso.GetSpecialFolder(2) & "\" & fso.GetTempName
  58.  
  59. wsh.Run "%comspec% /c gawk -f program.awk datafile" & " > " & TempFile, 0, True
  60. Set otf = fso.OpenTextFile(TempFile, 1)
  61. buf = otf.ReadAll
  62. otf.Close
  63. Set otf = fso.GetFile(TempFile)
  64. otf.Delete
  65.  
  66. Set otf = Nothing
  67. Set fso = Nothing
  68. Set wsh = Nothing
  69.  
  70. buf = Replace(buf,"<", "<")
  71. buf = Replace(buf,">", ">")
  72.  
  73. document.write("<pre>" & buf & "</pre>")
  74. </script>
  75.  
  76. </body>
  77. </html>

Report this snippet  

You need to login to post a comment.