cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

JMPer Cable

A technical blog for JMP users of all levels, full of how-to's, tips and tricks, and detailed information on JMP features
%3CLINGO-SUB%20id%3D%22lingo-sub-453800%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3EVerwendung%20der%20!%20(NOT)-Operator%20und%20wie%20Sie%20ihn%20in%20Ihrem%20JSL-Code%20n%C3%BCtzlich%20machen%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-453800%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3E%3CP%3EEin%20n%C3%BCtzliches%20Werkzeug%20zum%20Bearbeiten%20boolescher%20Ausgaben%2C%20das%20!%20(NOT)-Operator%20in%3CA%20href%3D%22https%3A%2F%2Fwww.jmp.com%2Fen_us%2Fsoftware%2Fdata-analysis-software.html%3Futm_campaign%3Dtd%26amp%3Butm_source%3Djmpercable%26amp%3Butm_medium%3Dsocial%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3E%20JMP%3C%2FA%3E%20kann%20auch%20andere%20wertvolle%20Anwendungen%20haben%2C%20z.%20B.%20die%20Verwendung%20mit%20Contains()%20in%20der%20an%20JMP-Datentabellen%20gesendeten%20%26lt%3B%3CSELECT%20where%3D%22%22%3E%0A%3C%2FSELECT%3E%3C%2FP%3E%3CP%3ELassen%20Sie%20uns%20hier%20zun%C3%A4chst%20klarstellen%2C%20dass%20es%20sich%20um%20die%20Verwendung%20von%20!%20handelt.%20als%3CA%20href%3D%22https%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2Fen%2F16.0%2Findex.shtml%23page%2Fjmp%2Foperators.shtml%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%20Operator%3C%2FA%3E%20und%20nicht%20als%20syntaktisches%20Werkzeug%2C%20das%20in%20verwendet%20wird%3CA%20href%3D%22https%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2Fen%2F16.1%2F%23page%2Fjmp%2Fjsl-syntax-rules.shtml%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%20Escape-Sequenzen%3C%2FA%3E%20in%20zitierten%20Zeichenfolgen%3B%20In%20diesen%20F%C3%A4llen%20hat%20es%20nicht%20die%20Bedeutung%20NOT.%3C%2FP%3E%0A%3CP%3ESie%20k%C3%B6nnen%20sich%20vorstellen%20!%20wie%20jede%20andere%3CA%20href%3D%22https%3A%2F%2Fwww.jmp.com%2Fsupport%2Fhelp%2Fen%2F16.0%2Findex.shtml%23page%2Fjmp%2Foperators.shtml%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3E%20Operator%3C%2FA%3E%20im%20JMP.%20Sie%20kennen%20wahrscheinlich%20die%20gebr%C3%A4uchlichsten%3A%20Addieren%20(%2B)%2C%20Subtrahieren%20(-)%2C%20Multiplizieren%20(*)%2C%20Dividieren%20(%2F)%20usw.%20Im%20Allgemeinen%20ist%20ein%20Operator%20ein%20aus%20einem%20oder%20zwei%20Zeichen%20bestehendes%20Symbol%2C%20das%20zum%20Ausf%C3%BChren%20allgemeiner%20arithmetischer%20Aktionen%2C%20zum%20Vergleichen%20von%20Werten%2C%20zum%20Erstellen%20von%20Listen%2C%20zum%20Indexieren%20in%20ein%20Datenelement%2C%20zum%20Senden%20von%20Nachrichten%2C%20zum%20Verketten%20von%20Listen%2C%20zum%20Verkn%C3%BCpfen%20von%20Bereichsnamen%2C%20zum%20Zusammenf%C3%BCgen%20von%20Ausdr%C3%BCcken%20und%20zum%20Beenden%20von%20Ausdr%C3%BCcken%20verwendet%20wird%20.%3C%2FP%3E%0A%3CP%3EDer%20!%20Das%20Zeichen%20(h%C3%A4ufig%20als%20%E2%80%9EBang%E2%80%9C-Zeichen%20bezeichnet)%20in%20JMP%20wird%20im%20JSL-Code%20als%20Operator%20verwendet%2C%20um%20ein%20logisches%20NICHT%20anzugeben%2C%20was%20im%20Kontext%20boolescher%20Werte%20(wahr%20oder%20falsch)%20bedeutet%2C%20dass%20es%20einen%20Wert%20ungleich%20Null%20(oder%20wahr)%20abbildet%20)-Werte%20auf%200%20(was%20%E2%80%9Efalsch%E2%80%9C%20bedeutet)%20und%20ordnet%200-Werte%20(0%20oder%20falsch)%20auf%201%20(was%20%E2%80%9Ewahr%E2%80%9C%20bedeutet)%20zu.%3C%2FP%3E%0A%3CP%3EHier%20sind%20einige%20einfache%20Beispiele%20f%C3%BCr%20seine%20Verwendung%3A%3C%2FP%3E%0A%3CP%3EBeispiel%201%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Ex%20%3D%201%3B%0A!x%3B%0A%2F%2FLOG%20RESULT%3A%200%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EBeispiel%202%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Ex%20%3D%200%3B%0A!x%3B%0A%2F%2FLOG%20RESULT%3A%201%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EBeispiel%203%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3E!(1%20%26lt%3B%202)%3B%0A%2F%2FLOG%20RESULT%3A%200%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EWenn%20Sie%20es%20mit%20anderen%20Operatoren%20gruppieren%2C%20k%C3%B6nnen%20Sie%20davon%20ausgehen%2C%20dass%20es%20zu%20anderen%20%E2%80%9Elogischen%E2%80%9C%20Operatoren%20wie%20OR%20(%7C)%20und%20AND%20(%26amp%3B)%20geh%C3%B6rt%2C%20die%20normalerweise%20in%20If()-Anweisungen%20verwendet%20werden.%3C%2FP%3E%0A%3CP%3EBeispiel%201%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Ex%20%3D%204%3B%0A%2F%2FCheck%20if%20x%20is%20NOT%20equal%20to%202%20or%203%0AIf(%20x%20!%3D%202%20%26amp%3B%20!(x%20%3D%3D%203)%2C%0A%20%20%20Show(%22Not%20Equal%20to%202%20or%203%22)%2C%0A%20%20%20Show(%22Equal%20to%202%20or%203%22)%0A)%3B%0A%2F%2FLOG%20RESULT%3A%20%22Not%20Equal%20to%202%20or%203%22%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CEM%3EHinweis%3A%20Beachten%20Sie%20hier%2C%20dass%20Sie%20NOT%20Equal%20mit%20!%3D%20oder%20dem%20Hinzuf%C3%BCgen%20von%20!%20best%C3%A4tigen%20k%C3%B6nnen.%20vor%20dem%20gesamten%20Gleichheitsausdruck%2C%20z.%20B.%20!(x%3D%3D3).%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3EBeispiel%202%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Estr%20%3D%20%22hello%20world%22%3B%0A%2F%2FCheck%20if%20str%20does%20NOT%20contain%20the%20letter%20%22o%22%0AIf%20(!Contains(str%2C%22o%22)%2C%0A%20Show(%22Does%20not%20contain%20o%22)%2C%0A%20Show(%22Contains%20o%22)%0A)%3B%0A%2F%2FLOG%20RESULT%3A%20%22Contains%20o%22%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EEs%20gibt%20viele%20Situationen%2C%20in%20denen%20die%20Verwendung%20hilfreich%20sein%20kann!%20wobei%20es%20nicht%20auf%20Ihre%20If()-Anweisungen%20wie%20oben%20beschr%C3%A4nkt%20ist.%20Wir%20haben%20ein%20Beispiel%20f%C3%BCr%20die%20Verwendung%20von%20!%20gesehen.%20mit%20Contains()%2C%20aber%20gehen%20wir%20noch%20etwas%20weiter.%20Eine%20klassische%20Verwendung%20von%20Contains()%20ist%20im%20Kontext%20einer%20%26lt%3B%26lt%3B%20Select%20Where()-Nachricht%2C%20wie%20in%20diesem%20Beispiel%20gezeigt%3A%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Open(%22%24SAMPLE_DATA%2FBig%20Class.jmp%22)%3B%0A%2F%2FSelect%20Rows%20in%20the%20table%20that%20do%20not%20contain%20the%20letter%20%22A%22%20for%20%3Aname%20column%0A%3CFONT%20color%3D%22%23000000%22%3Edt%20%26lt%3B%26lt%3B%20Select%20Where%20(!Contains(%3Aname%2C%20%22A%22))%3B%0A%3C%2FFONT%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%3CSTRONG%3EDas%20ist%20das%20Gleiche%20wie%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Open(%22%24SAMPLE_DATA%2FBig%20Class.jmp%22)%3B%0A%2F%2FSelect%20Rows%20in%20the%20table%20that%20do%20not%20contain%20the%20letter%20%22A%22%20for%20%3Aname%20column%0Adt%20%26lt%3B%26lt%3B%20Select%20Where%20(Contains(%3Aname%2C%20%22A%22)%3D%3D0)%3B%3CBR%20%2F%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3EDie%20erste%20%E2%80%9ESelect%20Where%E2%80%9C-Anweisung%20oben%20entspricht%20der%20Ausgabe%2C%20die%20Sie%20sehen%20w%C3%BCrden%2C%20wenn%20Sie%20die%20durchgehen%20w%C3%BCrden%3CSTRONG%3E%20Reihen%3C%2FSTRONG%3E%20Fenster%20in%20der%20Benutzeroberfl%C3%A4che%2C%20zu%20dem%20navigiert%20wurde%3CSTRONG%3E%20Zeilenauswahl%20-%26gt%3B%20Wo%20ausw%C3%A4hlen%3C%2FSTRONG%3E%20%E2%80%A6%20und%20dann%20im%20Dropdown-Men%C3%BC%20im%20Dialog%20die%20Option%20%E2%80%9Eenth%C3%A4lt%20nicht%E2%80%9C%20ausgew%C3%A4hlt.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22RowSelection.PNG%22%20style%3D%22width%3A%20702px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22RowSelection.PNG%22%20style%3D%22width%3A%20702px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22RowSelection.PNG%22%20style%3D%22width%3A%20702px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22RowSelection.PNG%22%20style%3D%22width%3A%20702px%3B%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22RowSelection.PNG%22%20style%3D%22width%3A%20702px%3B%22%3E%3Cspan%20class%3D%22lia-inline-image-display-wrapper%22%20image-alt%3D%22RowSelection.PNG%22%20style%3D%22width%3A%20702px%3B%22%3E%3Cimg%20src%3D%22https%3A%2F%2Fcommunity.jmp.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F39481i083E08AD7E7451EB%2Fimage-dimensions%2F702x372%3Fv%3Dv2%22%20width%3D%22702%22%20height%3D%22372%22%20role%3D%22button%22%20title%3D%22RowSelection.PNG%22%20alt%3D%22RowSelection.PNG%22%20%2F%3E%3C%2Fspan%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%20style%3D%22%20text-align%20%3A%20left%3B%20%22%3EWie%20Sie%20dem%20obigen%20Beispiel%20entnehmen%20k%C3%B6nnen%2C%20ist%20die%20Verwendung%20von%20!%20kann%20Code%20pr%C3%A4gnanter%20und%20lesbarer%20machen%3B%20Es%20funktioniert%20auch%20besser%2C%20wenn%20Sie%20Anweisungen%20in%20Ihren%20%26lt%3B%3CSELECT%20where-nachrichten%3D%22%22%20kombinieren%3D%22%22%20m%C3%B6chten%3D%22%22%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3Edt%20%3D%20Open(%22%24SAMPLE_DATA%2FBig%20Class.jmp%22)%3B%0A%2F%2FSelect%20Rows%20in%20the%20table%20that%20do%20not%20contain%20the%20letter%20%22A%22%20and%20%22E%22%2C%20and%20contain%20letter%20%22I%22%0Adt%20%26lt%3B%26lt%3B%20Select%20Where%20(!Contains(%3Aname%2C%20%22A%22)%20%26amp%3B%20!Contains(%3Aname%2C%22E%22)%20%26amp%3B%20Contains(%3Aname%2C%20%22I%22))%3B%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3C%2FSELECT%3E%3C%2FP%3E%3CP%3EDer%20NOT-Operator%20hat%20viele%20n%C3%BCtzliche%20Anwendungen%20in%20JSL%2C%20also%20probieren%20Sie%20ihn%20in%20Ihrem%20Code%20aus.%20Wenn%20Sie%20auf%20Probleme%20sto%C3%9Fen%20oder%20Fragen%20haben%2C%20k%C3%B6nnen%20Sie%20sich%20nat%C3%BCrlich%20jederzeit%20an%20den%20technischen%20Support%20von%20JMP%20wenden!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-453800%22%20slang%3D%22en-US%22%3E%3CP%3EErfahren%20Sie%2C%20was%20das%20ist!%20(NOT)-Operator%20ist%20und%20sehen%20Sie%20sich%20Beispiele%20an%2C%20wie%20Sie%20ihn%20in%20Ihrem%20JSL-Code%20verwenden%20k%C3%B6nnen.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-453800%22%20slang%3D%22en-US%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%20mode%3D%22NONE%22%3E%3CLINGO-LABEL%3EAutomatisierung%20und%20Skripterstellung%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Choose Language Hide Translation Bar
Using the ! (NOT) operator and how to make it useful in your JSL code

