Re: Buffer abuse

Dimitris Keletsekis <[email protected]> Fri, 26 Apr 2013 08:56:56 +0300
Newsgroups gmane.comp.windows.gui4cli
Message-ID <CAHiKg1WQdx1r7x6o0innhnSy-JbOSvx7n5i=1YEmA+0bTVGppA@mail.gmail.com>
Hi,

I didn't get much of what you are describing, but as I understand you want
to eliminate the Error report.

I'll have a look, but for now, if it bothers you a lot maybe you can use
SET OUTPUT to redirect the output temporarily.

Dimitris


On Thu, Apr 25, 2013 at 4:11 PM, flicknemo <[email protected]> wrote:

> **
>
>
> Buffer abuse
>
> Hi Dimitris,
>
> I wrote a script to detect drop any LNK file icon onto its window.
> On each drop it is detected by my function
> ~~~~~~~~~~~~~
> xondrop #window
> local filepath
> ~~~~~~~~~~~~~
> which checks first if it is a LNK, and opts out if it is not.
> Since it is to be used repeatedly during the run, on each drop, it has to
> clear the data by :
>  Buffer LOAD $filepath Binarydata //Read the file contents to RAM
> The interpreter is set not to allow us to accidentally overwrite our
> buffer data.
> So it only allows this when it is creating Binarydata in RAM during a run.
>
> There is an error message which halts it if it already exists .  The
> answer is to free the
> Binarydata buffer.  If it does NOT already exist, it gives an error message
> when the script tries to free it.  I looked at IFEXIST... ENDIF in the
> manual
> and it was not listed for buffers.  So I reasoned that if it tries to Use
> buffer,
> the interpreter will make it point at the RAM containing that buffer.
> Then it
> should set a true or false in the $$buffer.valid
> ~~~~~~~~~~~~~
> use buffer Binarydata
> if $$buffer.valid > 0
>      buffer free Binarydata
> endif
> ~~~~~~~~~~~~~
> I get an error :
>  [Item was not found, Binarydata]
> on the first drop, since the script asks this first before doing anything
> else. That will be from asking it to use a buffer which does not exist.
> While the buffer lives it contains the contents of the LNK file and another
> function :
> xroutine link2path buffer_name pcmode
> has these : modes of operation
> //mode =  0 which it defaults to pcpath, 1 is pcpath in quotes, 2 is
> gcpath, 3 is pcpath in quotes
> A Docase causes the selecting number to create the text in that manner,
> which at the moment, I shall print on the Debug output screen GCWIN.  The
> text will be used by other calling scripts as this is a library function.
>
> It is only intellectually challenging as the function does its job.  Shall
> I live with the error message in
> debug, or is there a way around this?
>
> Regards, Flicknemo
>
>  
>