[api-dev] Re: Global variables – OpenOffice.org Basic
2011/8/8 Johnny Rosenberg : > I am testing some functions at the moment (I wrote them a few years > ago and now I'm trying to make them faster…) but I am a bit stuck at > the moment. > > It looks something like this: > > Module1 > ¯¯¯ > ' Code starts here > Option Explicit > > Type Blahblah > This As Integer > That As Integer > End Type > > Dim OneThing As Blahblah > Dim MoreStuff As Integer > > Sub Main > Dim X As Integer > Some stuff > X=MyFunction(47) > More stuff > End Sub > ' End of code > > Module2 > ¯¯¯ > ' Code starts here > Function MyFunction(A As Integer) As Integer > Dim SomeValue As Integer > Some stuff > OneThing.This=A*SomeValue > More stuff > MyFunction=OneThing.This-A > End Function > ' End of code > > Now, when running this (with F5 or F8), it seems like it starts at > ”Sub Main” and everything above it is omitted, so I get an error > message in module2 when ”OneThing” is mentioned. Sorry, that was not correct. I don't get an error message, the variable just stays a 0. > Shouldn't the global things be available in all modules? They are if I > run similar macros from a spreadsheet, for example, that is not from > the Basic IDE. > > Did I miss something here? Is there a way around it? > > > Kind regards > > Johnny Rosenberg > ジョニー・ローゼンバーグ > -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Re: Global variables – OpenOffice.org Basic
Seems like replacing the word ”Dim” by ”Global” solved my problem. I just wonder why ”Dim” works when I don't run the macro from within the Basic IDE. Kind regards Johnny Rosenberg ジョニー・ローゼンバーグ -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Re: Global variables – OpenOffice.org Basic
Let me start by saying that this works just fine using OOo for all cases without resorting to Global. Do you have Option Compatible set anywhere? On 08/08/2011 11:42 AM, Johnny Rosenberg wrote: I am testing some functions at the moment (I wrote them a few years ago and now I'm trying to make them faster…) but I am a bit stuck at the moment. It looks something like this: Module1 ¯¯¯ ' Code starts here Option Explicit Type Blahblah This As Integer That As Integer End Type Dim OneThing As Blahblah Dim MoreStuff As Integer Sub Main Dim X As Integer Some stuff X=MyFunction(47) More stuff End Sub ' End of code Module2 ¯¯¯ ' Code starts here Function MyFunction(A As Integer) As Integer Dim SomeValue As Integer Some stuff OneThing.This=A*SomeValue More stuff MyFunction=OneThing.This-A End Function ' End of code Now, when running this (with F5 or F8), it seems like it starts at ”Sub Main” and everything above it is omitted, so I get an error message in module2 when ”OneThing” is mentioned. Shouldn't the global things be available in all modules? They are if I run similar macros from a spreadsheet, for example, that is not from the Basic IDE. Did I miss something here? Is there a way around it? Kind regards Johnny Rosenberg ジョニー・ローゼンバーグ -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Re: Global variables – OpenOffice.org Basic
011/8/14 Andrew Douglas Pitonyak : > Let me start by saying that this works just fine using OOo for all cases > without resorting to Global. > > Do you have Option Compatible set anywhere? > No, isn't that for compatibility with Visual Basic? I'm not sure why I would like to be compatible with that… Anyway, it worked (as far as I remember) without Global, but NOT from the IDE by pressing F5 in some cases. Kind regards Johnny Rosenberg ジョニー・ローゼンバーグ > > > On 08/08/2011 11:42 AM, Johnny Rosenberg wrote: >> >> I am testing some functions at the moment (I wrote them a few years >> ago and now I'm trying to make them faster…) but I am a bit stuck at >> the moment. >> >> It looks something like this: >> >> Module1 >> ¯¯¯ >> ' Code starts here >> Option Explicit >> >> Type Blahblah >> This As Integer >> That As Integer >> End Type >> >> Dim OneThing As Blahblah >> Dim MoreStuff As Integer >> >> Sub Main >> Dim X As Integer >> Some stuff >> X=MyFunction(47) >> More stuff >> End Sub >> ' End of code >> >> Module2 >> ¯¯¯ >> ' Code starts here >> Function MyFunction(A As Integer) As Integer >> Dim SomeValue As Integer >> Some stuff >> OneThing.This=A*SomeValue >> More stuff >> MyFunction=OneThing.This-A >> End Function >> ' End of code >> >> Now, when running this (with F5 or F8), it seems like it starts at >> ”Sub Main” and everything above it is omitted, so I get an error >> message in module2 when ”OneThing” is mentioned. >> Shouldn't the global things be available in all modules? They are if I >> run similar macros from a spreadsheet, for example, that is not from >> the Basic IDE. >> >> Did I miss something here? Is there a way around it? >> >> >> Kind regards >> >> Johnny Rosenberg >> ジョニー・ローゼンバーグ > > -- > Andrew Pitonyak > My Macro Document: http://www.pitonyak.org/AndrewMacro.odt > Info: http://www.pitonyak.org/oo.php > > -- > - > To unsubscribe send email to dev-unsubscr...@api.openoffice.org > For additional commands send email to sy...@api.openoffice.org > with Subject: help > -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help
[api-dev] Re: Global variables – OpenOffice.org Basic
On 08/14/2011 01:45 AM, Johnny Rosenberg wrote: 011/8/14 Andrew Douglas Pitonyak: Let me start by saying that this works just fine using OOo for all cases without resorting to Global. Do you have Option Compatible set anywhere? No, isn't that for compatibility with Visual Basic? I'm not sure why I would like to be compatible with that… Dim translates to "Private", but Private is broken in OOo so it acts like "Public". A decision was made to NOT fix this in case it broke existing macros. The end result is that DIM acts correctly ONLY if Option Compatible is used. Anyway, it worked (as far as I remember) without Global, but NOT from the IDE by pressing F5 in some cases. Kind regards Johnny Rosenberg ジョニー・ローゼンバーグ On 08/08/2011 11:42 AM, Johnny Rosenberg wrote: I am testing some functions at the moment (I wrote them a few years ago and now I'm trying to make them faster…) but I am a bit stuck at the moment. It looks something like this: Module1 ¯¯¯ ' Code starts here Option Explicit Type Blahblah This As Integer That As Integer End Type Dim OneThing As Blahblah Dim MoreStuff As Integer Sub Main Dim X As Integer Some stuff X=MyFunction(47) More stuff End Sub ' End of code Module2 ¯¯¯ ' Code starts here Function MyFunction(A As Integer) As Integer Dim SomeValue As Integer Some stuff OneThing.This=A*SomeValue More stuff MyFunction=OneThing.This-A End Function ' End of code Now, when running this (with F5 or F8), it seems like it starts at ”Sub Main” and everything above it is omitted, so I get an error message in module2 when ”OneThing” is mentioned. Shouldn't the global things be available in all modules? They are if I run similar macros from a spreadsheet, for example, that is not from the Basic IDE. Did I miss something here? Is there a way around it? Kind regards Johnny Rosenberg ジョニー・ローゼンバーグ -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help -- Andrew Pitonyak My Macro Document: http://www.pitonyak.org/AndrewMacro.odt Info: http://www.pitonyak.org/oo.php -- - To unsubscribe send email to dev-unsubscr...@api.openoffice.org For additional commands send email to sy...@api.openoffice.org with Subject: help