Our new official repo is on github
LCD Smartie version 5.6 is released!
Download it now: https://github.com/LCD-Smartie/LCDSmartie/releases

Strlen.dll [UPDATED]

Announcements of new plugins or updates.

Moderators: _X7JAY7X_, caesar, IFR, mattcro, limbo

Post Reply
Randy_84dger
Posts: 4
Joined: September 11th, 2006, 10:57 pm
Contact:

Strlen.dll [UPDATED]

Post by Randy_84dger »

Presenting strlen.dll. Written to solve http://forums.lcdsmartie.org/viewtopic.php?t=823

:smt024 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 :D
You do not have the required permissions to view the files attached to this post.
Last edited by Randy_84dger on September 14th, 2006, 5:13 pm, edited 2 times in total.
cin
Posts: 8
Joined: August 15th, 2006, 1:00 pm

Post 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).
Randy_84dger
Posts: 4
Joined: September 11th, 2006, 10:57 pm
Contact:

Post by Randy_84dger »

You're right... done!
shinobi_h2o
Posts: 18
Joined: December 21st, 2007, 4:13 am
Location: Rio de Janeiro, RJ

Post 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!
Last edited by shinobi_h2o on December 29th, 2007, 1:39 pm, edited 1 time in total.
mattcro
Forum Supporter
Posts: 590
Joined: March 8th, 2006, 1:58 pm
Location: Scotland

Post 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:

Code: Select all

CPU: $Right($CPUUsage%,$3%)%
This will show CPU usage, where the percentage always takes exactly 3 spaces and is right-justified. This will look like:

Code: Select all

CPU: 100%
CPU:  42%
CPU:   5%
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().
shinobi_h2o
Posts: 18
Joined: December 21st, 2007, 4:13 am
Location: Rio de Janeiro, RJ

Post 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. :D

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:

Code: Select all

   CPU: 4%
Memory: 823
  Temp: 48C
"CPU", "Memory" and "Temp" would use $right, and their values would use "width".

Thanks a lot for the tip, man! =))
mattcro
Forum Supporter
Posts: 590
Joined: March 8th, 2006, 1:58 pm
Location: Scotland

Post 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.
shinobi_h2o
Posts: 18
Joined: December 21st, 2007, 4:13 am
Location: Rio de Janeiro, RJ

Post 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
Post Reply