Declaring a variable purely to satisfy compiler?

I have encountered a strange issue. I am working with Mail template, and need to insert some logic in front of a standard LS library. My code “should be” …Sub ProcessAction(vArgs As Variant)

.If (Me.m_beobject.document.myFlag(0)=“1”) Then

…If IsOwner() Then

…If (IsCurrentActionInProgress ( ACTION_RESCHEDULE) Or IsCurrentActionInProgress ( ACTION_CANCEL)) Then

…do nothing

…End If

…End If

.Else

…Dim bSendNow As Integer

…bSendNow=False

…Call CSCalendarEntry…ProcessAction(vArgs)

.End If

End Sub

But that doesn’t work - now ProcessActions does not behave correctly. I found that taking the Dim statement out of its “correct” place and putting it in the “do nothing” place, now it works.

Sub ProcessAction(vArgs As Variant)

.If (Me.m_beobject.document.myFlag(0)=“1”) Then

…If IsOwner() Then

…If (IsCurrentActionInProgress ( ACTION_RESCHEDULE) Or IsCurrentActionInProgress ( ACTION_CANCEL)) Then

…Dim bSendNow As Integer

…End If

…End If

.Else

…bSendNow=False

…Call CSCalendarEntry…ProcessAction(vArgs)

.End If

End Sub

But in my eyes, it means the Dim statement never executes, so bSendNow is a Variant.

Can anyone help me understand what’s happening here?

Subject: I’m wondering why it makes a difference at all

AFAIK, LotusScript – unlike “real” programming languages like Java or C[++] – does not care where in a procedure you put a Dim statement. The declared variable’s scope is always the entire procedure. At least that’s what I’ve learned loooong ago, and I never experienced any exceptions from that rule.

Subject: that certainly seems to be the case here

Subject: Probably one of IBM’s global variables

You’ve probably used the same name as a global variable declared in one of the numerous script libraries that the mail template instantiates, and when the procedure you’re calling tries to run, it’s looking for that value - which, since you declared it but did not instantiate it, has no value and causes that called sub or function to fail. Try renaming the variable, putting it back where you originally had it, and see if that works.

Subject: it’s used in something much deeper than LS library

Some calls inside ProcessActions are to “hidden” procedures so we can’t always tell what the instantiation should be - from my view here, it looks like it is supposed to be a Variant, but decalring it like that doesn’t work.

Anyway, thanks for the reply.