[api-dev] Re: ReDim driving me crazy again…
HI from my poor experience if I want to use redim, i have to define the array as dynamic may be try this public NDice() as integer sub main redim NDice(1 to 6) end sub Laurent -- - 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: ReDim driving me crazy again…
2011/8/18 Laurent Godard oooc...@free.fr: HI from my poor experience if I want to use redim, i have to define the array as dynamic may be try this public NDice() as integer sub main redim NDice(1 to 6) end sub Laurent -- That is probably a good idea in most cases, but it gives the same error if the array is defined in another module (I just tried it in my example). I have worked around it now in my project (I found that I could just move the initial definition to the same module where the ReDim statement is, which works for this project but not in all cases), but I still want to know if this is a bug or not, so I can report it if it is. Thanks for your input, you are the only one who replied, so I guess most people hate me for all those annoying questions I posted recently… ;D 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: ReDim driving me crazy again…
Thanks for your input, you are the only one who replied, so I guess most people hate me for all those annoying questions I posted recently… ;D I guess its rather the move to Apache OpenOffice that cut down the activity on this mailing list... Don't take it personal. :) -Stephan-- - 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: ReDim driving me crazy again…
2011/8/18 Stephan Bergmann stephan.bergmann.second...@googlemail.com: Thanks for your input, you are the only one who replied, so I guess most people hate me for all those annoying questions I posted recently… ;D I guess its rather the move to Apache OpenOffice that cut down the activity on this mailing list... Don't take it personal. :) Well, I'll try not to… ;D Do you happen to know of a list for things like this with more activity? LibreOffice didn't seem to have a similar list either. Kind regards Johnny Rosenberg ジョニー・ローゼンバーグ -Stephan-- - 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: ReDim driving me crazy again…
2011/8/17 Johnny Rosenberg gurus.knu...@gmail.com: I edited a lot of code yesterday, one of the rows I did NOT edit was this one, which occurs at the top of a subroutine: ReDim NDice(1 To 6) As Integer It is defined in another module as: Public NDice(1 To 6) As Integer The error message I get is (translated from Swedish): ”BASIC syntax error: The NDice variable is already defined.” Yes, I know it is, that's one of the points by using ReDim, isn't it? Before doing some heavy editing there was no complaints on this line at all, and as I said, this is NOT one of the many lines I changed. So obviously some of my other edits caused this, but where to start looking? What can I possible have done to cause this? I just hate when these things happen, when there is an error message telling me that I can't do something that I should be able to do. Like if I got an error message for the line ”If a=b Then”, and the error message says: ”BASIC syntax error: a and b are already compared”… I have now tried a couple of more things. I have changed the global definition from Public to Private to Global to Dim and back again to Public. Same result no matter what. I have even removed the global definition, and I have searched through ALL the modules after the variable to make sure it's not declared elsewhere. STILL the error message says that it's already defined! I would like to know where, because the Find thing (Ctrl+f) can't find another definition of NDice than the ReDim on which the error occurs! I have searched for Dim NDice, Public NDice, Private NDice and Global NDice, nothing found except ReDim NDice (once – the one on which the error occurs). Well, I'll continue searching. I have now made a copy of the whole document for wild debugging, so I will try the most brutal things I can think of now, like removing entire modules to see if I can at least find in what module I need to have a closer look at… Any ideas are very welcome! I'm kind of losing my hair here… :P 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: ReDim driving me crazy again…
So here I am again, having fun by sending messages to myself… 2011/8/17 Johnny Rosenberg gurus.knu...@gmail.com: 2011/8/17 Johnny Rosenberg gurus.knu...@gmail.com: 2011/8/17 Johnny Rosenberg gurus.knu...@gmail.com: I edited a lot of code yesterday, one of the rows I did NOT edit was this one, which occurs at the top of a subroutine: ReDim NDice(1 To 6) As Integer It is defined in another module as: Public NDice(1 To 6) As Integer The error message I get is (translated from Swedish): ”BASIC syntax error: The NDice variable is already defined.” Yes, I know it is, that's one of the points by using ReDim, isn't it? Before doing some heavy editing there was no complaints on this line at all, and as I said, this is NOT one of the many lines I changed. So obviously some of my other edits caused this, but where to start looking? What can I possible have done to cause this? I just hate when these things happen, when there is an error message telling me that I can't do something that I should be able to do. Like if I got an error message for the line ”If a=b Then”, and the error message says: ”BASIC syntax error: a and b are already compared”… I have now tried a couple of more things. I have changed the global definition from Public to Private to Global to Dim and back again to Public. Same result no matter what. I have even removed the global definition, and I have searched through ALL the modules after the variable to make sure it's not declared elsewhere. STILL the error message says that it's already defined! I would like to know where, because the Find thing (Ctrl+f) can't find another definition of NDice than the ReDim on which the error occurs! I have searched for Dim NDice, Public NDice, Private NDice and Global NDice, nothing found except ReDim NDice (once – the one on which the error occurs). Well, I'll continue searching. I have now made a copy of the whole document for wild debugging, so I will try the most brutal things I can think of now, like removing entire modules to see if I can at least find in what module I need to have a closer look at… Any ideas are very welcome! I'm kind of losing my hair here… :P I have now found a line which seems to cause the problem. The confusing thing is that I can't really see why, because it doesn't seem to have anything to do with anything (except that the problem disappears when the line is out commented or removed). However, now I can at least reproduce the problem without including thousand of lines of code. Here's a simple example showing what I mean: Open OpenOffice.org Calc or LibreOffice Calc (I tested LibreOffice Calc 3.3.3 on Ubuntu 10.10 and OpenOffice.org Calc 3.2.0 on Ubuntu 10.04, same results). Click your way to the BASIC IDE (Tools → Macro → OpenOffice.org Basic (or LibreOffice Basic) → Untitled 1 → New → Accept the given name → OK. Create a new module, accept the given name. Now you have two modules, right? Module1 and Module2. Actually you only need one to discover this behaviour, but I think two modules illustrates it better, perhaps… Just found out that we need two modules to illustrate the problem, more on that further down… In module 2, replace what's there with the following: REM * BASIC * Option Explicit Public a(1 To 6) As Integer Sub Main Print This is not important in this case. End Sub In module 1, replace what's there with the following: REM * BASIC * Option Explicit Sub Main a(1)=2 End Sub Sub Test ReDim a(1 To 6) As Integer Dim i As Integer For i=1 To 6 a(i)=i Next i Print a(4)= a(4) End Sub Now try to run one of the subroutines in module 1. You'll get an error message at ”ReDim a(1 To 6) As Integer” no matter which one of the subroutines you are trying to run. Now, replace the main subroutine in Module1 with: Sub Main REM a(1)=2 End Sub You can now run both subroutines without any problems (except that Main doesn't do anything, but there will be no Error messages). Here's another trick: Replace all text in Module 1 with: REM * BASIC * Option Explicit Sub Test ReDim a(1 To 6) As Integer Dim i As Integer For i=1 To 6 a(i)=i Next i Print a(4)= a(4) End Sub Sub Main a(1)=2 End Sub It's the same code as before, but Main and Test now switched places. Run one of the subroutine. No error messages. I found that moving the Public definition from Module2 to Module1 also solves the problem, but I guess the problem could occur in Module2 instead, depending on what the code looks like there. I can imagine that there could be a situation where problems are almost unavoidable, even though it didn't happen to me yet… Maybe I have ten functions and/or subroutines in Module1 and Module 2 of which all of them use that variable and all of them needs the ReDim