#123935 - 2004-07-26 05:35 PM
Need some string expertise here ...
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
actually I am writing on a tool to export/import groups/users/policies etc. for the new project I am part of (some kind of test center).
I build an array of groups from a file created by the obvious tools the following (simplified) way:
Code:
->loop -> readline -> if instr(line,"*") -> string = string + right(line,-1) + chr(10) -> endif ->/loop string = left(string,-1) ;strip last chr(10) array = split(string,chr(10))
in this szenario (3200+ groups) the string grows over 32000 characters in length, no problem! From the array i build then an ini file with the elements as sections containing the group's descriptions as keys.
Now the problems start. On importing I do a readprofilestring on the sections of this ini file like:
Code:
string = readprofilestring(ini,"","") string = left(string,-1) , strip last chr(10) array = split(string,chr(10))
One should think that this works too as the both strings should contain the same data, but the 32000 character limit seems to apply only to readprofilestring as this craps out with 'Expression too long'; Which I kinda can't accept as the first way of creation works ok 
Is there any known workaround to this ?
My other option would be to split the ini file in parts of 1600 sections per file, which I consider a pain
_________________________
|
|
Top
|
|
|
|
#123937 - 2004-07-26 07:26 PM
Re: Need some string expertise here ...
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
|
|
Top
|
|
|
|
#123938 - 2004-07-27 11:30 AM
Re: Need some string expertise here ...
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
Ok, I accepted the fact that readprofilestring() can't create strings over 32000 chars, so I decided to split the ini files to parts of 1600 groups per file (1600 * 20 (max group chars) = 32000) like this :
creation :
Code:
$_ = writeprofilestring($sTargetFolder + '\grp\grp' + $c/1600 + '.ini',$item,"Desc",$a)
where $c is a passed for-next counter
readout :
Code:
dim $a, $c
$c = 0
while exist($sTargetFolder + '\grp\grp' + $c + '.ini')
$a = $a + readprofilestring($sTargetFolder + '\grp\grp' + $c + '.ini','','') + chr(10)
$c = $c + 1
loop
$a = left($a,-1)
$Enum_GRP = split($a,chr(10))
this works ok, allthough the string grows over 32000 chars in length
Now, as I tested this in a German environment where domain equals Domäne, I have lost some groups during export as a shelled net group command seems to deny working with 'umlauts' [äöü] (do you have a word for this in English ?) ...
the following line fails (ASCII is ON):
Code:
shell '%ComSpec% /c net group "' + $item + '" /domain > "' + $tmpfile + '" 2>nul'
where $item = 'Domänen-Admins' or something similar...
On the other side typing the command at command prompt works ok
Any insight there ?
thanx in advance
Edited by Jochen (2004-07-27 11:31 AM)
_________________________
|
|
Top
|
|
|
|
#123941 - 2004-07-27 02:09 PM
Re: Need some string expertise here ...
|
Jochen
KiX Supporter
   
Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
|
quite a pain but no significant slowdown as there are (normally) only 3 groups that match the condition :
Code:
if instr($item,'ä') while instr($item,'ä') $item = left($item,instr($item,'ä')-1) + chr(196) + right($item,len($item)-instr($item,'ä')) loop endif if instr($item,'ö') while instr($item,'ö') $item = left($item,instr($item,'ö')-1) + chr(214) + right($item,len($item)-instr($item,'ö')) loop endif if instr($item,'ü') while instr($item,'ü') $item = left($item,instr($item,'ü')-1) + chr(220) + right($item,len($item)-instr($item,'ü')) loop endif
Thanx Ron for the tip my friend
_________________________
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 595 anonymous users online.
|
|
|