f



SET PRINTER TO and SET DEFAULT

Hi
I recently discovered that if I issue a SET PRINTER TO LPTx after a
SET DEFAULT TO a different folder, clipper tries to create a file
named LPTx.PRN in the default directory and of course generates a
CREATE ERROR.
Without th SET DEFATLT TO command it does work as it should.
This happens in W2K/XP machines, doesn't in W98.
Any idea ?
TIA
Claudio
0
cherszage (159)
1/15/2008 1:33:16 PM
comp.lang.clipper 3959 articles. 0 followers. Post Follow

2 Replies
1062 Views

Similar Articles

[PageSpeed] 45

On Tue, 15 Jan 2008 05:33:16 -0800 (PST), cherszage@gmail.com wrote:

>Hi
>I recently discovered that if I issue a SET PRINTER TO LPTx after a
>SET DEFAULT TO a different folder, clipper tries to create a file
>named LPTx.PRN in the default directory and of course generates a
>CREATE ERROR.
>Without th SET DEFATLT TO command it does work as it should.
>This happens in W2K/XP machines, doesn't in W98.

My solution is a custom function SetPrinterTo().
You can #translate your SET PRINTER TO to call it  :

/*  SetPrinterTo(), to nullify _SET_DEFAULT before a set printer to.
*   SET PRINTER TO cFile   =>     SetPrinterTo( cFile )
*   SET PRINTER TO cFile ADDITIVE   =>   SetPrinterTo( cFile, .T. )
*   SET PRINTER TO           =>      SetPrinterTo( "" )
*   Remarque : SetPrinterTo() gives the current setting without
changing anythg
*/

#include "hcommon.ch"            // for isnil()

function SetPrinterTo( cPrintFile, lAdd )
  local cOldDefault
  local cOldPrintFile := set(_SET_PRINTFILE)

  if ! isnil(cPrintFile)
     cOldDefault   := set(_SET_DEFAULT, "" )
     set(_SET_PRINTFILE, cPrintFile, lAdd)
     set(_SET_DEFAULT, cOldDefault)
  endif

return cOldPrintFile 

-- 
Ciao,
Sebas
0
sebas22
1/15/2008 2:21:01 PM
On Jan 15, 11:21=A0am, sebas22 <nos...@x.invalid> wrote:
> On Tue, 15 Jan 2008 05:33:16 -0800 (PST), chersz...@gmail.com wrote:
> >Hi
> >I recently discovered that if I issue a SET PRINTER TO LPTx after a
> >SET DEFAULT TO a different folder, clipper tries to create a file
> >named LPTx.PRN in the default directory and of course generates a
> >CREATE ERROR.
> >Without th SET DEFATLT TO command it does work as it should.
> >This happens in W2K/XP machines, doesn't in W98.
>
> My solution is a custom function SetPrinterTo().
> You can #translate your SET PRINTER TO to call it =A0:
>
> /* =A0SetPrinterTo(), to nullify _SET_DEFAULT before a set printer to.
> * =A0 SET PRINTER TO cFile =A0 =3D> =A0 =A0 SetPrinterTo( cFile )
> * =A0 SET PRINTER TO cFile ADDITIVE =A0 =3D> =A0 SetPrinterTo( cFile, .T. =
)
> * =A0 SET PRINTER TO =A0 =A0 =A0 =A0 =A0 =3D> =A0 =A0 =A0SetPrinterTo( "" =
)
> * =A0 Remarque : SetPrinterTo() gives the current setting without
> changing anythg
> */
>
> #include "hcommon.ch" =A0 =A0 =A0 =A0 =A0 =A0// for isnil()
>
> function SetPrinterTo( cPrintFile, lAdd )
> =A0 local cOldDefault
> =A0 local cOldPrintFile :=3D set(_SET_PRINTFILE)
>
> =A0 if ! isnil(cPrintFile)
> =A0 =A0 =A0cOldDefault =A0 :=3D set(_SET_DEFAULT, "" )
> =A0 =A0 =A0set(_SET_PRINTFILE, cPrintFile, lAdd)
> =A0 =A0 =A0set(_SET_DEFAULT, cOldDefault)
> =A0 endif
>
> return cOldPrintFile
>
> --
> Ciao,
> Sebas

Sebas
Thanks for your answer.
I was trying to avoid this push/pop solution.
Unless any other one had found the reason for this clipper/w2k+
behaviour, this would probably become "the" solution.
Thanks again
Claudio
0
cherszage (159)
1/15/2008 3:41:24 PM
Reply: