Page 2 of 4 <1234>
Topic Options
#147537 - 2005-09-13 12:24 PM Re: printer add: need help...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
whole lot of syntax errors there mart.

and balafrus' code is not kixtart at all.
"if exist blaah" just does not work.

and that printer mapping.
is there only one printer per room?
do the printers have proper names or do they differ totally from the naming schema?

I say this because like I said above, all you need is at most 5 lines of code if all of the info is here.
don't start coding too soon.
you can see what comes from it.
bad code

and mart, could you clean your code?
_________________________
!

download KiXnet

Top
#147538 - 2005-09-13 12:56 PM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
well , i don't know why don't you like the "if exist" but i did it because i found it in a doc about kix and don't know kix at all...so i'm open to all sugest if you have any..

BAL.

Top
#147539 - 2005-09-13 01:02 PM Re: printer add: need help...
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Yeah, should read stuff better.
Just took balafrus's code without reading it properly.
Added lots of ".


Edited by Mart (2005-09-13 01:04 PM)
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#147540 - 2005-09-13 01:05 PM Re: printer add: need help...
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Quote:

is

Code:
Use * /delete 



used to delete all mappings ?

BAL.




Yes it is.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#147541 - 2005-09-13 01:13 PM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
Excuse me but is your script for Kix 4xx or kix 3xx ?

Cause i got some error messages at startup and cant see them cause of their speed...

BAL.

Top
#147542 - 2005-09-13 01:17 PM Re: printer add: need help...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
balafrus, if you look again in the manual, exist is a function.
thus it is Exist()

Code:
if exist("myfolder") or exist("myFile") or not exist("yourFile")



now, still...
you don't have kixtart 4.xx but with you can do pretty amazing stuff with 3.62 and it surely is not that old.
just lacks some of the cool newer functionality.

if you can't tell the naming schema (if there is any) for the printers, can't assist you further.

in your attempt in the first post of yours, you just write the reg-value but there is lot more than reg-value to having a printer connected.
thus, use kixtart's inbuild AddPrinterConnection() instead.
_________________________
!

download KiXnet

Top
#147543 - 2005-09-13 01:26 PM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
yes but i don't remmeber who's telling me that i cant with my old version of Kix...

The naming schema, what did u mean of ? the name of the printer and the server ?

Room 604
Printer laser: HPlaserjet604
printer colour: HP604
serveur: PTP7002A01

and the same for other classroom...

BAL.

Top
#147544 - 2005-09-13 01:41 PM Re: printer add: need help...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
alrighty!
now, if I understood all the pieces properly, all you need for all classes could be...

Code:

;Room XXX
;wksta: PTExXXXayy
;Printer laser: HPlaserjetXXX
;printer colour: hpXXX
;serveur: PTPServerName

if substr(@wksta,1,3) = "PTE"
$Room = substr(@wksta,4,4)
if substr($Room,1,1) = "0" $Room = substr($Room,2) endif ;if number begins with zero, remove it.
$retval = AddPrinterConnection("\\PTPServerName\HPlaserjet"+$Room)
$retval = AddPrinterConnection("\\PTPServerName\HP"+$Room)
endif



that same code works for all rooms.
now, if you want to make the laser the default (as example), you need to have the name of the printer instead of the sharename.
if your sharename and printername on the server are the same, then simply this will do:
Code:

if substr(@wksta,1,3) = "PTE"
$Room = substr(@wksta,4,4)
if substr($Room,1,1) = "0" $Room = substr($Room,2) endif ;if number begins with zero, remove it.
$retval = AddPrinterConnection("\\PTPServerName\HPlaserjet"+$Room)
$retval = SetDefaultPrinter("\\PTPServerName\HPlaserjet"+$Room)
$retval = AddPrinterConnection("\\PTPServerName\HP"+$Room)
endif



and that's it. there is 7 lines but heck... little extra for 3.xx

you understand what I did there?
_________________________
!

download KiXnet

Top
#147545 - 2005-09-13 01:57 PM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
yes but still one problem , the local 705 have only one printer colour and no laser...and 706 use the shared printer from 705 too...

So for the 705-706 only one printer (colour) shared.

BAL.

Top
#147546 - 2005-09-13 04:45 PM Re: printer add: need help...
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
it does not matter.
I thought about it too before posted the code.
when there is no printer, the addprinterconnection just fails to connect the printer, right?
so, it's fine to be there.

