/* @N This Genie allows you to add an entry to an existing label database */ msg = PDSetup.rexx(2,0) units = getclip(pds_units) if msg ~= 1 then exit_msg(msg) cr = '0a'x pgdir = ReadINI.rexx("FNT", "S:PDraw.ini") if pgdir = '' then do pgdir = pdm_GetFileName("Please find the PDraw/data directory", "", "") if pgdir = '' then exit_msg() pgdir = SplitFileName.rexx(pgdir) end if right(pgdir, 1) = ":" then pgdir = pgdir'Data/' else pgdir = pgdir'/Data/' dlist = getdirlist.rexx(pgdir, ".db") if dlist = '' then exit_msg("Unable to find database files! Please reinstall") obj = pdm_SelFirstObj() if obj ~= 0 then do size = pdm_GetObjVisSize(obj) width = pdm_ConvertUnits(1, units, word(size, 1)) height = pdm_ConvertUnits(1, units, word(size, 2)) end else do width = "" height = "" end do labeltype = pdm_Inform(3,"Would you like to add a Dot Matrix label or a Laser Label?", "Cancel", "Dot Matrix", "Laser") if labeltype = 0 then exit_msg() if labeltype = 1 then do form = "Part Number"cr"Label Type"cr"Label Width:"width || cr"Label Height:"height || cr"Num. Columns"cr"Carrier Width"cr"Horizontal Pitch"cr"Vertical Pitch" form = pdm_GetForm("Enter Label Specifications..", 20, form) if form = '' then exit_msg() parse var form pnum '0a'x type '0a'x lwid '0a'x lheight '0a'x cols '0a'x cwidth '0a'x hpitch '0a'x vpitch if ~(datatype(lheight, n) & datatype(lwid, n) & datatype(cols, n) & datatype(cwidth,n) & datatype(hpitch, n) & datatype(vpitch,n)) then exit_msg("Invalid Entry") if units ~= 1 then do lheight = pdm_ConvertUnits(units, 1, lheight) lwid = pdm_ConvertUnits(units, 1, lwid) cwidth = pdm_ConvertUnits(units, 1, cwidth) hpitch = pdm_ConvertUnits(units, 1, hpitch) vpitch = pdm_ConvertUnits(units, 1, vpitch) end line = pnum';'type';'lheight';'lwid';'cols';'cwidth';'hpitch';'vpitch';' filename = pdm_SelectFromList("Select label database..", 25,5,0,dlist) if filename = '' then exit_msg() filename = pgdir || filename".db" if ~open(file, filename, r) then exit_msg("Unable to open file: "filename) fline = readln(file) if pos('MATRIX', fline) = 0 then exit_msg("This is not a Dot Matrix Label Database..") call seek(file, 0, e) call writeln(file, line) call close(file) call pdm_Inform(1,"Finished..",) end else do form = "Part Number"cr"Label Type"cr"Label Width:"width || cr"Label Height:"height cr"Num. Columns"cr"Num. Rows"cr"Top Margin"cr"Side Margin"cr"Horizontal Pitch"cr"Vertical Pitch" form = pdm_GetForm("Enter Label Specifications..", 20, form) if form = '' then exit_msg() parse var form pnum '0a'x type '0a'x lwid '0a'x lheight '0a'x cols '0a'x rows '0a'x tmarg '0a'x smarg '0a'x hpitch '0a'x vpitch if ~(datatype(lheight, n) & datatype(lwid, n) & datatype(cols, n) & datatype(rows,n) & datatype(tmarg, n) & datatype(smarg, n) & datatype(hpitch, n) & datatype(vpitch, n)) then exit_msg("Invalid entry") if hpitch < lwid then exit_msg("Horizontal pitch must be greater than or equal to label width") if vpitch < lheight then exit_msg("Vertical pitch must be greater than or equal to label height") if units ~= 1 then do lheight = pdm_ConvertUnits(units, 1, lheight) lwid = pdm_ConvertUnits(units, 1, lwid) tmarg = pdm_ConvertUnits(units, 1, tmarg) smarg = pdm_ConvertUnits(units, 1, smarg) hpitch = pdm_ConvertUnits(units, 1, hpitch) vpitch = pdm_ConvertUnits(units, 1, vpitch) end line = pnum';'type';'lheight';'lwid';'cols';'rows';'tmarg';'smarg';'hpitch';'vpitch';' filename = pdm_SelectFromList("Select label database..", 25,5,0,dlist) if filename = '' then exit_msg() filename = pgdir || filename".db" if ~open(file, filename, r) then exit_msg("Unable to open file: "filename) fline = readln(file) if pos('LASER', fline) = 0 then exit_msg("This is not a Laser Label Database..") call seek(file, 0, e) call writeln(file, line) call close(file) call pdm_Inform(1,"Finished..",) end end exit_msg() exit_msg: procedure expose units do parse arg message if message ~= '' then call pdm_Inform(1,message,) call pdm_SetUnits(units) exit end