It is currently April 30th, 2024, 9:06 am

Use fileview plugin to define a variable

Get help with creating, editing & fixing problems with skins
Hylia
Posts: 10
Joined: September 20th, 2022, 12:57 am

Use fileview plugin to define a variable

Post by Hylia »

I'm sure this is probably easier than it seems to me at the moment, but I have spent the past few days trying to figure out how to do this. Basically, as the title says, I want to use the fileview plugin to retrieve the names of folders, and then go on to define variables using the retrieved folder names to be used in a context menu. This seems like it should be a relatively simple thing to do, but all usage and documentation I can find on the plugin has been for using it for meters.
So far I've tried something along the lines of

Code: Select all

[MeasureProfileList]
Measure=Plugin
Plugin=FileView
Path=#ROOTCONFIG#Settings\Profiles
ShowDotDot=0
ShowFile=0
ShowFolder=1
Count=15

[Profile01Measure]
Measure=Plugin
Plugin=FileView
Path=[MeasureProfileList]
Type=FileName
Index=1
OnRefreshAction=[!WriteKeyValue Variables Profile01 "%1" "#ROOTCONFIG#Settings\Settings.inc"]

[Profile01String]
Meter=String
Measure=Profile01Measure 
;OnRefreshAction=[!WriteKeyValue Variables Profile01 "%1" "#ROOTCONFIG#Settings\Settings.inc"]
Additionally, I tried the syntax of #CURRENTSECTION# in place of %1, but still nothing. Settings.inc is getting updated but nothing is actually getting changed. I'm sure I'm missing something obvious but I can't figure out what
Last edited by Hylia on March 2nd, 2023, 9:25 pm, edited 1 time in total.
User avatar
balala
Rainmeter Sage
Posts: 16189
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Use fileview plugin to define a variable

Post by balala »

Hylia wrote: March 2nd, 2023, 6:46 am Basically, as the title says, I want to use the fileview plugin to retrieve the names of folders, and then go on to define variables using the retrieved folder names to be used in a context menu.
There are a few issues with the posted code, namely:
  • The Path option of the parent [MeasureProfileList] measure is wrong, because the #ROOTCONFIG# variable doesn't include a backslash, which is needed in a path. So theoretically (but just theoretically, see bellow as well) the Path option should be Path=#ROOTCONFIG#\Settings\Profiles. But neither this will work, because #ROOTCONFIG# is just a name of a folder, not its path. To get the measure working, replace the above Path option by something like Path=#ROOTCONFIGPATH#Settings\Profiles. #ROOTCONFIGPATH# in this case is a full path, for instance C:\Users\YourName\Documents\Rainmeter\Skins\illustro\ and does include the final backslash, which this way is not needed anymore to be added once more.
  • OnRefreshAction can't be used on a measure. This option belongs to the [Rainmeter] section and has to be used there. Not sure when do you want to write the variable as set in the !WriteKeyValue bang of the mistakenly used OnRefreshAction, but most probably you should use either an OnChangeAction or an OnUpdateAction option instead of OnRefreshAction (however none of this doesn't really make sense on a first look). So when would you like to write the Profile01 variable?
  • Besides this, even if the !WriteKeyValue bang would be used into a proper option, it doesn't write the value, because %1 doesn't make sense in this case. The bang should look for instance this way: [!WriteKeyValue Variables Profile01 "[Profile01Measure]" "#ROOTCONFIGPATH#Settings\Settings.inc"], at least assuming that you want to write the value of the [Profile01Measure] measure. Note that I also extended the #ROOTCONFIG# variable in the "#ROOTCONFIG#Settings\Settings.inc" path to #ROOTCONFIGPATH#, due to the exact same reasons as those described in the first point above:
    • #ROOTCONFIG# is not a full path, but the last parameter of the !WriteKeyValue bang has to be a full path of a file, in which the bang writes the value.
    • Even if it would be a path, #ROOTCONFIG# doesn't include a backslash, so the path anyway would be incorrect (see the explanation above).
  • Besides this, if you altered the !WriteKeyValue bang as described here, you have to add a DynamicVariables=1 option to the [Profile01Measure] measure, because the !WriteKeyValue bang of the option, uses a section variable ([Profile01Measure]) and these variables require setting on the dynamic variables.
  • Finally there is no Measure option on String meters (and in fact this option can be used only on measures, to establish the type of measure). You probably thought to a MeasureName option, but you wrote only Measure=.