A useful tool for manipulating Boolean outputs, the ! (NOT) operator in JMP can also have other valuable applications, such as use with Contains() in the <<Select Where() message sent to JMP data tables. This blog post will explore the use of ! and how it might be useful in your JSL code.

First, let’s clarify here that we are discussing the use of ! as an operator and not as the syntactical tool used in escape sequences in quoted strings; in these instances, it does not take on the NOT meaning.

You can think of ! like any other operator in JMP. You are likely familiar with the most common ones: Add (+), Subtract (-), Multiply (*), Divide (/), etc. In a general sense, an operator is a one- or two-character symbol used to perform common arithmetic actions, compare values, construct lists, subscript into a data element, send messages, concatenate lists, scope names, glue expressions, and end expressions.

The ! character (often referred to as the “bang” character) in JMP is used in JSL code as an operator to indicate a logical NOT, which means, in the context of Boolean values (true or false), that it maps nonzero (or true) values to 0 (which means false) and maps 0 (0 or false) values to 1 (which means true).

Here are some simple examples of its use:

Ex 1:

x = 1;
!x;
//LOG RESULT: 0

Ex 2:

x = 0;
!x;
//LOG RESULT: 1

Ex 3:

!(1 < 2);
//LOG RESULT: 0

When grouping it with other operators, you can think of it as belonging with other “logical” operators such as OR (|) and AND (&), which are typically used in If() statements.

