Question already answered on the OOoForum...
Global variables are the only variables that hold their value between
macro execution. Statics are only for a single run so if you called
ViewZoomCycle five times in the same macro execution, then it would hold
the value.
RBL wrote:
Does anyone know if there are any issues using static variables with
OpenOffice macros?
The following macro does not work, but should (at least, in VBA it
would). COUNT is never remembered; it's always zero.
The purpose of this macro is to allow a user to hit a hotkey and cycle
the display through all of the standard zoom factors.
sub ViewZoomCycle
rem
----------------------------------------------------------------------
rem define variables
static count as integer
dim document as object
dim dispatcher as object
rem
----------------------------------------------------------------------
rem get access to the document
count = count + 1
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem
----------------------------------------------------------------------
dim args1(2) as new com.sun.star.beans.PropertyValue
args1(0).Name = "Zoom.Value"
args1(1).Name = "Zoom.ValueSet"
args1(1).Value = 28703
args1(2).Name = "Zoom.Type"
select case count
case 1
args1(0).Value = 0
args1(2).Value = 2
case 2
args1(0).Value = 0
args1(2).Value = 3
case 3
args1(0).Value = 0
args1(2).Value = 1
case 4
args1(0).Value = 200
args1(2).Value = 0
case 5
args1(0).Value = 150
args1(2).Value = 0
case 6
args1(0).Value = 100
args1(2).Value = 0
case 7
args1(0).Value = 75
args1(2).Value = 0
case 8
args1(0).Value = 50
args1(2).Value = 0
case else
count = 0
end select
if count then
dispatcher.executeDispatch(document, ".uno:Zoom", "", 0, args1())
end if
end sub
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info: http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]