- Michael Frascinella wrote:
> Notetabbers,

; For month as a number 1-12

>

> I have a clip that asks for a month and the number of the first Sunday,

> then sets up predefined dates for the month. I want to test for whether

> it is an odd month or even month so that the clip inserts event A or

> event B. The clip prompts me to pick the month, but I can't figure out

> how to test for more than one month at a time. The online help does not

> seem to explain how to test for A or B or C, then do one thing.

>

> The second line does not work, but I don't know the correct syntax.

>

> ^!Set %month%=^?[Month for

> events?=Jan.|Feb.|Mar.|Apr.|May|June|July|Aug.|Sept.|Oct.|Nov.|Dec.]

> ^!If ^%month% = "Jan."|"Mar." ^!Info This is odd month

^!IF ^$Calc("^%Month% mod 2;0")$ = 0 MonthEven Else MonthOdd

; For month as a short string.

^!Set %OddMonths%="Jan|Mar|May|July|Sept|Nov"

^!If ^$StrPos("^%Month%";"^%OddMonths%";0)$ >0 MonthOdd Else MonthEven

(Note: The later example could have been made into one line, but I

generally recommend breaking commands up into pieces in order to

avoid long lines whenever possible.)

Wayne VanWeerthuizen - Wayne,

I think I almost understand your solution but it's disappointing that

Notetab can't handle Booleans in an If statement the way it does with

the Find statement. **Feature request**

When I used to write command procedures that ran on VMS, I could test

for multiple conditions with the .or. or the .and. operators. For example,

If (month = "jan") .or. (month = "mar") then goto oddmonth

Help me with the following.

Example 1:

; For month as a number 1-12

^!IF ^$Calc("^%Month% mod 2;0")$ = 0 MonthEven Else MonthOdd

Your first example uses the ^$Calc statement and assumes that the

%month% variable stores a number (1-12). The online help explains not

much about a lot of math functions and MOD is one of them. What is the

meaning of the expression inside the Calc parentheses and what does it

mean to test if the expression equals zero?

Example 2:

; For month as a short string

^!Set %OddMonths%="Jan|Mar|May|July|Sept|Nov"

^!If ^$StrPos("^%Month%";"^%OddMonths%";0)$ >0 MonthOdd Else MonthEven

In the second example, %month% is a variable containing the month the

user selects and %oddmonths% is a comparison string. What is the meaning

of the vbars? It looks like an array but ^!SetArray is the statement to

do that, right? Is %oddmonths% just a simple text string of all the odd

months and StrPos is looking for the string the user selected?

^!StrPos looks for the substring %month% in the string %oddmonths% but

what does it mean if the value is greater than zero? Or maybe I should

ask when does that result = 0?

Yours,

Michael F

Working from home

-©¿©-

~

******************

Never Forget

September 11, 2001

******************

[Non-text portions of this message have been removed] - Michael Frascinella wrote:
> Wayne,

Some of this is covered in a tutorial I began work a couple years ago.

>

> I think I almost understand your solution but it's disappointing that

> Notetab can't handle Booleans in an If statement the way it does with

> the Find statement. **Feature request**

I never did finish it. If anyone wants to help me update/complete it, it

would be much appreciated.

Look for the file "NoteTab Tutorial Control Structures v003.otl"

in the yahoo groups file area:

http://groups.yahoo.com/group/ntb-clips/files/

Again, note that several sections of the outline are not complete, and

some of the clip examples filled-in yet.

> When I used to write command procedures that ran on VMS, I could test

mod means modulo, which is basically the remainder after division.

> for multiple conditions with the .or. or the .and. operators. For example,

>

> If (month = "jan") .or. (month = "mar") then goto oddmonth

>

> Help me with the following.

>

> Example 1:

>

> ; For month as a number 1-12

> ^!IF ^$Calc("^%Month% mod 2;0")$ = 0 MonthEven Else MonthOdd

>

> Your first example uses the ^$Calc statement and assumes that the

> %month% variable stores a number (1-12). The online help explains not

> much about a lot of math functions and MOD is one of them. What is the

> meaning of the expression inside the Calc parentheses and what does it

> mean to test if the expression equals zero?

For example, 27 divided by 5 is 5 remainder 2. So 27 mod 5 = 2.

X mod 2 is zero whenever X is even.

X mod 10 is zero if X is a multiple of ten.

> Example 2:

In the example the vbars are merely decorative. They could be

>

> ; For month as a short string

> ^!Set %OddMonths%="Jan|Mar|May|July|Sept|Nov"

> ^!If ^$StrPos("^%Month%";"^%OddMonths%";0)$ >0 MonthOdd Else MonthEven

>

> In the second example, %month% is a variable containing the month the

> user selects and %oddmonths% is a comparison string. What is the meaning

> of the vbars? It looks like an array but ^!SetArray is the statement to

> do that, right? Is %oddmonths% just a simple text string of all the odd

> months and StrPos is looking for the string the user selected?

changed to spaces, or even removed entirely. In other situations,

they could help prevent extraneous matches, such as "arm" within

"MarMay".

> ^!StrPos looks for the substring %month% in the string %oddmonths% but

StrPos returns the character position within second string where the

> what does it mean if the value is greater than zero? Or maybe I should

> ask when does that result = 0?

first string is found. It returns 0 only if the first string is not

found within the second. StrPos returns 1 if the second string begins

with the first. In example above ^$StrPos("May";"^%OddMonths%";0)$

should return 9.