[Script] [Util] Chem String Functions Library v. 2.97 [19-01-2009]
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
[Script] [Util] Chem String Functions Library v. 2.97 [19-01-2009]
################################################################################
Script : Chem String Functions Library
Author : Chem
E-mail : chemodun@gmail.com
Version: 2.97
Desc. :Provide some functions for manipulate with string, based on their displayed width
################################################################################
_____________
Download:
Spk version
[ external image ]
History :
2.97
-converted to X3:TC
_____________
Installation :
Install via Cycrow Script Manager (Plugin Manager)
_____________
Use:
Libraries has two script files:
setup.lib.chem.string.xml - this file prepare special array for filling string by space.
Script doesn't have any parameters.
lib.chem.strings.xml - main library script.
Script has 6 parameters:
mode (Work Mode) - for defining which function called from library
Arg1..Arg5 - for setting functions parameters
Now in version 2.81 library provide 8 functions:
1. split.string.by.delim
Arg1 - string-delimeter - string, or string from text file by page id Arg1 and text id Arg2
Arg2 - string-source - string, or string from text file by page id Arg2(or Arg3) and text id Arg3 (or $Arg4)
Arg3 - max count parts of source string (if null - max count = 99)
return - array of found parts of source string
It's function can split source string (first) by delimeter (second).
You can set maximum count of parts for splitting (Arg3), i.e. if source has more then one occurrence of delimiter , but you set Arg3 = 2 - function will return array with only 2 elements, first - source string before first occurrence of Arg1 in Arg2, and second - all source after this first occurrence.
2.'fill.spaces' - you can create string with correct displayed width in player logbook, i.e. after using this function on, for example, strings "this is long string" and "small string", they will be filled by spaces up to they width in pixels (not symbols) will be equal.
Arg1 - source string, or string from text file by page id Arg1 and text id Arg2
Arg2 or Arg3- max len (in spaces, i.e. count of sybols " ")
Arg3 or Arg4- fill
if bool
TRUE - fill left (align right)
FALSE - fill right (align left)
if string
'-' - align left
'=' - align center
'+' - align right
It's function will fill source string by spaces based not on count of symbols in string, but on their summary width on screen in player logbook.
I.e. default length for one symbols it this function will taken equal to two spaces.
In fact some symbols have length more then two spaces, some - less.
Function use special array, was prepared in setup script by experimental data form text files x8910.xml.
Now supported only English, Russian, and German languages.
If length source string more then needed length - string will be truncated.
See examples:
If you browser support animated gif -
[ external image ] [ external image ]
Or if not:
output without 'fill.spaces'
[ external image ][ external image ]
output wtih 'fill.spaces'
[ external image ][ external image ]
3,4 'sum.to.string' and 'number.to.string'
Arg1 - integer
return - string
will do convert number 1234567890 to string like 1,234,567,890 or
will do convert sum 1234567890 to string like 1,234,567,890 Cr (add default name of games currency)
5,6 'fill.sum.to.string' and 'fill.number.to.string'
Arg1 - integer
Arg2 - max length
Arg3 - TRUE - fill left (align right) or FALSE - fill right (align left)
return - string
will do convert number 1234567890 to string like 1,234,567,890 or
will do convert sum 1234567890 to string like 1,234,567,890 Cr (add default name of games currency)
Then fill converted string as it can be done via 'fill.spaces'
7 'sprintf'
Arg1 -
if string
- then format string
else if number
- page id for format string
Arg2
if Arg1 = page id
- then text id for format string
else if
- array - then array of params
else
- params
Arg3..Arg5 - params or array of params like Arg2
if param is string and has form (page;id) then it will be replaced with string from text file
Function works like sprintf function from ScE, but use unlimited count of params and extended syntax:
%[align][width]specifier
align:
- - left
= - center
+ - right (default)
width: needed width of string in pseudo symbols
specifier:
n - number
c - currency
s - string
8 'length'
Arg1 - source string, or string from text file by page id Arg1 and text id Arg2
Arg2 or Arg3- - type of measurement units.
if [TRUE] - then result will be returned in spaces
otherwise - in pseudosymbols.
This function will return displayed length of source string.
_____________
Uninstallation:
Uninstall via Cycrow Script Manager (or Plugin Manager)
_____________
Languages:
Russian
English
Deutsch - thanks to Unitrader [KGB]
_____________
Info:
Uses
Text Files Used : 8910
Text Pages Used:8910
_____________
Edit: Added working xdownloads download link. X2-Illuminatus
Script : Chem String Functions Library
Author : Chem
E-mail : chemodun@gmail.com
Version: 2.97
Desc. :Provide some functions for manipulate with string, based on their displayed width
################################################################################
_____________
Download:
Spk version
[ external image ]
History :
2.97
-converted to X3:TC
_____________
Installation :
Install via Cycrow Script Manager (Plugin Manager)
_____________
Use:
Libraries has two script files:
setup.lib.chem.string.xml - this file prepare special array for filling string by space.
Script doesn't have any parameters.
lib.chem.strings.xml - main library script.
Script has 6 parameters:
mode (Work Mode) - for defining which function called from library
Arg1..Arg5 - for setting functions parameters
Now in version 2.81 library provide 8 functions:
1. split.string.by.delim
Arg1 - string-delimeter - string, or string from text file by page id Arg1 and text id Arg2
Arg2 - string-source - string, or string from text file by page id Arg2(or Arg3) and text id Arg3 (or $Arg4)
Arg3 - max count parts of source string (if null - max count = 99)
return - array of found parts of source string
It's function can split source string (first) by delimeter (second).
You can set maximum count of parts for splitting (Arg3), i.e. if source has more then one occurrence of delimiter , but you set Arg3 = 2 - function will return array with only 2 elements, first - source string before first occurrence of Arg1 in Arg2, and second - all source after this first occurrence.
2.'fill.spaces' - you can create string with correct displayed width in player logbook, i.e. after using this function on, for example, strings "this is long string" and "small string", they will be filled by spaces up to they width in pixels (not symbols) will be equal.
Arg1 - source string, or string from text file by page id Arg1 and text id Arg2
Arg2 or Arg3- max len (in spaces, i.e. count of sybols " ")
Arg3 or Arg4- fill
if bool
TRUE - fill left (align right)
FALSE - fill right (align left)
if string
'-' - align left
'=' - align center
'+' - align right
It's function will fill source string by spaces based not on count of symbols in string, but on their summary width on screen in player logbook.
I.e. default length for one symbols it this function will taken equal to two spaces.
In fact some symbols have length more then two spaces, some - less.
Function use special array, was prepared in setup script by experimental data form text files x8910.xml.
Now supported only English, Russian, and German languages.
If length source string more then needed length - string will be truncated.
See examples:
If you browser support animated gif -
[ external image ] [ external image ]
Or if not:
output without 'fill.spaces'
[ external image ][ external image ]
output wtih 'fill.spaces'
[ external image ][ external image ]
3,4 'sum.to.string' and 'number.to.string'
Arg1 - integer
return - string
will do convert number 1234567890 to string like 1,234,567,890 or
will do convert sum 1234567890 to string like 1,234,567,890 Cr (add default name of games currency)
5,6 'fill.sum.to.string' and 'fill.number.to.string'
Arg1 - integer
Arg2 - max length
Arg3 - TRUE - fill left (align right) or FALSE - fill right (align left)
return - string
will do convert number 1234567890 to string like 1,234,567,890 or
will do convert sum 1234567890 to string like 1,234,567,890 Cr (add default name of games currency)
Then fill converted string as it can be done via 'fill.spaces'
7 'sprintf'
Arg1 -
if string
- then format string
else if number
- page id for format string
Arg2
if Arg1 = page id
- then text id for format string
else if
- array - then array of params
else
- params
Arg3..Arg5 - params or array of params like Arg2
if param is string and has form (page;id) then it will be replaced with string from text file
Function works like sprintf function from ScE, but use unlimited count of params and extended syntax:
%[align][width]specifier
align:
- - left
= - center
+ - right (default)
width: needed width of string in pseudo symbols
specifier:
n - number
c - currency
s - string
8 'length'
Arg1 - source string, or string from text file by page id Arg1 and text id Arg2
Arg2 or Arg3- - type of measurement units.
if [TRUE] - then result will be returned in spaces
otherwise - in pseudosymbols.
This function will return displayed length of source string.
_____________
Uninstallation:
Uninstall via Cycrow Script Manager (or Plugin Manager)
_____________
Languages:
Russian
English
Deutsch - thanks to Unitrader [KGB]
_____________
Info:
Uses
Text Files Used : 8910
Text Pages Used:8910
_____________
Edit: Added working xdownloads download link. X2-Illuminatus
Multiply entropy by absolute zero
Ñâîáîäà ñðåäè çâåçä / Freedom in space
Ñâîáîäà ñðåäè çâåçä / Freedom in space
I just installed this library to use it in my script, but unfortunately it doesn't work. I only tried function 2 to fill a string with spaces.
I tried it as follows:
Unfortunately the retun value ($ware) is always null. What am I doing wrong?
Greets,
ScRaT
I tried it as follows:
Code: Select all
$ware = call script lib.chem.strings: Mode = '2' Arg1=$ware, Arg2=30, Arg3='-', Arg4=null, Arg5=null
Greets,
ScRaT
First: Thanks/Danke for the reply.
But I still get null as returnvalue.
I changed the call to:
For Arg2 I also tried other (higher) values, but no change...
Maybe I installed it incorrectly, because this is a pck-file. I tried to use the Plugin Manager (Beta 6), but it always crashes, when I try to switch to the right directory. So I unpacked the pck file and put the script and the t-file into the corresponding directories manually. Is there a problem with "installing" it this way?
If not, what could be the problem?
Greets,
ScRaT
But I still get null as returnvalue.
I changed the call to:
Code: Select all
$ware = call script lib.chem.strings: Mode = 'fill.spaces' Arg1=$ware, Arg2=30, Arg3='-', Arg4=null, Arg5=null
Maybe I installed it incorrectly, because this is a pck-file. I tried to use the Plugin Manager (Beta 6), but it always crashes, when I try to switch to the right directory. So I unpacked the pck file and put the script and the t-file into the corresponding directories manually. Is there a problem with "installing" it this way?
If not, what could be the problem?
Greets,
ScRaT
Only thing I could suggest is assign the $ware to a different variable before feeding it into the fill.spaces function. I'm assuming that $ware is a variable containing a ware reference, which could be confusing the function which is expecting a straight string? I also use this function and have not had a problem with it at all. Maybe try changing the return value to a new variable and see if that helps, even though I know it works when the return variable and the arg1 variable are the same.
Failing that, I'd make a copy of the script and edit it to throw out some debug info, to find out how the values are proceeding through the script and where they are getting lost
Failing that, I'd make a copy of the script and edit it to throw out some debug info, to find out how the values are proceeding through the script and where they are getting lost
Gaming PC: Gigabyte H270M-D3H | i7 7700 | 16Gb DDR4 | Gigabyte GTX1060 6Gb OC | Asus Xonar DGX | Window 10 Home 64bit | Samsung 256Gb SSD
I don't know if Chem plans any updates or so, however Tim-O modified the german t-file, to make it work better.
After I worked a bit with it, I discovered that Chem seems to have forgotten the letter "Q". So I added it to the german t-file.
You can get that t-file here: 8910-L049.xml.
This file is of course only interesting for german users. =)
Maybe some english user will improve the english t-file aswell.
Greets,
ScRaT
After I worked a bit with it, I discovered that Chem seems to have forgotten the letter "Q". So I added it to the german t-file.
You can get that t-file here: 8910-L049.xml.
This file is of course only interesting for german users. =)
Maybe some english user will improve the english t-file aswell.
Greets,
ScRaT
Thanks for using my script.
About German t-file - thanks ScRaT_GER for support, I will add it to next release.
About problem with
as documented -
P.S. My English not good, if someone can help me with documentation - it will be great.
P.P.S. I am now "young father", so I don't have enough time not only for scripts but and fir sleep too .
About German t-file - thanks ScRaT_GER for support, I will add it to next release.
About problem with
Code: Select all
$ware = call script lib.chem.strings: Mode = 'fill.spaces' Arg1=$ware, Arg2=30, Arg3='-', Arg4=null, Arg5=null
But I will add functionality to use any another type of value, not only strings.2.'fill.spaces' - you can create string with correct displayed width in player logbook, i.e. after using this function on, for example, strings "this is long string" and "small string", they will be filled by spaces up to they width in pixels (not symbols) will be equal.
Arg1 - source string, or string from text file by page id Arg1 and text id Arg2
Arg2 or Arg3- max len (in spaces, i.e. count of sybols " ")
Arg3 or Arg4- fill
P.S. My English not good, if someone can help me with documentation - it will be great.
P.P.S. I am now "young father", so I don't have enough time not only for scripts but and fir sleep too .
Multiply entropy by absolute zero
Ñâîáîäà ñðåäè çâåçä / Freedom in space
Ñâîáîäà ñðåäè çâåçä / Freedom in space
I think many people treat a long of the variable types as strings, since they generally return strings in use, but don't realise they are actually all different types. If you edit the functions to assign the passed argument to a new variable that would probably be sufficient for most cases I would think.
Gaming PC: Gigabyte H270M-D3H | i7 7700 | 16Gb DDR4 | Gigabyte GTX1060 6Gb OC | Asus Xonar DGX | Window 10 Home 64bit | Samsung 256Gb SSD
Hi,
it's me again. =)
The description says:
The coloured text also 'colours' the following texts.
For example if you want to display a text like this:
Your Ship with a super long name Flighttime: ...
and the Ships name is even longer (might happen), the following happens:
Your Ship with an even longer super l Flightime: ...
See what I'm trying to say?
It would be great if you could review this function, if you find the time.
Maybe add a "." at the end of the shortened string, so that it is clear, that it was shortened.
Greets,
ScRaT
it's me again. =)
The description says:
Strange effects can be observed when using coloured texts and strings which are longer, than the desired lenght.If length source string more then needed length - string will be truncated.
The coloured text also 'colours' the following texts.
For example if you want to display a text like this:
Your Ship with a super long name Flighttime: ...
and the Ships name is even longer (might happen), the following happens:
Your Ship with an even longer super l Flightime: ...
See what I'm trying to say?
It would be great if you could review this function, if you find the time.
Maybe add a "." at the end of the shortened string, so that it is clear, that it was shortened.
Greets,
ScRaT
Does this script also function correctly when aligning strings for use is custom menus? I am getting some very subtle alignment errors (as in off 1 or 2 spaces) when doing a multicolumn layout for a large custom menu.
In the readme for this script there is mention of maximum display width of 100. From what I can tell the max width on the large menu is 142 or 143 (Varies depending on string, which I think is what leads to alignment issues). Would this mess up the padding functions of the script?
EDIT: Don't have a pic of my menu, but you can see exactly what I am talking about in ScRaT's thread http://forum.egosoft.com/viewtopic.php?t=243204. See how the columns don't quite line up?
In the readme for this script there is mention of maximum display width of 100. From what I can tell the max width on the large menu is 142 or 143 (Varies depending on string, which I think is what leads to alignment issues). Would this mess up the padding functions of the script?
EDIT: Don't have a pic of my menu, but you can see exactly what I am talking about in ScRaT's thread http://forum.egosoft.com/viewtopic.php?t=243204. See how the columns don't quite line up?
Well, slight aligninging "errors" occur, if you are using a character, which does not exactly match its assigned size.
In the German t-file, for example, the letter "q" was missing. So I added it, which enhanced the alignment in some cases.
As you are mentioning my thread: I think it's okay and way better than without the alignment.
Maybe you can observe which strings are the ones that pop out the most and find their difference to the others. Like this I found the missing letter "q" (which is btw still missing in the English t-file afaik).
Greets,
ScRaT
In the German t-file, for example, the letter "q" was missing. So I added it, which enhanced the alignment in some cases.
As you are mentioning my thread: I think it's okay and way better than without the alignment.
Maybe you can observe which strings are the ones that pop out the most and find their difference to the others. Like this I found the missing letter "q" (which is btw still missing in the English t-file afaik).
Greets,
ScRaT
I agree that the alignment, even with small 'errors', is far superior to no alignment all. I just wanted to check and see if the small misalignments are the expected behavior, or 'operator error'. I will fiddle with the text file and see what I can come up with.ScRaT_GER wrote:As you are mentioning my thread: I think it's okay and way better than without the alignment.
Nice work by the way on your trade overview script ScRaT. Looks really good. May have to add that one to my collection!
i've added the missing "Q" and "q" to the english version.
8910-L044.xml
all other letters are there
@ScRaT_GER
i noticed in the file you posted here that it doesn't contain a lower case "q" is that intented?
8910-L044.xml
all other letters are there
@ScRaT_GER
i noticed in the file you posted here that it doesn't contain a lower case "q" is that intented?
No, it's not.
I simply forgot to check it, because I didn't notice alignment error in strings containing a lower case "q".
I'll check which changes can be made to make better.
Greets,
ScRaT
I simply forgot to check it, because I didn't notice alignment error in strings containing a lower case "q".
I'll check which changes can be made to make better.
Greets,
ScRaT
Last edited by ScRaT_GER on Sun, 26. Apr 09, 16:32, edited 1 time in total.
Since you'r checking, possibly the comma "," too. I've noticed alignment errors when commas appear, but haven't got around to checking yet. This is with the English files.
Gaming PC: Gigabyte H270M-D3H | i7 7700 | 16Gb DDR4 | Gigabyte GTX1060 6Gb OC | Asus Xonar DGX | Window 10 Home 64bit | Samsung 256Gb SSD
- Carlo the Curious
- Posts: 16999
- Joined: Mon, 5. Mar 07, 22:03
Colon and semi-colon (: and ;) seem to be missing as well (EN).
e.g.:
[ external image ]
Column 1 is left-justified and column 2 right-justified using fill.spaces (size 10).
e.g.:
[ external image ]
Column 1 is left-justified and column 2 right-justified using fill.spaces (size 10).
@strude it already contains a comma
updated the (EN) version with the missing colon and semi-colon.
8910-L044.xml
updated the (EN) version with the missing colon and semi-colon.
8910-L044.xml
I'm not really sure how it works. The comma is in the file, but perhaps it's not in the right section for it's screen width? Just seems that in a list of values, items that contain no commas are aligned, items that contain 1 comma are aligned, 2 commas are aligned, but each of these aren't aligned with each other. As in items with no commas don't align with items with 1 comma.draffutt wrote:@strude it already contains a comma
Gaming PC: Gigabyte H270M-D3H | i7 7700 | 16Gb DDR4 | Gigabyte GTX1060 6Gb OC | Asus Xonar DGX | Window 10 Home 64bit | Samsung 256Gb SSD
-
- Posts: 22
- Joined: Thu, 19. Nov 09, 00:44
Can't install script
How do i determen a valid directory for installation of script