You Must use control words within an explicit definition. foo=: 3 : 0 if. 1 do. wdinfo 'success' end. )
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Hahn, Harvey Sent: Wednesday, February 20, 2008 18:47 To: Programming forum Subject: [Jprogramming] Beg Q--"if" spelling error??? I'm stumped--again! I was trying to create a series of "if" statements to process arguments passed to a J script (standalone app). In the statement, "if. A do. B end.", I tested and know that statements A and B are constructed correctly and work properly (that is, they have the proper syntax, values, etc.). But I kept getting an error message every time the script reached the "if" statements. I decided to switch over to the interpreter and see if I could figure out what's going on. That's when things really blew my mind! In order to create a tiny example for your perusal of what was going on, I made the "A" value above always be true (value of 1, based on what was returned by J when I typed a true mathematical statement) and stuck in a simple display action for the "B" value above. Here's my example and the J interpreter's response: if. 1 do. wdinfo 'success' end. |spelling error | if. 1 do. wdinfo 'success' end. | ^ How can there be a "spelling error"??? "if." is exactly what is described in the "control structures" section of the Vocabulary. OK, so I decided that, since x, y, and other characters dropped their terminating periods starting in J601, I'd try do the same with the words in the "if" structure: if 1 do wdinfo 'success' end <-- dialog box displays followed by: |value error: if | if 1 do wdinfo'success'end Interestingly, it *worked*! Or I should say that it sort of worked: when I pressed the Enter key, the expected dialog box displayed, but, when I clicked the "OK" button, the error message above appeared. Help! I don't know what's happening or why. I tried to follow the proper spelling and syntax of the "if" structure, but it doesn't seem to work as documented. Any ideas??? Thanks! (BTW, I'm running J601c.) Harvey ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
