  directory change,@path(%0)
  external vdsbar.dll
  external vdsimage.dll
  DIALOG CREATE,Barcode printing program,-1,0,296,363
  DIALOG ADD,GROUP,gSystem,0,0,296,48,Barcode system
  DIALOG ADD,COMBO,cSystem,16,8,112,21,,,list,sorted
  DIALOG ADD,TEXT,lRatio,16,136,,,"Ratio (2 or 4):"
  DIALOG ADD,EDIT,eRatio,16,208,72,24,4
  DIALOG ADD,GROUP,gBarcodes,48,0,296,200,Barcodes
  DIALOG ADD,EDIT,eBarcodes,64,8,280,176,,,multi
  DIALOG ADD,GROUP,gOutput,248,0,296,48,Output filename
  DIALOG ADD,EDIT,eOutput,264,8,240,24,,,readonly
  DIALOG ADD,BUTTON,bOutput,264,256,32,24,...
  DIALOG ADD,CHECK,chPrint,304,8,280,16,&Print barcodes
  DIALOG ADD,BUTTON,bCreate,328,72,152,24,&Create,,default
  DIALOG SHOW
  list loadtext,cSystem,
"2_5interleaved
"2_5industrial
"2_5matrix
"39
"39ext
"128a
"128b
"128c
"93
"93ext
"msi
"postnet
"codabar
"ean8
"ean13
"upca
"upce0
"upce1
"upcsupp2
"upcsupp5
"ean128a
"ean128b
"ean128c
  %A       = @match(cSystem,codabar)
  %%font   = Verdana
  %%size   = 10
  %%attr   = 
  %%color  = black
  %%column = 250
  %%vert   = 100
:evloop
  wait event
  goto @event()
:bCreatebutton
  if @not(@dlgtext(eOutput))
    warn You must select a file first!
    goto evloop
  end
  list create,1
  list assign,1,@dlgtext(eBarcodes)
  if @greater(@count(1),0)
    image open
    image width,@prod(%%column,2)
    %%text = @dlgtext(cSystem) "("@dlgtext(eRatio)")"
    image text,0,@diff(@div(@prod(%%column,2),2),@div(@image(textwidth,%%text,%%font,%%size,%%attr),2)),%%text,%%font,%%size,B,%%color
    %x = 0
    %y = 30
    repeat
      %%code = @next(1)
      barcode savecode,@dlgtext(cSystem),code.bmp,%%code,50,@dlgtext(eRatio),black,white
      image save,@dlgtext(eOutput)
      image open,code.bmp
      %%width = @image(width)
      %%height = @image(height)
      image open,@dlgtext(eOutput)
      image insert,code.bmp,0,0,,,%y,@sum(%x,@diff(@div(%%column,2),@div(%%width,2)))
      image text,@sum(%y,55),@sum(%x,@diff(@div(%%column,2),@div(@image(textwidth,%%code,%%font,%%size,%%attr),2))),%%code,%%font,%%size,%%attr,%%color
      %x = @sum(%x,%%column)
      if @greater(%x,@pred(@prod(%%column,2)))
        %x = 0
        %y = @sum(%y,%%vert)
      end
    until @not(@item(1))
    image save,@dlgtext(eOutput)
    if @dlgtext(chPrint)
      shell print,@dlgtext(eOutput)
    else
      shell open,@dlgtext(eOutput)
    end
  end
  list close,1
  goto evloop
:bOutputbutton
  %A = @filedlg("Image files (*.bmp; *.gif; *.jpg)|*.bmp;*.gif;*.jpg",Select destination image file,,save)
  if %A
    if @not(@ext(%A))
      %A = %A.bmp
    end
    dialog set,eOutput,%A
  end
  goto evloop
:close
  exit
