It is currently April 23rd, 2024, 10:28 pm

Help: Filelistplugin

Share and get help with Plugins and Addons
User avatar
Bonsitm
Posts: 10
Joined: July 12th, 2010, 11:28 am

Help: Filelistplugin

Post by Bonsitm »

Hello,

I've been trying to use the FilelistPlugin dll to make a 'hard disk' measure using the size of my Dropbox folder out of the 2GB allowance.

After messing around with the code I've found that the reason

Code: Select all

[dropboxmeasure]
measure=calc
Formula=2000-MeasureFolderSizeStr
doesn't work is that the MeasureFolderSizeStr function of the plugin returns a value containing the letter 'b' (as it measures filesizes in bytes).

Upon further investigation I found that any Formula with a number/letter, for example:

Code: Select all

Formula=50-48b
Simply behaves as though the '48b' in this example is the number 0, which is useless.

Is there a way to remove the 'b' from the measure output before using it to calculate the Dropbox use percentage?

Thanks in advance.
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: Help: Filelistplugin

Post by Chewtoy »

What kind of measure is the Dropbox measure?
It is not, from what I can see, a basic Measure=FreeDiskSpace as that would not return the 'b'.
Witch makes me believe you are getting this from the net (it is DropBox after all). And by that using a WebParser-measure. Then it's a simple matter of substitute away the letter. Substitute="b":"" and it should be gone. And I notice now that you said 'plugin' but I'm to lazy to come up with something else to write.

Anyway. If the calc as you have it thinks that it's a string you're trying to subtract with, you can fool it by passing the returned value through an 'empty' calc before you do the operation. So you just have a calc with Formula=MeasureFolderSizeStr and then use that calc in your real calc that actually do something.
I don't think, therefore I'm not.
User avatar
Bonsitm
Posts: 10
Joined: July 12th, 2010, 11:28 am

Re: Help: Filelistplugin

Post by Bonsitm »

Hi, thanks for the fast reply.
Dropbox is a web service that sychronises a folder on your pc with its server, so my Dropbox folder is a real folder on my computer.
I have tried a combination of the fooling empty calc and removing the 'b' with a substitution, but still no success.
I'll keep trying though.
User avatar
Alex2539
Rainmeter Sage
Posts: 642
Joined: July 19th, 2009, 5:59 am
Location: Montreal, QC, Canada

Re: Help: Filelistplugin

Post by Alex2539 »

Could you post the entirety of your code? The problem is not only with the calc, but also potentially with the source measure.

I'm guessing from the topic title that MeasureFolderSizeStr is using the FileListPlugin to read the size of the dropbox folder. If that's the case, then your problem is that it returns the value as a string, not a number. You will need to add a substitution to get rid of the characters that Calc does not understand. First, make sure that the measure does not contain the line "Format=Dynamic" or "Format=KBytes". Then, add the following line to your measure:

Code: Select all

Substitute=",":"" , "b":""
As far as I know, the only characters you need to get rid of are the commas that separate the thousands and the "b" at the end. This line should force the measure to return the size of the folder in bytes. Next, the calc measure should look like this:

Code: Select all

Measure=Calc
Formula=2*(2**30)-[MeasureFolderSizeStr0]
DynamicVariables=1
The first bit, "2*(2**30)", calculates the number of bytes in 2 GB (ie: your dropbox limit). I don't know why you were using 2000, but that number is incorrect. The folder's size is measured in bytes. There are 1024 bytes in a kilobyte, 1024 kilobytes in a megabyte and 1024 megabytes in a gigabyte. That means that one gigabyte is 1024 x 1024 x 1024 bytes. Since 1024 is actually 210, I've just simplified that into "1 gigabyte = 230 bytes" (in Rainmeter, the symbol for exponents is "**"). Then since you have 2 GB of storage, you just need to double that number.

The second part of that formula is the important part. Because we want the Calc measure to use the value from the other measure after the substitution, we must use it as a dynamic variable. To do that, you simply add [Square Brackets] around the measure's name, and then add the line "DynamicVariables=1" at the end.

And there you have it. That should measure the amount of space you have left in your dropbox folder.
ImageImageImageImage
User avatar
Bonsitm
Posts: 10
Joined: July 12th, 2010, 11:28 am

Re: Help: Filelistplugin

Post by Bonsitm »

That works! You're amazing! Thank you very much! :D
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help: Filelistplugin

Post by jsmorley »

"2*(2**30)"

Now you are just showing off.. ;-) For those not in the Borg Collective, he means 2*1073741824

:-)
User avatar
Bonsitm
Posts: 10
Joined: July 12th, 2010, 11:28 am

Re: Help: Filelistplugin

Post by Bonsitm »

It does look complicated, but I was able to follow having recently finished A-Level Maths. I just looked up '**' and saw what it meant. Thanks for the help!