Access denied

Discussions related to graphics (2D and 3D), animation and games programming
KenDown
Posts: 332
Joined: Wed 04 Apr 2018, 06:36

Access denied

Post by KenDown »

Can anyone tell me why the bit of code here throws up an "Access denied" error? I get the same error if I don't delete the temporary file but then call the routine a second time (which would try to overwrite Temp.bmp)

Reading the help file indicates that to clear images out of memory one needs to call PROC_imgExit followed by PROC_imgINIT and doing so does indeed allow me to delete the file, but it also disables the library so that no further images are displayed.

Code: Select all

      INSTALL @lib$+"ImgLib"
      PROC_imgInit
      l%=0:t%=0:w%=1920:h%=1080
      OSCLI("SCREENSAVE "+@dir$+"Temp.bmp "+STR$l%+","+STR$t%+","+STR$w%+","+STR$h%)
      t%=FN_imgLoad(@dir$+"Temp.bmp")
      OSCLI("DEL "+CHR$34+@dir$+"Temp.bmp"+CHR$34)
baz4096
Posts: 9
Joined: Tue 07 Oct 2025, 12:11

Re: Access denied

Post by baz4096 »

Hi Ken,

We had a web hosting outage earlier that prevented Richard from replying to this post.
Richard's message would have been as follows:



KenDown wrote: ↑Tue 20 Oct 2026, 17:54 Can anyone tell me why the bit of code here throws up an "Access denied"
error?
@dir$ is the directory containing your
BASIC program
, as such you should never attempt to write to
it
since it may be read-only - and is likely to be if you
'compile' your program to an executable. The only pre-defined
directories to which you may safely write are
@tmp$ and @usr$.

Also, it makes no sense to put a file path in quotes in the *DEL command
but the same path not in quotes in the *SCREENSAVE command:

Code: Select all

       OSCLI("SCREENSAVE "+@dir$+"Temp.bmp
"+STR$l%+","+STR$t%+","+STR$w%+","+STR$h%)
       OSCLI("DEL "+CHR$34+@dir$+"Temp.bmp"+CHR$34)
If quotes are needed (and they generally will be) they are needed in
both.
--------------------------------------------------------------------

Richard.