To store permanent variable across sessions (that is, after you close and then open XY again) [Solved]
Posted: 06 Mar 2022 17:09
The following is a simple script that shows/hides hidden, system, and protected files in one step. It is assumed to be assigned to a user button on the toolbar.
The script works fine except that if the button is currently in the pressed state and you close XY and then open it again and then press the button again, the script won't know that the button is already in the pressed state, and so the first time you press it, nothing will happen.
To resolve this problem, we need to preserve the value of
My guess is that we can write
Any suggestions?
Code: Select all
"Show Everything"
perm $p_showHideState;
if (!regexmatches($p_showHideState, "(1|2)")) { $p_showHideState = 1; }
// #388 - Hide protected operating system files
// #493 - Show hidden files and folders
// #494 - Show system files and folders
// Show
if ($p_showHideState == 1) {
if (get("#388") == 1) { #388; }
if (get("#493") == 0) { #493; }
if (get("#494") == 0) { #494; }
$p_showHideState = 2;
ctbstate(1);
}
// Hide
elseif ($p_showHideState == 2) {
if (get("#388") == 0) { #388; }
if (get("#493") == 1) { #493; }
if (get("#494") == 1) { #494; }
$p_showHideState = 1;
ctbstate(0);
}
To resolve this problem, we need to preserve the value of
p_showHideState between XYplorer sessions. But how?My guess is that we can write
p_showHideState and its value as a key-value pair into XYplorer.ini and then read it from there. But I don't know whether this a posssible at all and whether this way is really good.Any suggestions?