GUI for AWK Scripts in Windows


/ Published in: Awk
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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. <title>My application</title>
  27.  
  28. <hta:application
  29. id="MyApp"
  30. applicationName="My application"
  31. border="thick"
  32. borderStyle="normal"
  33. caption="yes"
  34. contextMenu="yes"
  35. icon=""
  36. innerBorder="no"
  37. maximizeButton="yes"
  38. minimizeButton="yes"
  39. navigable="yes"
  40. scroll="yes"
  41. scrollFlat="no"
  42. selection="yes"
  43. showInTaskBar="yes"
  44. singleInstance="yes"
  45. sysMenu="yes"
  46. version="1.0"
  47. windowState="normal">
  48.  
  49. </head>
  50.  
  51. <script type="text/vbscript">
  52. Set wsh = CreateObject("Wscript.Shell")
  53. Set fso = CreateObject("Scripting.FileSystemObject")
  54. TempFile = fso.GetSpecialFolder(2) & "\" & fso.GetTempName
  55.  
  56. wsh.Run "%comspec% /c gawk -f program.awk datafile" & " > " & TempFile, 0, True
  57. Set otf = fso.OpenTextFile(TempFile, 1)
  58. buf = otf.ReadAll
  59. otf.Close
  60. Set otf = fso.GetFile(TempFile)
  61. otf.Delete
  62.  
  63. Set otf = Nothing
  64. Set fso = Nothing
  65. Set wsh = Nothing
  66.  
  67. buf = Replace(buf,"<", "<")
  68. buf = Replace(buf,">", ">")
  69.  
  70. document.write("<pre>" & buf & "</pre>")
  71. </script>
  72.  
  73. </body>
  74. </html>

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.