It is currently September 21st, 2019, 10:19 pm

[Script] Path Parser

Discuss the use of Lua in Script measures.
User avatar
StArL0rd84
Posts: 336
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: [Script] Path Parser

StArL0rd84 » May 30th, 2017, 8:00 pm

Yeah sry about digging up this old post.
but tnx again balala, it worked.
Well, after i also added: if sOutput == 'Drive' then
return sDrive
At the bottom of the script.
I think i actually learned something about lua today. tnx
(#WorkTime# = 1 ? #Work# : ([mEnergyLoss:%] > 100 ? #SleepMode# : #Rainmeter#))
User avatar
balala
Rainmeter Sage
Posts: 8636
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: [Script] Path Parser

balala » May 30th, 2017, 8:12 pm

But to be honest, if you need just the drive letter, there is no need to use a lua script. A simple String measure can do the job.
Eg, the following [MeasureDrive] measure returns the needed letter:

Code: Select all

[Variables]
Path=C:\Path\To\File.txt

[MeasureDrive]
Measure=String
String=#Path#
RegExpSubstitute=1
Substitute="^(.):.*$":"\1:"
It's much more simpler and easier to use.