1. Re: Save As options ... (another BUG!)

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 )
> >
> >     -- return result
> >     return fName
> >
> > end function
> > -- end code --
> >
> >
> > ----- Original Message -----
> > From: "Greg Haberek" <g.haberek at comcast.net>
> > To: <EUforum at topica.com>
> > Sent: Wednesday, February 11, 2004 1:10 PM
> > Subject: Re: Save As options and parameters
<snip>

> > to
> > > you to determine how to use the index from the filter list. It's
> > > basically
> > a
> > > matter of storing your filters properly so you can look them up with
the
> > > returned index.
> > >
> > > -- 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 )
> > >         fIndex = fetch( ofn, ofnFilterIndex )
> > >     else
> > >     -- cancelled
> > >         fName = ""
> > >     end if
> > >
> > >     -- release the structure and strings
> > >     release_mem( ofn )
> <snip>
>
>
>
> TOPICA - Start your own email discussion group. FREE!
>
>

new topic     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu