Page 1 of 1
Strlen.dll [UPDATED]
Posted: September 13th, 2006, 1:28 pm
by Randy_84dger
Presenting strlen.dll. Written to solve
http://forums.lcdsmartie.org/viewtopic.php?t=823

UPDATE: Improved as per cin's suggestion. (should probably have done that initially).
README.txt:
INFORMATION
-----------
This plugin was written to allow functions based on the length of strings.
Based on DemoC++Plugin.
FUNCTIONS
---------
Contains two functions:
Function1: $dll(strlen,1,XXXX,1)
Returns the length of XXXX. (param2 not used)
Function2: $dll(strlen,2,XXXX#YY,ZZZZ)
Returns ZZZZ if length(XXXX) > YY.
Hope someone else finds it useful

Posted: September 14th, 2006, 1:16 pm
by cin
I think you should make it more universal - the length (20) should be passed as a parameter. It is suitable only for 20 characters width - not usable for 16 or others. You know you can put # to add more params (of course it can be any other character, but # became some standard when more than 2 params are needed).
Posted: September 14th, 2006, 4:34 pm
by Randy_84dger
You're right... done!
Posted: December 29th, 2007, 2:20 am
by shinobi_h2o
Damn, I was so happy when I found this plugin! Pitty it doesn't do what I thought... lol
I have this problem: I'm making a plugin to show some telemetry data from GTR2. And I wanted to spread the four tyre's temperatures across the screen so that they wouldn't keep moving if they occupied more then 2 characters each.
For example: (space)99(three spaces)99
Then if the front left tyre goes up to 100, it would remove one of the spaces...
I thought I could have used the function2 like this:
$dll(strlen,2,[space][tyretemperature][space]#4,[space][tyretemperature])
But it returns nothing. :-\
I can't seem to find a plugin that does this... :-\
I didn't really find a utility for the second function when xxxx is lesser then yy, but it's a nice plugin anyway! =)
Keep up the good work, bro!
Posted: December 29th, 2007, 11:59 am
by mattcro
Re shinobi's problem (I see you've found a solution with the width plugin)... you can do this with Smartie's built-in $Right() command:
This will show CPU usage, where the percentage always takes exactly 3 spaces and is right-justified. This will look like:
There is a limit to this, though. If you have a variable number of decimal places in the value you want to display, you'll need a proper formatting plugin. Also, there doesn't seem to be an equivalent $Left() command.
Read the
Smartie Commands page for info on $Right().
Posted: December 29th, 2007, 1:36 pm
by shinobi_h2o
Thanks mattcro, but it would be more like a $left plugin... lol
The Width.dll did the job perfectly!
It keeps writing from the left, only reserving a blank character on the right in case the numbers rise from two-digits to three-digits.
In the case you posted (CPU Usage, mem etc), I think I would also use the width plugin on the values, and the $right on the names, because I like this "left cell aligned right, right cell aligned left" format, like the credits screen at the end of most movies. lol
Like this:
"CPU", "Memory" and "Temp" would use $right, and their values would use "width".
Thanks a lot for the tip, man! =))
Posted: December 29th, 2007, 10:39 pm
by mattcro
Ah, gotcha - yes, a $Left() would probably do the trick for your layout if it existed...
You may also be able to use $Fill(), which places the following text at a specified position, for example:
Code: Select all
CPU: $CPUUsage%%$Fill(10)$Time(hh:nn)
The time will always be displayed at horizontal position 11, regardless of how many digits (1, 2 or 3) are displayed for CPU percentage.
There's probably not much point in using $Right() for the names, since you can position them using a few space characters in the layout to align them.
The way I have my screens laid out, $Right() does what I need. I like to have the numbers right-justified, so the "%", "C", "MB" or whatever stays in the same place and there is space to the left of it for however many digits I need.
It's probably time some of these formatting plugins were integrated into Smartie in the style of $Right() etc, instead of having loads of lengthy DLL call commands.
Posted: December 30th, 2007, 5:17 am
by shinobi_h2o
Oh damn, I didn`t know what $fill was for.
So much simpler... :-\ lol
But it's not really a problem, since I only wrote this $width once, copied to a notepad and kept copying everything, only changing the numbers in my plugin. lol
I'm thinking about adding some other functions to my plugin, maybe with Limbo's $round and such, because the commands are too long, and LCDSmartie is invoking too much different DLLs. lol
It's supposed to run with a racing game, pulling data off it's shared memory, so it's a good idea to keep the resources usage low, right? Heheh
I'm also a bit disappointed with myself because I couldn't find any kind of IPC (Interprocess Comm) with VB.NET 1.1.
First I was trying to use the clipboard, which is memory based, no TPC hassles, and quite fast. But it in fact annoyed me to click-once /click "Pause", copy the new-built DLL, paste, click-once/click "Run", and since I was having problems with the data types, I fallowed Limbo's suggestion to use the registry. But I'm still looking forward for some true IPC, real "elegant" (read: EFFICIENT!). lol
If you have any info, please gimme a call.
Thanks for the help, bro! I'll see if I can reduce the DLLs usage in my plugins.
P.S.: Sorry if I'm being repetitive, I'm kinda high right now. lol
Thank god Firefox underlines unrecognized words! LOL