Something like a shell's "profile"? [SOLVED]

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
Filehero
Posts: 2732
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Something like a shell's "profile"? [SOLVED]

Post by Filehero »

Hi,

did a search with different combinations of "autoload", "perm" "global", "variable", "profile" etc., but straight from the result subjects I rather had no luck yet. Nevertheless, I'd like to apologize for any overlooks in advance. :wink:

"problem/challenge":
two different running contexts (vulgo: computers) will _generally_ differ in their root paths only. So, apart from their physical and logical layers (partitions and drives), below individual root paths either XY-host will exhibit an identical folder/file organisation.
This calls for 'profiles' - autostarted/autoloaded root scripts defining the basic environment everything else that will be "called" is derived from/based upon.

How can this be achieved in an "easily" maintainable way?


Thanks & cheers,
Filehero

PS: Hope, I'm not about to become the forum's dumb a** ...
PS 2: Edits in italic
Last edited by Filehero on 02 Mar 2012 20:32, edited 1 time in total.

nas8e9
Posts: 2232
Joined: 21 Jun 2008 14:50

Re: Something like a shell's "profile"?

Post by nas8e9 »

I'm not sure I understand: since Windows Vista, the Windows partition is always assigned the letter C:, meaning any location on the system drive can be relied upon to start with C:\.

If you're running Windows XP, there's the Windows %SystemDrive% and XYplorer's native <xydrive> variables.

If you need to refer to non-system partitions (e.g. D:\), you could define a global Windows variable (on Windows 7 through Control Panel > System > Advanced system settings > Advanced > Environment variables). AFAIK XYplorer supports Windows variables when defining locations.

Filehero
Posts: 2732
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: Something like a shell's "profile"?

Post by Filehero »

Hi nas8e9,

thank you for your reply. :)

No, unfortunately I'm not relying on window's world wide canonical folders. But I should better try to give a better example ('backup'), so here I go:
Computer 1's path for backup --> D:\$targetPath
Computer 2's path for backup --> C:\Data\$targetPath

My goal: the _global and portable_ script should care for '$targetPath', the _local profile_ (script?) cares for the differing upstream paths ("D:\" and "C:\Data").


Cheers,
Filehero

nas8e9
Posts: 2232
Joined: 21 Jun 2008 14:50

Re: Something like a shell's "profile"?

Post by nas8e9 »

Filehero wrote:No, unfortunately I'm not relying on window's world wide canonical folders. But I should better try to give a better example ('backup'), so here I go:
Computer 1's path for backup --> D:\$targetPath
Computer 2's path for backup --> C:\Data\$targetPath

My goal: the _global and portable_ script should care for '$targetPath', the _local profile_ (script?) cares for the differing upstream paths ("D:\" and "C:\Data").
I think your best bet for the upstream path at least (computer-specific) is Windows system variables, which work for both regular as well as portable installations: the variable is set per-computer. I've tested XYplorer's system variable support, and they're even resolved within the address bar (e.g. enter %SystemDrive% and see how XYplorer changes the AB icon to that for the system drive).

I'm not clear what your requirements are for $targetpath: if it's similar to the upstream path in that it can be set once and for all per computer, a system variable should work?

Filehero
Posts: 2732
Joined: 27 Feb 2012 18:50
Location: Windows 11@100%

Re: Something like a shell's "profile"? [Solved]

Post by Filehero »

nas8e9 wrote:I'm not clear what your requirements are for $targetpath: if it's similar to the upstream path in that it can be set once and for all per computer, a system variable should work?
Yes, the $targetpath is supposed to be the same.

You're right, system variables is the obvious way to go. But there are two reasons, why I do look for alternative ways.
First, I'm simply exploring XYPlorer's possibilities. Secondly, and more relevant, I'm always trying to setup my "environments" as self-contained as possible. Especially, since XYPlorer is portable.

In the help file I've found a section mentioning a way to make variables persisting sessions. I'll try that soon, if it works the way I suppose (as soon as a permanent variable statement gets evaluated, the key/value pair ist written into the .ini ar any other file) I simply have to run this statement with "Run script" once and I'm done.

Will report back....

Edit: It exactly works that way!!
:arrow: Simply switch on "Configuration/Extended/Scripting/Remember permanent variables" (restart required) and the values become persistent. Really cool ...
:D :D :D

And a small test snippet:

Code: Select all

"1. Create persistency ..."
  $p_Perm = "I'm the survivor!";
  msg $p_Perm;
  perm $p_Perm;
  
// now close all running XPlorer sessions to assure RAM cleanup and restart
"2. Check persistency ..."
  msg $p_Perm;

"3. Remove persistency ..."
  unset $p_Perm;
  
// now close all running XPlorer sessions to assure RAM cleanup and restart
"4. Check persistency again..."
  msg $p_Perm; // the value should be gone now, and the variable identifier literal displayed instead

Cheers,
Filehero

Post Reply