Ex 1:

x = 4;
//Check if x is NOT equal to 2 or 3
If( x != 2 & !(x == 3),
   Show("Not Equal to 2 or 3"),
   Show("Equal to 2 or 3")
);
//LOG RESULT: "Not Equal to 2 or 3"

Note: Notice here that you can assert NOT Equal with != or adding ! before the entire equality expression, such as !(x==3).

Ex 2:

str = "hello world";
//Check if str does NOT contain the letter "o"
If (!Contains(str,"o"),
	Show("Does not contain o"),
	Show("Contains o")
);
//LOG RESULT: "Contains o"

There are many situations where it might be helpful to use ! where it is not limited to your If() statements like above. We saw an example of using ! with Contains(), but let’s take it a bit further. A classic use of Contains() is in the context of a << Select Where() message, as demonstrated in this example:

dt = Open("$SAMPLE_DATA/Big Class.jmp");
//Select Rows in the table that do not contain the letter "A" for :name column
dt << Select Where (!Contains(:name, "A"));

This is the same as

dt = Open("$SAMPLE_DATA/Big Class.jmp");
//Select Rows in the table that do not contain the letter "A" for :name column
dt << Select Where (Contains(:name, "A")==0);

The first 'Select Where' statement above matches the output you would see if you went through the Rows window in the UI, navigated to Row Selection --> Select Where… and then selected the option from the dropdown in the dialog “does not contain”.

RowSelection.PNG

As you can see from the example above, the use of ! can make code more concise and readable; it also works better when you want to combine statements in your <<Select Where messages, like the one below:

dt = Open("$SAMPLE_DATA/Big Class.jmp");
//Select Rows in the table that do not contain the letter "A" and "E", and contain letter "I"
dt << Select Where (!Contains(:name, "A") & !Contains(:name,"E") & Contains(:name, "I"));

The NOT operator has many useful applications in JSL, so give it a try in your code. Of course, feel free to reach out to JMP Technical Support if you run into any issues or have questions!

Last Modified: Dec 19, 2023 4:41 PM