RE: Save As options ... (another BUG!)
- Posted by CoJaBo <cojabo at suscom.net> Feb 12, 2004
- 459 views
Hopefully...Greg Haberek wrote: > > > Gosh darn son of a pup! That *was* in the first version, but I guess I > forgot to put it back in. Oh well, I think we get it now. > > ----- Original Message ----- > From: "CoJaBo" <cojabo at suscom.net> > To: <EUforum at topica.com> > Subject: RE: Save As options ... (another BUG!) > > > > Do I see another bug? > > > > -- begin code -- > > global function getSaveFileName2( integer id, sequence fName, sequence > > filters ) > > -- getSaveFileName2() > > -- returns { File name, Filter Index ) on success > > -- returns {} on user cancel > > > > atom ofn, flags > > atom fIndex -- filter index > > > > -- build the structure > > if find("DIALOG FLAGS", upper(filters)) = 0 then > > -- Default setting > > flags = or_bits(OFN_OVERWRITEPROMPT, OFN_HIDEREADONLY) > > else > > flags = 0 > > end if > > ofn = buildDefaultOfn( id, fName, filters, flags) -- warn if exists > > > > -- call the routine > > if w32Func(xGetSaveFileName, {ofn}) then > > -- get the name > > fName = fetch( ofn, ofnFile ) > > else--canceled > > fName=""--this might help! > > end if > > > > if length(fName) then--if program specified name > > --and user canceled, this would still run! > > fIndex = fetch( ofn, ofnFilterIndex ) > > fName = {fName, fIndex} > > end if > > > > -- release the structure and strings > > release_mem( ofn ) > > > > -- return result > > return fName > > > > end function > > -- end code -- > > > > > > Greg Haberek wrote: > > > > > > > > > Figures! I release code and I find a bug! Grrr... Apparently if you > > > clicked > > > 'Cancel', fIndex would have no value and produce an error. Here's the > > > fixed > > > code: > > > > > > -- begin code -- > > > global function getSaveFileName2( integer id, sequence fName, sequence > > > filters ) > > > -- getSaveFileName2() > > > -- returns { File name, Filter Index ) on success > > > -- returns {} on user cancel > > > > > > atom ofn, flags > > > atom fIndex -- filter index > > > > > > -- build the structure > > > if find("DIALOG FLAGS", upper(filters)) = 0 then > > > -- Default setting > > > flags = or_bits(OFN_OVERWRITEPROMPT, OFN_HIDEREADONLY) > > > else > > > flags = 0 > > > end if > > > ofn = buildDefaultOfn( id, fName, filters, flags) -- warn if exists > > > > > > -- call the routine > > > if w32Func(xGetSaveFileName, {ofn}) then > > > -- get the name > > > fName = fetch( ofn, ofnFile ) > > > end if > > > > > > if length(fName) then > > > fIndex = fetch( ofn, ofnFilterIndex ) > > > fName = {fName, fIndex} > > > end if > > > > > > -- release the structure and strings > > > release_mem( ofn ) <snip>