for 706 the problem is there.
you have 2 choices.
either share the same printer again with another name too or I will modify the script.

you could have something like:
Code:

if substr(@wksta,1,3) = "PTE"
$Room = substr(@wksta,4,4)
if substr($Room,1,1) = "0" $Room = substr($Room,2) endif
if $Room = "706" $Room = "705" endif ;706 does not have printer, using the one from 705.
$retval = AddPrinterConnection("\\PTPServerName\HPlaserjet"+$Room)
$retval = SetDefaultPrinter("\\PTPServerName\HPlaserjet"+$Room)
$retval = AddPrinterConnection("\\PTPServerName\HP"+$Room)
endif

_________________________
!

download KiXnet

Top
#147547 - 2005-09-15 09:04 AM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
nice one , i will try this and tell you if it works... !

Thanks a lot !

BAL.
(ps: i take my 2nd "C" training yesterday...so please be patient.. )

Top
#147548 - 2005-09-15 09:54 AM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
excuse my next noob question but could i use kixtart in local mode , in exemple only one my computer to make my tests...and if i can , how ?

Cause like this i can make all the tests i want (need...) without making some trouble with the other users...

Thanks again !

BAL.

Top
#147549 - 2005-09-15 09:58 AM Re: printer add: need help...
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Sure you can. Just run it of your local system from for example a command line window or directly from the editor if it has the option to do so.

pathtokix32\kix32.exe pathttoscript\yourscript.kix
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#147550 - 2005-09-15 10:05 AM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
rhooo thanks a lot it will help me more then u can think about....

BAL.

Top
#147551 - 2005-09-15 10:07 AM Re: printer add: need help...
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
Just a small tip.

Don’t forget to put Break on at the top of your script when testing. If its not there and for some reason your script gets stuck or in a loop you cant quit it without being logged of each time.
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#147552 - 2005-09-15 10:30 AM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
could you please put me an exemple ?
Top
#147553 - 2005-09-15 10:43 AM Re: printer add: need help...
Mart Moderator Offline
KiX Supporter
*****

Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
It's easy, just put Break on at the top of your script like this:

Code:

Break on

other kix code goes here

_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.

Top
#147554 - 2005-09-15 10:54 AM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
oh , ok im thinking about a more evil code like this

Code:

break
if substr(@wksta,1,3) = "PTE" break on
$Room = substr(@wksta,4,4)
if substr($Room,1,1) = "0" $Room = substr($Room,2) endif
if $Room = "706" $Room = "705" endif ;706 does not have printer, using the one from 705.
$retval = AddPrinterConnection("\\PTPServerName\HPlaserjet"+$Room)
$retval = SetDefaultPrinter("\\PTPServerName\HPlaserjet"+$Room)
$retval = AddPrinterConnection("\\PTPServerName\HP"+$Room)
endif




Or something like that...

BAL.

Top
#147555 - 2005-09-15 11:06 AM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
here's what i've tried and don't seems to work...

Code:

break on

if substr(@wksta,1,3) = "PTE"
$Room = substr(@wksta,4,4)
if substr($Room,1,1) = "0" $Room = substr($Room,2) endif ;
$retval = AddPrinterConnection("\\PTE0705A06\HP"+$Room)
$retval = SetDefaultPrinter("\\PTP0705A06\HP"+$Room)
endif



Isn't it suppose to connect a printer ? i try this one with kixtart version 4.50 any idea ?

BAL.

Top
#147556 - 2005-09-15 11:38 AM Re: printer add: need help...
balafrus Offline
Fresh Scripter

Registered: 2005-09-12
Posts: 33
Loc: Belgium
ok i try this one and it works fine:

Code:

break on

if substr(@wksta,1,5) = "PTE07";
$retval = AddPrinterConnection("\\PTE0705A06\HP705")
$retval = SetDefaultPrinter("\\PTE0705A06\HP705")
endif



But still have some problems to set as a default printer...is the syntax correct ?

BAL.

Top
Page 2 of 4 <1234>


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 581 anonymous users online.
Newest Members
Audio, Hoschi, Comet, rrosell, PatrickPinto
17880 Registered Users

Generated in 0.076 seconds in which 0.025 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org