WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Miscellaneous

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

ENUM counting structure

Some languages support ENUM or Enumeration type structures where a list of identifiers (variables) may be specified, and used as numbers in a program, without each number being individualy specified.

WinBatch does not support this construct, but with a small User Defined Subroutine, an Enumeration-type structure may be name


#DefineSubRoutine enum(enum_s)
    If StrClean(enum_s,"abcdefghijklmnopqrstuvwxyz_,0123456789","",0,1)>""
      Terminate(1,"enum",StrCat("bad string",@LF,'"',enum_s,'"'))
    EndIf
    For enum_i = 1 To ItemCount(enum_s,",")
      enum_v = ItemExtract(enum_i,enum_s,",")
      If enum_v=="" Then Continue
      %enum_v% = enum_i
    Next enum_i
    DropWild("enum_*")
#EndSubRoutine


;Test

    ;Define the variables one, two, three, and four as part of an enumeration
    enum("one,two,three,four") ; don't forget the quotes

    ;Show the assigned values.
    Display(1,"one",one)
    Display(1,"two",two)
    Display(1,"three",three)
    Display(1,"four",four)

Article ID:   W16019
File Created: 2004:03:30:15:42:18
Last Updated: 2004:03:30:15:42:18