cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Georg
Level VII

How to check whether a preference is set and how

I would like to check, whether a preference is set to a certain value, but with JSL I cannot retrieve the value to compare it in an if statement etc. and react upon situation. Get Preferences returns something, but what excactly is it and how to proceed with it?

 

Names Default To Here( 1 );

// Task: what is the preference set to
prefs = Get Platform Preference( Control chart builder( K sigma ) );

// hover over prefs shows the result correctly, but how to retrieve it,
// e.g. as a string?

// what type is this? JMP gives no answer
Type( prefs );

// it has a length
length(prefs);

// this does not work
Log Capture( Get Platform Preference( Control chart builder( K sigma ) ) );
Georg
1 ACCEPTED SOLUTION

Accepted Solutions
hogi
Level XI

Re: How to check whether a preference is set and how

The returned value is a command to set the preferences as they are at the moment.

You could convert the command to a string, parse it and check if the option is enabled or disabled:

 

returnedString=Char(Get Platform Preference( Control chart builder( K sigma ) ));
Regex(returnedString,"(on|off)","\1")

View solution in original post

3 REPLIES 3
hogi
Level XI

Re: How to check whether a preference is set and how

The returned value is a command to set the preferences as they are at the moment.

You could convert the command to a string, parse it and check if the option is enabled or disabled:

 

returnedString=Char(Get Platform Preference( Control chart builder( K sigma ) ));
Regex(returnedString,"(on|off)","\1")
Georg
Level VII

Re: How to check whether a preference is set and how

Thanks @hogi , that worked perfectly. I was irritated, because I assigned the preference command to a variable, and then cast to character didn't work. But it's the magic of JSL.

 

returnedCommand = Get Platform Preference( Control chart builder( K sigma ) );
// this gives nothing:
show(char(returnedCommand));

returnedString=Char(Get Platform Preference( Control chart builder( K sigma ) ));
// this works
show (returnedString);
Georg
vince_faller
Super User (Alumni)

Re: How to check whether a preference is set and how

Couldn't you also check the literal as an expression? 

 

Names default to here(1);
Get Platform Preference( Control chart builder( K sigma ) ) == Expr(Platform Preferences( Control chart builder( K Sigma( 3, <<Off ) ) ));
// for me this returned 1
Vince Faller - Predictum