| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| Given: set i=1,j=2,k=3 what does the following say: if i=0!(j=2) write "yes",! ^^^^^^^^^ this is confusing me. What is the 'nl' command doing there? -- Duke Normandin |
|
#2
| |||
| |||
| In article <D_9Tj.255$Yp.44@edtnps92>, Duke Normandin <dukeofperl@ml1.net> wrote: >Given: > >set i=1,j=2,k=3 > >what does the following say: > >if i=0!(j=2) write "yes",! > ^^^^^^^^^ >this is confusing me. What is the 'nl' command doing there? Pay attention to the difference between an expression and a format. -- -- Rod -- rodd(at)polylogics(dot)com |
|
#3
| |||
| |||
| On May 3, 10:23 pm, Duke Normandin <dukeofp...@ml1.net> wrote: > Given: > > set i=1,j=2,k=3 > > what does the following say: > > if i=0!(j=2) write "yes",! > ^^^^^^^^^ > this is confusing me. What is the 'nl' command doing there? > -- > Duke Normandin The ! symbol is an "or" when used with an IF command or as part of a condition. It is a "nl" when used with the write command. --Leane |
|
#4
| |||
| |||
| Here's a tip to make sure you don't fall foul of MUMPS' unusual if/else construction and its reliance on $t which can inadvertently cause you problems (another area of weirdness that can cause hours of debugging grief) As a matter of course, I structure them as follows: if condition do . ; whatever needed for main condition .; etc.... else do . ; whatever needed for else condition . ;etc... This use of "dot syntax" gives you the syntactical equivalent to the C-style: if (condition) { //whatever you need to do } else { //whatever else you need to do } so it's a reasonably familiar construct for someone new to MUMPS, and also will behave as you'd expect. Note the 2 spaces between "else" and "do" On Sun, 4 May 2008 00:39:17 -0700 (PDT), lmv <lverhulst@gmail.com> wrote: >On May 3, 10:23 pm, Duke Normandin <dukeofp...@ml1.net> wrote: >> Given: >> >> set i=1,j=2,k=3 >> >> what does the following say: >> >> if i=0!(j=2) write "yes",! >> ^^^^^^^^^ >> this is confusing me. What is the 'nl' command doing there? >> -- >> Duke Normandin > >The ! symbol is an "or" when used with an IF command or as part of a >condition. It is a "nl" when used with the write command. > >--Leane --- Rob Tweed Company: M/Gateway Developments Ltd Registered in England: No 3220901 Registered Office: 58 Francis Road,Ashford, Kent TN23 7UR Web-site: http://www.mgateway.com SlipstreamUSA: April 2, Renaissance Hotel, Orlando http://www.OutOfTheSlipstream.com |
|
#5
| |||
| |||
| On 2008-05-04, lmv <lverhulst@gmail.com> wrote: > On May 3, 10:23 pm, Duke Normandin <dukeofp...@ml1.net> wrote: >> Given: >> >> set i=1,j=2,k=3 >> >> what does the following say: >> >> if i=0!(j=2) write "yes",! >> ^^^^^^^^^ >> this is confusing me. What is the 'nl' command doing there? >> -- >> Duke Normandin > > The ! symbol is an "or" when used with an IF command or as part of a > condition. It is a "nl" when used with the write command. > > --Leane Thanks, Leane! The tutorial I'm using had covered the fact that `!' is used to mean `or' as well, but I completely missed it. My bad! [Rod] Good advise, of course. Because of the duality of some Mumps syntax, I have to learn to keep that in mind at all times. [Rob] What a great suggestion -- especially for me with my Perl background. I must remember those 2 spaces, though...... ![]() Thanks everybody! and have a great weekend! L8r... -- Duke Normandin |
|
#6
| |||
| |||
| > What a great suggestion -- especially for me with my Perl background. > I must remember those 2 spaces, though...... ![]() One way to remember is to think of all M commands as containing two spaces: <previous command or linestart> Commandword Space Argument(s) Space where a nl may be substituted for the last space and if there are no arguments (e.g. following the ELSE command) there still have to be two spaces. Aaron |
|
#7
| |||
| |||
| On 2008-05-04, Aaron Seidman <aaron@imaginative-illustration.com> wrote: > > What a great suggestion -- especially for me with my Perl background. > > I must remember those 2 spaces, though...... ![]() > > One way to remember is to think of all M commands as containing two > spaces: > ><previous command or linestart> Commandword Space Argument(s) Space | | | | +> 2 spaces each <+ Is this what you mean? > where a nl may be substituted for the last space and if there are no > arguments (e.g. following the ELSE command) there still have to be > two spaces. > > Aaron Thanks for your input Aaron! -- Duke Normandin |
|
#8
| |||
| |||
| Duke Normandin wrote: >> One way to remember is to think of all M commands as containing two >> spaces: >> >> <previous command or linestart> Commandword Space Argument(s) Space > | | > | | > +> 2 spaces each <+ > Is this what you mean? Each command must have exactly one space between the commandword (e.g. WRITE, IF, DO, etc.) and the argument list and there must be one or more spaces or nl after the argument(s), depending whether there is anything else following. Some examples (NB: the semicolon ";" is the comment character): |space|WRITE<sp>"FOO"<nl> ; One vommand on the line, line ends with newline | tab | |space|WRITE<sp>"FOO","BAR"<sp>READ<sp>VAR<nl> ; two commands on line | tab | |space|ELSE<sp><sp>KILL<sp>VAR<nl> ; ELSE command has empty arg list | tab | Aaron |
|
#9
| |||
| |||
| On 2008-05-05, Aaron Seidman <aaron@imaginative-illustration.com> wrote: > Duke Normandin wrote: >>> One way to remember is to think of all M commands as containing two >>> spaces: >>> >>> <previous command or linestart> Commandword Space Argument(s) Space >> | | >> | | >> +> 2 spaces each <+ >> Is this what you mean? > > Each command must have exactly one space between the commandword (e.g. > WRITE, IF, DO, etc.) and the argument list and there must be one or more > spaces or nl after the argument(s), depending whether there is anything else > following. > > Some examples (NB: the semicolon ";" is the comment character): > >|space|WRITE<sp>"FOO"<nl> ; One vommand on the line, line ends with newline >| tab | > > >|space|WRITE<sp>"FOO","BAR"<sp>READ<sp>VAR<nl> ; two commands on line >| tab | > > >|space|ELSE<sp><sp>KILL<sp>VAR<nl> ; ELSE command has empty arg list >| tab | > > Aaron I now understand what you are getting at. Thanks! -- Duke Normandin |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.