Page 1 of 1 1
Topic Options
#206741 - 2013-02-20 10:10 AM Using @CRLF as a delimiter in split??
Curious Offline
Getting the hang of it

Registered: 2004-02-16
Posts: 61
I'm improving our way of adding printers for our users, reading from a file with 'ReadProfileString'.

kix command is like this:

 Code:
	
	$PrinterList = Split(ReadProfileString('%logonserver%\NETLOGON\PRINTER\Printer.ini', $ID, 'Printer'), ';')
	$DefPrinter = ReadProfileString('%logonserver%\NETLOGON\PRINTER\Printers.ini', $ID, 'Standard')
	For Each $Printer in $PrinterList
          xxx
          xxx
        Next


When handling long printernames, the use of a ';' as a delimiter produces long messy lines in the ini-file.
Instead It would be nice to use like a '@CRLF' instead as a delimiter.

Is there an easy way to accomplish this?


Regards Jon
_________________________
I was placed on earth to do a job. Right now I have so much to do, I will never die..

Top
#206742 - 2013-02-20 11:49 AM Re: Using @CRLF as a delimiter in split?? [Re: Curious]
Glenn Barnas Administrator Offline
KiX Supporter
*****

Registered: 2003-01-28
Posts: 4403
Loc: New Jersey
No - you can't span INI data over multiple lines. However, since you seem to have a file just for printers, the "Printer" section is redundant - try this:
PRINTER.INI File:
 Code:
[SOME_ID]
URL\For\Printer1=1
URL\For\Printer2=Default
URL\For\Printer3=1
[AnotherID]
URL\For\Printer1=1
URL\For\Printer4=Default
The printer UNC Path becomes the value instead of the data, and the "1" enables it. Here's the pseudo-code concept:
 Code:
$aPrinters=EnumINI(printers.ini, 'SomeID')
For Each $Printer in $aPrinters
  $Status = ReadProfileString(printers.ini, $ID, $Printer)
  If $Status ; if data is true (not zero), then map it
    AddPrinterConnection($Printer)
    If $Status = 'Default'
      SetDefaultPrinter($Printer)
    EndIf
  EndIf
Next
EnumINI is a UDF.

Glenn
_________________________
Actually I am a Rocket Scientist! \:D

Top
Page 1 of 1 1


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

Who's Online
0 registered and 2312 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.054 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

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