Not sure where you want to use the Profile01 variable into the context menu, but this probably is another story. For first, try out the things I described above and let me know if you got it working, please.
Hylia
Posts: 10
Joined: September 20th, 2022, 12:57 am

Re: Use fileview plugin to define a variable

Post by Hylia »

balala wrote: March 2nd, 2023, 7:25 pm There are a few issues with the posted code, namely:
  • The Path option of the parent [MeasureProfileList] measure is wrong, because the #ROOTCONFIG# variable doesn't include a backslash, which is needed in a path. So theoretically (but just theoretically, see bellow as well) the Path option should be Path=#ROOTCONFIG#\Settings\Profiles. But neither this will work, because #ROOTCONFIG# is just a name of a folder, not its path. To get the measure working, replace the above Path option by something like Path=#ROOTCONFIGPATH#Settings\Profiles. #ROOTCONFIGPATH# in this case is a full path, for instance C:\Users\YourName\Documents\Rainmeter\Skins\illustro\ and does include the final backslash, which this way is not needed anymore to be added once more.
  • OnRefreshAction can't be used on a measure. This option belongs to the [Rainmeter] section and has to be used there. Not sure when do you want to write the variable as set in the !WriteKeyValue bang of the mistakenly used OnRefreshAction, but most probably you should use either an OnChangeAction or an OnUpdateAction option instead of OnRefreshAction (however none of this doesn't really make sense on a first look). So when would you like to write the Profile01 variable?
  • Besides this, even if the !WriteKeyValue bang would be used into a proper option, it doesn't write the value, because %1 doesn't make sense in this case. The bang should look for instance this way: [!WriteKeyValue Variables Profile01 "[Profile01Measure]" "#ROOTCONFIGPATH#Settings\Settings.inc"], at least assuming that you want to write the value of the [Profile01Measure] measure. Note that I also extended the #ROOTCONFIG# variable in the "#ROOTCONFIG#Settings\Settings.inc" path to #ROOTCONFIGPATH#, due to the exact same reasons as those described in the first point above:
    • #ROOTCONFIG# is not a full path, but the last parameter of the !WriteKeyValue bang has to be a full path of a file, in which the bang writes the value.
    • Even if it would be a path, #ROOTCONFIG# doesn't include a backslash, so the path anyway would be incorrect (see the explanation above).
  • Besides this, if you altered the !WriteKeyValue bang as described here, you have to add a DynamicVariables=1 option to the [Profile01Measure] measure, because the !WriteKeyValue bang of the option, uses a section variable ([Profile01Measure]) and these variables require setting on the dynamic variables.
  • Finally there is no Measure option on String meters (and in fact this option can be used only on measures, to establish the type of measure). You probably thought to a MeasureName option, but you wrote only Measure=.
Not sure where you want to use the Profile01 variable into the context menu, but this probably is another story. For first, try out the things I described above and let me know if you got it working, please.

Thank you so much, this is exactly what I needed. Idk how I didn't notice that it was supposed to be ROOTCONFIGPATH, I've used it in this skin many times haha.
User avatar
balala
Rainmeter Sage
Posts: 16189
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Use fileview plugin to define a variable

Post by balala »

Hylia wrote: March 2nd, 2023, 9:25 pm Thank you so much, this is exactly what I needed.
I'm glad.
Hylia wrote: March 2nd, 2023, 9:25 pm Idk how I didn't notice that it was supposed to be ROOTCONFIGPATH, I've used it in this skin many times haha.
Don't worry, it happens.