[api-dev] Re: Constant values for Function arguments
Hi Johnny Am 18.08.2011 18:02, schrieb Johnny Rosenberg: > I just realised that I sent the last message privately, sorry for > that. Here's the same thing (with some additions) but to the list > instead: > > 2011/8/18 Thomas Krumbein : >> Hey Johnny, >> >> honestly, a lot of your questions/things are "basics"... > > Yes, I know. So that's why nobody replies, I suppose. Maybe I'd be > better off sending them to the users' list instead, then. I'll do that > next time. Thanks for the warning. We guitar players are not too > bright… I don't think you get no replies because of that. It's more likely, as Stephan Bergmann stated, that some people are quite busy now. You should not be discouraged by such statements. Even very experienced developers make sometimes easy faults. And some of your questions would also help others not working with OOo-Basic for ten years. So please keep on asking, although not too many people would now have the time to answer. But times will change ;-) > >> VALUE, STRING, FORMULA and DATETIME are reserved words in Basic and >> cannot be used as constant or variable names. Ever thought about this? > > Well, I know STRING is (it turns blue when I type it). > But why did it work in my other example? And why did the monitor show > the right values? > > But I'm sure going to try your suggestion, the one about not using > those names. Thanks! > I was originally going to use the original values, like > ”com.sun.star.sheet.CellFlags.STRING”, but all those long (or broken) > lines are so hard to read, so I like to keep it short, but not too > short… > > Yes, I am a beginner (I will probably always be) and yes, I have > troubles understanding English some times, which makes it even harder > for me, since almost all information I can find is in English. > > > Best regards > > Johnny Rosenberg > ジョニー・ローゼンバーグ > >> >> Try to put a character in Front (i.E. nValue, or myString) and >> everything works as expected >> >> Best regards >> Thomas >> >> >> Am 18.08.2011 12:52, schrieb Johnny Rosenberg: >> Here's another delicate problem that's easy to work around, but still >> very strange: >> >> Module 2: >> ———Code starts below——— >> REM * BASIC * >>> >>> Option Explicit >>> >>> Public Const VALUE=1 >>> Public Const STRING=4 >>> Public Const FORMULA=16 >>> Public Const DATETIME=2 >>> >>> Sub HelloWorld >>> Print "Hello world!" >>> End Sub >>> ———End of code——— >>> >>> >>> Module1: >>> ———Code starts below——— >>> REM * BASIC * >>> >>> Option Explicit >>> >>> Sub Main >>> Dim A >>> A=VALUE+STRING+FORMULA >>> End Sub >>> ———End of code——— >>> Run Main and you will get an error message at ”A=VALUE+STRING+FORMULA”. >>> If you run step by step (Ctrl+F8 in the BASIC IDE) and stop at that >>> line and then hover your mouse pointer over VALUE or STRING or >>> FORMULA, you can clearly see its values, but obviously this doesn't >>> help. Dimensioning A as Variant, as I did, doesn't help either. If you >>> look at VALUE, STRING or FORMULA in the variable monitor (or whatever >>> it's called in English), the window at the bottom left, you can see >>> that they are Variant/Integer and you can see their correct values. >>> >>> So now, let's move the constant definition to Module1: >>> Module 2: >>> ———Code starts below——— >>> REM * BASIC * >>> >>> Option Explicit >>> >>> Sub HelloWorld >>> Print "Hello world!" >>> End Sub >>> ———End of code——— >>> >>> >>> Module1: >>> ———Code starts below——— >>> REM * BASIC * >>> >>> Option Explicit >>> >>> Public Const VALUE=1 >>> Public Const STRING=4 >>> Public Const FORMULA=16 >>> Public Const DATETIME=2 >>> >>> Sub Main >>> Dim A >>> A=VALUE+STRING+FORMULA >>> End Sub >>> ———End of code——— >>> >>> Now Main in Module1 works as expected, but take a look in the monitor >>> again. Those constants appears in exactly the same way this time as >>> before, the only exception is that this works. >>> I would be very grateful for an explanation about this. Is there >>> REALLY a logical reason for it to be this way or should I report this >>> as a bug as soon as possible? >>> >>> Of course I can define those constants in every module, but isn't one >>> of the points by declaring as Public that I can reach them in all my >>> modules? Well, in this case I can; I just can't use them, at least not >>> when adding them to each other. >>> ”A=VALUE” works in both my examples, but obviously not >>> ”A=VALUE+STRING+FORMULA” for some reason I am sure absolutely nobody >>> can explain, so please prove me wrong here…! >>> >>> :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: Custom types drives me nuts – this can't be happening… can it?
2011/8/16 Andrew Douglas Pitonyak : > Oh my goodness! It is always something small that wastes hours of time. Yes, it seems like it most of the time… But if the bug you mentioned about that Private acts like Public was fixed, I wouldn't have had this problem, would I? :) Or if I had the magic words ”Option Compatible” involved… ;D Kind regards Johnny Rosenberg ジョニー・ローゼンバーグ > > On 08/15/2011 08:48 AM, Johnny Rosenberg wrote: >> >> Okej, forget this, I solved it. Immediately after I sent this I found >> the problem! All I needed to do to find it out was probably to write >> about it somewhere… >> >> I found the problem when I did a search in all modules for my type >> ”DieStatistics”. I found it in a module called ”Experiment” which is >> Swedish for ”Experiments” in this case. >> >> I did some tests in that module a few days ago, before I declared >> DiceFreq as an array of DieStatistics, so DiceFreq was declared >> globally twice: >> >> Module Experiment: >> Global DiceFreq As DieStatistics >> >> >> Module P: >> Private DiceFreq(1) As DieStatistics >> >> After removing the Experiment ones, everything worked as expected. >> >> Phew, what a relief… I thought I was crazy there for a few minutes…! >> >> >> And I usually don't top post, but in this case I thought it could be >> appropriate, since the text below suddenly became very unimportant. >> >> >> Best regards >> >> Johnny Rosenberg >> ジョニー・ローゼンバーグ >> >> >> 2011/8/15 Johnny Rosenberg: >>> >>> I was editing some code I have, actually a game with dice and stuff, >>> but that doesn't matter, I suppose. >>> >>> So I ran into a problem, and I copied the troubling part of the code >>> to a separate document for test driving. >>> However, the test code runs perfectly, but not within the game of mine! >>> >>> I ran the game on another computer but another version of >>> OpenOffice.org (actually the first computer runs LibreOffice 3.3.3), >>> but the results were exactly the same. >>> >>> Here's the test code. I have a message box after almost every >>> statement so I can see what happens. I added some extra comments in >>> the code. >>> >>> REM * BASIC * >>> >>> Option Explicit >>> Option Compatible >>> >>> Type DieStatistics >>> Value As Integer >>> Count As Integer >>> End Type >>> >>> ' The variable DiceFreq, declared below this comment, tells us which >>> two die values that are most frequent. For example, if the six dice >>> are 133455, >>> ' DiceFreq will contain: >>> ' DiceFreq(0).Value: 5 (the most common value is 5) >>> ' DiceFreq(0).Count: 2 (2 dice have the value 5) >>> ' DiceFreq(1).Value: 3 (the second most common value is 3 – in this >>> case there are two of both 3 and five, but higher value has priority) >>> ' DiceFreq(1).Count: 2 (2 dice have the value 3) >>> ' This makes it very easy for us to calculate things later, >>> calculations that are not present in this short example though. >>> Private DiceFreq(1) As DieStatistics ' >>> >>> >>> Sub Test0 >>> ' NDice tells us how many there are of each die value. In the above >>> example, NDice(4)=1, since there are 1 die with the value 4. >>> Dim NDice(1 To 6) As Integer, i As Integer >>> >>> ' Here we set the values of NDice for an example where this is >>> known >>> to fail, that is what NDice would contain if the dice were 112345 >>> ' NDice(1)=2, NDice(2)=1 and so on. >>> For i=2 To 5 >>> NDice(i)=1 >>> Next i >>> NDice(1)=2 >>> >>> ' Here's where I calculate the values for DiceFreq by going through >>> NDice from 6 to 1. >>> For i=6 To 1 Step -1 >>> If NDice(i)>DiceFreq(0).Count Then >>> DiceFreq(1).Count=DiceFreq(0).Count >>> DiceFreq(1).Value=DiceFreq(0).Value >>> MsgBox DiceFreq(0).Value& ": "& >>> DiceFreq(0).Count& " st."& Chr(13)& _ >>> DiceFreq(1).Value& ": "& >>> DiceFreq(1).Count& " st." >>> DiceFreq(0).Count=NDice(i) >>> DiceFreq(0).Value=i >>> MsgBox DiceFreq(0).Value& ": "& >>> DiceFreq(0).Count& " st."& Chr(13)& _ >>> DiceFreq(1).Value& ": "& >>> DiceFreq(1).Count& " st." >>> ElseIf NDice(i)>DiceFreq(1).Count Then >>> DiceFreq(1).Count=NDice(i) >>> DiceFreq(1).Value=i >>> MsgBox DiceFreq(0).Value& ": "& >>> DiceFreq(0).Count& " st."& Chr(13)& _ >>> DiceFreq(1).Value& ": "& >>> DiceFreq(1).Count& " st." >>> EndIf >>> Next i >>> MsgBox "Final reults:"& String(2,Chr(13))& DiceFreq(0).Value& >>> ":" >>> & DiceFreq(0).Count& _ >>> " st."& Chr(13)& DiceFreq(1).Value& ": "& DiceFreq(1).Count& >>> " st." >>> End Sub >>> >>> >>> Now, while this works perfectly as a stand-al
[api-dev] Re: Constant values for Function arguments
I just realised that I sent the last message privately, sorry for that. Here's the same thing (with some additions) but to the list instead: 2011/8/18 Thomas Krumbein : > Hey Johnny, > > honestly, a lot of your questions/things are "basics"... Yes, I know. So that's why nobody replies, I suppose. Maybe I'd be better off sending them to the users' list instead, then. I'll do that next time. Thanks for the warning. We guitar players are not too bright… > VALUE, STRING, FORMULA and DATETIME are reserved words in Basic and > cannot be used as constant or variable names. Ever thought about this? Well, I know STRING is (it turns blue when I type it). But why did it work in my other example? And why did the monitor show the right values? But I'm sure going to try your suggestion, the one about not using those names. Thanks! I was originally going to use the original values, like ”com.sun.star.sheet.CellFlags.STRING”, but all those long (or broken) lines are so hard to read, so I like to keep it short, but not too short… Yes, I am a beginner (I will probably always be) and yes, I have troubles understanding English some times, which makes it even harder for me, since almost all information I can find is in English. Best regards Johnny Rosenberg ジョニー・ローゼンバーグ > > Try to put a character in Front (i.E. nValue, or myString) and > everything works as expected > > Best regards > Thomas > > > Am 18.08.2011 12:52, schrieb Johnny Rosenberg: > Here's another delicate problem that's easy to work around, but still > very strange: > > Module 2: > ———Code starts below——— > REM * BASIC * >> >> Option Explicit >> >> Public Const VALUE=1 >> Public Const STRING=4 >> Public Const FORMULA=16 >> Public Const DATETIME=2 >> >> Sub HelloWorld >> Print "Hello world!" >> End Sub >> ———End of code——— >> >> >> Module1: >> ———Code starts below——— >> REM * BASIC * >> >> Option Explicit >> >> Sub Main >> Dim A >> A=VALUE+STRING+FORMULA >> End Sub >> ———End of code——— >> Run Main and you will get an error message at ”A=VALUE+STRING+FORMULA”. >> If you run step by step (Ctrl+F8 in the BASIC IDE) and stop at that >> line and then hover your mouse pointer over VALUE or STRING or >> FORMULA, you can clearly see its values, but obviously this doesn't >> help. Dimensioning A as Variant, as I did, doesn't help either. If you >> look at VALUE, STRING or FORMULA in the variable monitor (or whatever >> it's called in English), the window at the bottom left, you can see >> that they are Variant/Integer and you can see their correct values. >> >> So now, let's move the constant definition to Module1: >> Module 2: >> ———Code starts below——— >> REM * BASIC * >> >> Option Explicit >> >> Sub HelloWorld >> Print "Hello world!" >> End Sub >> ———End of code——— >> >> >> Module1: >> ———Code starts below——— >> REM * BASIC * >> >> Option Explicit >> >> Public Const VALUE=1 >> Public Const STRING=4 >> Public Const FORMULA=16 >> Public Const DATETIME=2 >> >> Sub Main >> Dim A >> A=VALUE+STRING+FORMULA >> End Sub >> ———End of code——— >> >> Now Main in Module1 works as expected, but take a look in the monitor >> again. Those constants appears in exactly the same way this time as >> before, the only exception is that this works. >> I would be very grateful for an explanation about this. Is there >> REALLY a logical reason for it to be this way or should I report this >> as a bug as soon as possible? >> >> Of course I can define those constants in every module, but isn't one >> of the points by declaring as Public that I can reach them in all my >> modules? Well, in this case I can; I just can't use them, at least not >> when adding them to each other. >> ”A=VALUE” works in both my examples, but obviously not >> ”A=VALUE+STRING+FORMULA” for some reason I am sure absolutely nobody >> can explain, so please prove me wrong here…! >> >> :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…
On Aug 18, 2011, at 2:33 PM, Johnny Rosenberg wrote: > 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. No, don't know a better list for now. Most traffic on ooo-...@incubator.apache.org currently is about moving the project, not about using or hacking the project. In the end, the goal is to resurrect the OOo infrastructure over at Apache, if not as an exact clone then at least in spirit, so it might be a good idea to stick to this list for the moment---even if you sometimes have to write the answers to your questions yourself… ;) -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 : >> 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…
> 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: Constant values for Function arguments
Hey Johnny, honestly, a lot of your questions/things are "basics"... VALUE, STRING, FORMULA and DATETIME are reserved words in Basic and cannot be used as constant or variable names. Ever thought about this? Try to put a character in Front (i.E. nValue, or myString) and everything works as expected Best regards Thomas Am 18.08.2011 12:52, schrieb Johnny Rosenberg: > Here's another delicate problem that's easy to work around, but still > very strange: > > Module 2: > ———Code starts below——— > REM * BASIC * > > Option Explicit > > Public Const VALUE=1 > Public Const STRING=4 > Public Const FORMULA=16 > Public Const DATETIME=2 > > Sub HelloWorld > Print "Hello world!" > End Sub > ———End of code——— > > > Module1: > ———Code starts below——— > REM * BASIC * > > Option Explicit > > Sub Main > Dim A > A=VALUE+STRING+FORMULA > End Sub > ———End of code——— > Run Main and you will get an error message at ”A=VALUE+STRING+FORMULA”. > If you run step by step (Ctrl+F8 in the BASIC IDE) and stop at that > line and then hover your mouse pointer over VALUE or STRING or > FORMULA, you can clearly see its values, but obviously this doesn't > help. Dimensioning A as Variant, as I did, doesn't help either. If you > look at VALUE, STRING or FORMULA in the variable monitor (or whatever > it's called in English), the window at the bottom left, you can see > that they are Variant/Integer and you can see their correct values. > > So now, let's move the constant definition to Module1: > Module 2: > ———Code starts below——— > REM * BASIC * > > Option Explicit > > Sub HelloWorld > Print "Hello world!" > End Sub > ———End of code——— > > > Module1: > ———Code starts below——— > REM * BASIC * > > Option Explicit > > Public Const VALUE=1 > Public Const STRING=4 > Public Const FORMULA=16 > Public Const DATETIME=2 > > Sub Main > Dim A > A=VALUE+STRING+FORMULA > End Sub > ———End of code——— > > Now Main in Module1 works as expected, but take a look in the monitor > again. Those constants appears in exactly the same way this time as > before, the only exception is that this works. > I would be very grateful for an explanation about this. Is there > REALLY a logical reason for it to be this way or should I report this > as a bug as soon as possible? > > Of course I can define those constants in every module, but isn't one > of the points by declaring as Public that I can reach them in all my > modules? Well, in this case I can; I just can't use them, at least not > when adding them to each other. > ”A=VALUE” works in both my examples, but obviously not > ”A=VALUE+STRING+FORMULA” for some reason I am sure absolutely nobody > can explain, so please prove me wrong here…! > > :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] Constant values for Function arguments
Here's another delicate problem that's easy to work around, but still very strange: Module 2: ———Code starts below——— REM * BASIC * Option Explicit Public Const VALUE=1 Public Const STRING=4 Public Const FORMULA=16 Public Const DATETIME=2 Sub HelloWorld Print "Hello world!" End Sub ———End of code——— Module1: ———Code starts below——— REM * BASIC * Option Explicit Sub Main Dim A A=VALUE+STRING+FORMULA End Sub ———End of code——— Run Main and you will get an error message at ”A=VALUE+STRING+FORMULA”. If you run step by step (Ctrl+F8 in the BASIC IDE) and stop at that line and then hover your mouse pointer over VALUE or STRING or FORMULA, you can clearly see its values, but obviously this doesn't help. Dimensioning A as Variant, as I did, doesn't help either. If you look at VALUE, STRING or FORMULA in the variable monitor (or whatever it's called in English), the window at the bottom left, you can see that they are Variant/Integer and you can see their correct values. So now, let's move the constant definition to Module1: Module 2: ———Code starts below——— REM * BASIC * Option Explicit Sub HelloWorld Print "Hello world!" End Sub ———End of code——— Module1: ———Code starts below——— REM * BASIC * Option Explicit Public Const VALUE=1 Public Const STRING=4 Public Const FORMULA=16 Public Const DATETIME=2 Sub Main Dim A A=VALUE+STRING+FORMULA End Sub ———End of code——— Now Main in Module1 works as expected, but take a look in the monitor again. Those constants appears in exactly the same way this time as before, the only exception is that this works. I would be very grateful for an explanation about this. Is there REALLY a logical reason for it to be this way or should I report this as a bug as soon as possible? Of course I can define those constants in every module, but isn't one of the points by declaring as Public that I can reach them in all my modules? Well, in this case I can; I just can't use them, at least not when adding them to each other. ”A=VALUE” works in both my examples, but obviously not ”A=VALUE+STRING+FORMULA” for some reason I am sure absolutely nobody can explain, so please prove me wrong here…! :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…
2011/8/18 Laurent Godard : > 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