Board index » delphi » BGI problem

BGI problem

We are still teaching pascal (TP7.0) but we have encountered a problem
that never existed before.  We have TP installed on the network x: drive
and it and all its subdirectory are write-protected. This has always been
the case. The Board recently upgraded to the latest version of Novell.

The problem is that if a student runs this program it will not work.
If a teacher runs this program it works. Students have 'read' access to
x:\tp\bgi.  If students copy the egavga.bgi to their own directory the
program will work if the 'path' is changed to reflect this.

InitGraph (Gd,Gm, 'h:\pascal');   (* this is OK ' *)

Is there a fix for this? Is there something that I am missing?
Does TP actually require egavga.bgi to be read/writeable?

thanks in advance
John K

Program test;
   uses Crt, Graph;
var
   Gd, Gm: Integer;
   Color: Word;
begin
   Gd := Detect;
   InitGraph(Gd, Gm, 'x:\tp\bgi ');
   Color := GetMaxColor;
   Randomize;
   repeat
      PutPixel(Random(100), Random(100), Color); { Plot "stars" }
      Delay(10);
   until KeyPressed;
   Readln;
   CloseGraph;
end.
--
John Katic    e-mail address aq...@freenet.carleton.ca
              fax number     1-613-224-0805
-----------------------------------------------------------------

 

Re:BGI problem


Hi!

Quote
> Is there a fix for this? Is there something that I am missing?
> Does TP actually require egavga.bgi to be read/writeable?

This is probably due to the problem that BP tries to open
files in read/write filemode.

Possible filemodes:
  Read only    $00
  Write only   $01
  Read/Write   $02
  Deny all     $10
  Deny write   $20
  Deny read    $30
  Deny none    $40
  Inheritance  $80

I guess setting the "filemode" variable (always available due to
the system unit) to read only when opening the BGI driver should
fix this problem. BUT BE AWARE! Your pupils should set the filemode
back to read/write after opening the BGI driver, otherwise they
won't be able to write to files over the whole program!
Another solution could be linking the driver into the exe.
There's somewhere a demo prog delivered for this.

Bye,
Stefan
--
please remove the NOSPAM in my email-adress to answer me
take a look @ my homepage: http://sourcenet.home.pages.de/

Re:BGI problem


In article <3aad256...@news.arcor-ip.de>,

Quote
Stefan Goehler <stefan.goeh...@gmxNOSPAM.de> wrote:

>I guess setting the "filemode" variable (always available due to
>the system unit) to read only when opening the BGI driver should
>fix this problem. BUT BE AWARE! Your pupils should set the filemode
>back to read/write after opening the BGI driver, otherwise they
>won't be able to write to files over the whole program!

Filemode only works with reset so it only prevents random access where
one reads and writes on same open file. One can always create files
with rewrite and write on them.

In fact it is good to always set filemode to zero and then only when
needed set it back to 2. This allows you to read read-only files. Also
an error in this case is detected immediately if you try to write on
file opened with reset. On the default value (2) the error might go
unnoticed during testing if the test environment does not use read-only
files and then on distribution the program might fail.

IMO Borland blew this. They should have kept reset strictly read only
and then give a separate routine to open for read-write, or they could
have allowed the filemode as an optional parameter for reset().

Osmo

Re:BGI problem


RE: Re: BGI problem
BY: ronka...@cc.helsinki.fi (Osmo Ronkanen)

Reply : Requested

Quote
>Filemode only works with reset so it only prevents random access where
>one reads and writes on same open file. One can always create files
>with rewrite and write on them.

     From what you are saying, I can only change the FileMode when I use
"reset".

     Am I understanding your statement correctly.

Art Johnston

--- Gated via The Abyss BBS -*n...@filenet.wwiv.net*-
    (714) 903-9920 -* Westminster, California*-

Re:BGI problem


Quote
John Katic wrote:
> We are still teaching pascal (TP7.0) but we have encountered a problem
> that never existed before.  We have TP installed on the network x: drive
> and it and all its subdirectory are write-protected. This has always been
> the case. The Board recently upgraded to the latest version of Novell.

> The problem is that if a student runs this program it will not work.
> If a teacher runs this program it works. Students have 'read' access to
> x:\tp\bgi.  If students copy the egavga.bgi to their own directory the
> program will work if the 'path' is changed to reflect this.

> InitGraph (Gd,Gm, 'h:\pascal');   (* this is OK ' *)

> Is there a fix for this? Is there something that I am missing?
> Does TP actually require egavga.bgi to be read/writeable?

> thanks in advance
> John K

> Program test;
>    uses Crt, Graph;
> var
>    Gd, Gm: Integer;
>    Color: Word;
> begin
>    Gd := Detect;
>    InitGraph(Gd, Gm, 'x:\tp\bgi ');
>    Color := GetMaxColor;
>    Randomize;
>    repeat
>       PutPixel(Random(100), Random(100), Color); { Plot "stars" }
>       Delay(10);
>    until KeyPressed;
>    Readln;
>    CloseGraph;
> end.
> --
> John Katic    e-mail address aq...@freenet.carleton.ca
>               fax number     1-613-224-0805
> -----------------------------------------------------------------

At my former school the problem was exactly the other way round...but I
don't whether the drive was write protected or not...

Markus

Re:BGI problem


In article <3aad9ec8-the-ab...@wwivbbs.org>,

Quote
Art Johnston <u...@n700.filenet.wwiv.net> wrote:

>RE: Re: BGI problem
>BY: ronka...@cc.helsinki.fi (Osmo Ronkanen)

>Reply : Requested

>>Filemode only works with reset so it only prevents random access where
>>one reads and writes on same open file. One can always create files
>>with rewrite and write on them.

>     From what you are saying, I can only change the FileMode when I use
>"reset".

You can change it when you please but it only affects the reset().

Begin
  filemode:=0;
end.

That is a program that changes filemode but does not use reset.

From the help:

"The FileMode variable determines the access code to pass to DOS when
typed and untyped files (not text files) are opened using the Reset
procedure."

Osmo

Re:BGI problem


Quote
> Filemode only works with reset so it only prevents random access where
> one reads and writes on same open file. One can always create files
> with rewrite and write on them.

I forgot to mention that. Nevertheless files can't be written if
opened with reset and the variable hasn't been set back. Sometimes,
this can result in some trouble...

Bye,
Stefan
--
please remove the NOSPAM in my email-adress to answer me
take a look @ my homepage: http://sourcenet.home.pages.de/

Re:BGI problem


In article <3aae7d9...@news.arcor-ip.de>,

Quote
Stefan Goehler <stefan.goeh...@gmxNOSPAM.de> wrote:
>> Filemode only works with reset so it only prevents random access where
>> one reads and writes on same open file. One can always create files
>> with rewrite and write on them.
>I forgot to mention that. Nevertheless files can't be written if
>opened with reset and the variable hasn't been set back. Sometimes,
>this can result in some trouble...

But this would be revealed by even the simplest testing. The other way
is much harder to detect. In any case if you keep filemode as 2, you
need to set it ALWAYS to zero just before you open a file for read and
then back to two. Otherwise your code fails if the file is read-only.

Osmo

Other Threads