MonthMath problem?

I am rusty at PanX code and need some help. The following code works as long as I have a -12 in the MonthMath function. However, PanX bombs if I change the -12 to -11.

GetScrap “Enter month and year of last month of the T12: (mm/yy)”
FileGlobal fgDate, fgDateRange
fgDate = Date(Clipboard())
Message DatePattern(fgDate, “MON”)
Message DatePattern(fgDate, “mm/dd/yy”)

fgDate = Month1st(fgDate)
Message DatePattern(fgDate, “mm/dd/yy”)

fgDate = MonthMath(fgDate, -12)

Message DatePattern(fgDate, “mm/dd/yy”)


I am not sure what I am doing wrong. Any ideas?

Does “bomb” mean crash?

I tried this and it worked fine for me, and calculated the correct date. I literally copy and pasted your code into a procedure, so I know I was using the same code as you.

The code works fine with a “12” in the third to the last line of code, but if I change the “12” to “11” I get the endless spinning beachball.

I cannot duplicate this – it works fine when I try it. What are you entering as the starting date?

I was using the starting date at 5/18

Works perfect for me. With -11 the result is 6/1/17.

Strange. My OS is 10.11.6. Would that have anything to do with it? I just copied and pasted the code that I sent you back into a new procedure. It still fails with a -11. It works with a -12. It works with at 10, but does not work with a -10.

After several hours of testing, getting the beachball, force quitting and relaunching I have found that all my tested positive integer offsets seem to work. All of my negative offset integers worked except -8, -9, -10, and -11. My PanX version is 10.0.01 2685, and my operating system is 10.11.6. To make sure I had clean text for the code, I wrote the code in TextWrangler and pasted it into Panorama. To speed up the test, I used the following code:

Local N, D
FileGlobal fgDate

GetScrap "Enter month offset: "

N = Val(Clipboard())
N = Int(N)

fgDate = Today()
;Message DatePattern(fgDate, “DayOfWeek, mm/dd/yy”)

fgDate = Month1st(fgDate)
;Message DatePattern(fgDate, “mm/dd/yy”)

D = MonthMath(fgDate, N)

Message DatePattern(D, “MON, mm/dd/yy”)


I have duplicated this failure. The failure is shown by a spinning beach ball. The problem occurs in the MonthMath( function. I wrote this procedure to test MonthMath:

let N=Int(-7)
 Let lvresult=""
     lvresult=lvresult+"("+N+") "+datepattern(Monthmath(today(),N),"mm/dd/yyyy")+";"
     filesave "~/desktop/result.txt",lvresult
 until 1000

The monthmath( function works correctly for values of N from -7 to 1000, and from -19 to -12. I have not tested for numbers smaller than -19.
I see there was a related Bitbucket issue (#814) that was resolved.
I also see that I have no way to add a Bitbucket issue; maybe I forgot how to do that or maybe I have been downgraded, not necessarily unreasonably. (Never mind, I had to log back in to add a Bitbucket issue, which I have done.)

Tom, thanks for this insight which solves the puzzle. This was the very first bug fixed AFTER Panorama 10.0.1 was released. So it’s fixed in the version I normally use (the latest development build), but not in the released 10.0.1 version. That’s why I couldn’t duplicate the problem – dumb of me not to think of that. So, this is a real problem that is already fixed in the 10.1 release.