home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / EnterAct 3.5 / Drag_on Modules / hAWK programs / $EnumSwitch < prev    next >
Encoding:
Text File  |  1993-04-09  |  1017 b   |  37 lines  |  [TEXT/KEEN]

  1. #$EnumSwitch
  2. #Select a bunch of enums, and run Hawk on the front selection
  3. # -optionally select the entire enum body from '{' to '}' with Balance
  4. #Leave "Show std out" and "Select all of stdout" checked
  5.  
  6.     {    gsub(/=[^,]*/, " ")
  7.         gsub(/=(.)*$/, " ")
  8.         gsub(/[,{};]/, " ")
  9.         for ( k = 1; k <= NF; k++)
  10.             case[++i] = $k
  11.     }
  12.  
  13. END    {    print "switch (??)"
  14.         print "\t{"
  15.         for (k = 1; k <= i; ++k)
  16.             {
  17.             print "case " case[k] ":"
  18.             print "\t"
  19.             print "break;"
  20.             }
  21.         print "default:"
  22.         print "\t"
  23.         print "break;"
  24.         print "\t}"
  25.     }
  26.  
  27. # User’s Manual references:
  28. # «hAWK User’s Manual» «F   Running hAWK programs»
  29. # «hAWK User’s Manual» «L  5   Regular expressions»
  30. # «hAWK User’s Manual» «M  5   Built-in string and file functions»
  31. # «hAWK User’s Manual» «K  4   Built-in variables»
  32. # «hAWK User’s Manual» «K  8   Arrays»
  33. # «hAWK User’s Manual» «N   User-defined functions»
  34. # «hAWK User’s Manual» «P  3   The getline function»
  35. # «hAWK User’s Manual» «O  3   Output into files»
  36. # «hAWK User’s Manual» «Q   The hAWK function»
  37.