It is currently April 25th, 2024, 3:40 am

Powershell output empty

Get help with creating, editing & fixing problems with skins
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Powershell output empty

Post by StArL0rd84 »

I have this list of resolutions I wish to reorder by the number of pixels in each resolution.
startoffile
640x480
720x480
800x600
1024x768
1152x864
1176x664
1280x720
1280x768
1280x800
1280x960
1280x1024
1360x768
1366x768
1600x900
1600x1024
1600x1200
1680x1050
1920x1080
1920x1200
1920x1440
2560x1440
3840x1080
5120x1440
1440x900
720x576
endoffile
I am reading the list, and formatting it into an array, so I can use it in PowerShell to do the math.

Code: Select all

[mArray]
Measure=String
String=[mDeduplicate]
DynamicVariables=1
UpdateDivider=-1
Substitute="startoffile#CRLF#":'(',"#CRLF#":'), (',", (endoffile), (":'',"x":'*'
OnChangeAction=[!CommandMeasure mArrayMath "run"]

[mArrayMath]
Measure=Plugin
Plugin=RunCommand
Program=PowerShell.exe
Parameter='$A = [&mArray] #CRLF#for ($i = 0; $i -lt $A.Length; $i++){$A[$i]}'
State=Hide
OutputType=UTF8
OutputFile=#@#txt\5_Array.txt
DynamicVariables=1
It does NOT work if I call for the array using [mArray] or [&mArray]
$A = [&mArray] #CRLF#for ($i = 0; $i -lt $A.Length; $i++){$A[$i]}

But I can get it to work using the raw data like this:
$A = (640*480), (720*480), (800*600), (1024*768), (1152*864), (1176*664), (1280*720), (1280*768), (1280*800), (1280*960), (1280*1024), (1360*768), (1366*768), (1600*900), (1600*1024), (1600*1200), (1680*1050), (1920*1080), (1920*1200), (1920*1440), (2560*1440), (3840*1080), (5120*1440), (1440*900), (720*576)
for ($i = 0; $i -lt $A.Length; $i++){$A[$i]}


Not really sure about all the details of the code since I'm a novice, and I copied the code from somewhere I can't find again.
What I DO know is, that we are loading the array in the variable $A and doing work on it.
But it's like the variable is empty in Rainmeter, and that's what PowerShell processes and outputs.

ar.png
ps.png
If there's a way to reorder the list of resolutions by number of pixels, some other way, like a calc measure or a lua script, I'm all ears.
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Powershell output empty

Post by balala »

StArL0rd84 wrote: November 6th, 2022, 11:47 am It does NOT work if I call for the array using [mArray] or [&mArray]
The [mArray] measure is never updating, due to its UpdateDivider=-1 option. Accordingly, its value is never changing, so its OnChangeAction option is never executed. But even if you remove the UpdateDivider=-1 option, if it might not change, to get the OnChangeAction executed. Depends on the not posted [mDeduplicate] measure if it does.
For first you should check if the OnChangeAction option of the [mArray] measure is executed. If it isn't, check if the value of the measure changes. I don't know what you should do, especially because I don't know the whole code. So, if you can't find a solution, please post the whole code, not just a snippet. Or if resources are involved, pack the config and upload it. Many depends on the rest of the code.
User avatar
StArL0rd84
Posts: 424
Joined: February 8th, 2015, 10:07 pm
Location: EU, Denmark.

Re: Powershell output empty

Post by StArL0rd84 »

balala wrote: November 6th, 2022, 12:51 pm The [mArray] measure is never updating, due to its UpdateDivider=-1 option. Accordingly, its value is never changing, so its OnChangeAction option is never executed. But even if you remove the UpdateDivider=-1 option, if it might not change, to get the OnChangeAction executed. Depends on the not posted [mDeduplicate] measure if it does.
For first you should check if the OnChangeAction option of the [mArray] measure is executed. If it isn't, check if the value of the measure changes. I don't know what you should do, especially because I don't know the whole code. So, if you can't find a solution, please post the whole code, not just a snippet. Or if resources are involved, pack the config and upload it. Many depends on the rest of the code.
You where right. But I'm still a little confused.
Can't see why [mArray] can't have UpdateDivider=-1 if [mDeduplicate] updates it.
User avatar
balala
Rainmeter Sage
Posts: 16168
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Powershell output empty

Post by balala »

StArL0rd84 wrote: November 6th, 2022, 1:47 pm You where right. But I'm still a little confused.
This means did you get it working?
StArL0rd84 wrote: November 6th, 2022, 1:47 pm Can't see why [mArray] can't have UpdateDivider=-1 if [mDeduplicate] updates it.
Not knowing the code (not even the [mDeduplicate] measure), have no idea. This is why i asked for the whole code.