[api-dev] Re: How can I read my code in a module in the Basic IDE with Basic code?
I believe that AndrewBase.odt has an example that writes code to a module and then calls it. I also believe that it demonstrates how to walk controls and similar. On 08/14/2011 02:11 AM, Johnny Rosenberg wrote: My workaround at the moment, is to first save my code to a file and then loading it from the file. Not that it matters why I want to do this, but I am writing a macro that examines my subroutines and functions. I want to know the name of every function and every subroutine, what module they are in, what parameters they want, what they return, which subroutines and functions (of those in the same modules) they call, by which functions and subroutines they are called and maybe some more. My macro works, but as I said, it reads the information from files rather than directly from the modules in the Basic IDE. If I only can read all the text in one module at once, that would do it just fine. If there is a simple one-liner that reads just one function or subroutine, that's a bonus, and if I can read a dialogue that's even better… I know how to read from spreadsheets and writer documents, I just can't figure out how to reach the text in the IDE. Hoping for an answer even though I noticed that this list seems quite dead these days. Maybe people are busy doing real things… 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: How can I read my code in a module in the Basic IDE with Basic code?
2011/8/14 Johnny Rosenberg : > 2011/8/14 Johnny Rosenberg : >> 2011/8/14 Johnny Rosenberg : >>> 2011/8/14 Oliver Brinzing : Hi Johnny, > If I only can read all the text in one module at once, that would do > it just fine. If there is a simple one-liner that reads just one > function or subroutine, that's a bonus, and if I can read a dialogue > that's even better… Have you tried: Sub Test() Dim oLibs as Object Dim oLib as Object Dim sLib as String Dim mTmp() Dim i as Integer Dim s as String sLib = "Standard" oLibs = GlobalScope.BasicLibraries If Not oLibs.hasByName(sLib) Then MsgBox "Error reading " & sLib EndIf oLib = oLibs.getByName(sLib) mTmp() = oLib.getElementNames() For i = 0 To uBound(mTmp()) s = s + mTmp(i) & Chr(13) Next i MsgBox s MsgBox oLib.getByName(mTmp(0)) End Sub >>> >>> No, I didn't, but it seems to work for my global macros. I guess I >>> need to change the ”oLibs = GlobalScope.BasicLibraries” line for local >>> code (macros for the current document only), but to what? >>> >>> >>> Regards >>> >>> Johnny Rosenberg >>> ジョニー・ローゼンバーグ >>> Regards Oliver >>> >> >> Experimented a bit: >> Sub Main >> Dim A As String >> >> ' Getting code from the tab ”Spel” in the current document: >> A=ThisComponent.BasicLibraries.getByName("Standard").getByName("Spel") >> MsgBox A >> End Sub >> >> Thanks for your hint! >> >> >> Kind regards >> >> Johnny Rosenberg >> ジョニー・ローゼンバーグ >> > > Also tried with Dialogues, but (in my case, as an example) > ThisComponent.DialogLibraries.getByName("Standard").getByName("Namndialog"), > which is a simple dialogue, seems to be an object of some kind and > it's not very obvious how to get the information I need from it (like > labels names of buttons and other objects, which macro they call and > so on). I guess I have to study it a bit closer, but all shortcuts > (like if someone would like to provide an example of some kind or > something) are welcome… > > After having studied it only for maybe a minute or so, it seems like I > need to know what I'm looking for to look for it… But studying it more > might give me another impression of the whole thing, I don't know. I think I have it now. I have to create a UNO dialogue first, then I can get my info from it. I think the following code will give me every information I want from one of my dialogues: Sub main Dim X As Object X=CreateUnoDialog(DialogLibraries.getByName("Standard").getByName("Resultatdialog")) Xray X End Sub 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: How can I read my code in a module in the Basic IDE with Basic code?
2011/8/14 Johnny Rosenberg : > 2011/8/14 Johnny Rosenberg : >> 2011/8/14 Oliver Brinzing : >>> Hi Johnny, >>> If I only can read all the text in one module at once, that would do it just fine. If there is a simple one-liner that reads just one function or subroutine, that's a bonus, and if I can read a dialogue that's even better… >>> >>> Have you tried: >>> >>> Sub Test() >>> >>> Dim oLibs as Object >>> Dim oLib as Object >>> Dim sLib as String >>> >>> Dim mTmp() >>> Dim i as Integer >>> Dim s as String >>> >>> sLib = "Standard" >>> oLibs = GlobalScope.BasicLibraries >>> If Not oLibs.hasByName(sLib) Then >>> MsgBox "Error reading " & sLib >>> EndIf >>> >>> oLib = oLibs.getByName(sLib) >>> >>> mTmp() = oLib.getElementNames() >>> >>> For i = 0 To uBound(mTmp()) >>> s = s + mTmp(i) & Chr(13) >>> Next i >>> MsgBox s >>> >>> MsgBox oLib.getByName(mTmp(0)) >>> >>> End Sub >> >> No, I didn't, but it seems to work for my global macros. I guess I >> need to change the ”oLibs = GlobalScope.BasicLibraries” line for local >> code (macros for the current document only), but to what? >> >> >> Regards >> >> Johnny Rosenberg >> ジョニー・ローゼンバーグ >> >>> Regards >>> Oliver >> > > Experimented a bit: > Sub Main > Dim A As String > > ' Getting code from the tab ”Spel” in the current document: > A=ThisComponent.BasicLibraries.getByName("Standard").getByName("Spel") > MsgBox A > End Sub > > Thanks for your hint! > > > Kind regards > > Johnny Rosenberg > ジョニー・ローゼンバーグ > Also tried with Dialogues, but (in my case, as an example) ThisComponent.DialogLibraries.getByName("Standard").getByName("Namndialog"), which is a simple dialogue, seems to be an object of some kind and it's not very obvious how to get the information I need from it (like labels names of buttons and other objects, which macro they call and so on). I guess I have to study it a bit closer, but all shortcuts (like if someone would like to provide an example of some kind or something) are welcome… After having studied it only for maybe a minute or so, it seems like I need to know what I'm looking for to look for it… But studying it more might give me another impression of the whole thing, I don't know. 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: How can I read my code in a module in the Basic IDE with Basic code?
2011/8/14 Johnny Rosenberg : > 2011/8/14 Oliver Brinzing : >> Hi Johnny, >> >>> If I only can read all the text in one module at once, that would do >>> it just fine. If there is a simple one-liner that reads just one >>> function or subroutine, that's a bonus, and if I can read a dialogue >>> that's even better… >> >> Have you tried: >> >> Sub Test() >> >> Dim oLibs as Object >> Dim oLib as Object >> Dim sLib as String >> >> Dim mTmp() >> Dim i as Integer >> Dim s as String >> >> sLib = "Standard" >> oLibs = GlobalScope.BasicLibraries >> If Not oLibs.hasByName(sLib) Then >> MsgBox "Error reading " & sLib >> EndIf >> >> oLib = oLibs.getByName(sLib) >> >> mTmp() = oLib.getElementNames() >> >> For i = 0 To uBound(mTmp()) >> s = s + mTmp(i) & Chr(13) >> Next i >> MsgBox s >> >> MsgBox oLib.getByName(mTmp(0)) >> >> End Sub > > No, I didn't, but it seems to work for my global macros. I guess I > need to change the ”oLibs = GlobalScope.BasicLibraries” line for local > code (macros for the current document only), but to what? > > > Regards > > Johnny Rosenberg > ジョニー・ローゼンバーグ > >> Regards >> Oliver > Experimented a bit: Sub Main Dim A As String ' Getting code from the tab ”Spel” in the current document: A=ThisComponent.BasicLibraries.getByName("Standard").getByName("Spel") MsgBox A End Sub Thanks for your hint! 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: How can I read my code in a module in the Basic IDE with Basic code?
2011/8/14 Oliver Brinzing : > Hi Johnny, > >> If I only can read all the text in one module at once, that would do >> it just fine. If there is a simple one-liner that reads just one >> function or subroutine, that's a bonus, and if I can read a dialogue >> that's even better… > > Have you tried: > > Sub Test() > > Dim oLibs as Object > Dim oLib as Object > Dim sLib as String > > Dim mTmp() > Dim i as Integer > Dim s as String > > sLib = "Standard" > oLibs = GlobalScope.BasicLibraries > If Not oLibs.hasByName(sLib) Then > MsgBox "Error reading " & sLib > EndIf > > oLib = oLibs.getByName(sLib) > > mTmp() = oLib.getElementNames() > > For i = 0 To uBound(mTmp()) > s = s + mTmp(i) & Chr(13) > Next i > MsgBox s > > MsgBox oLib.getByName(mTmp(0)) > > End Sub No, I didn't, but it seems to work for my global macros. I guess I need to change the ”oLibs = GlobalScope.BasicLibraries” line for local code (macros for the current document only), but to what? Regards Johnny Rosenberg ジョニー・ローゼンバーグ > Regards > Oliver -- - 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: How can I read my code in a module in the Basic IDE with Basic code?
Hi Johnny, > If I only can read all the text in one module at once, that would do > it just fine. If there is a simple one-liner that reads just one > function or subroutine, that's a bonus, and if I can read a dialogue > that's even better… Have you tried: Sub Test() Dim oLibs as Object Dim oLib as Object Dim sLib as String Dim mTmp() Dim i as Integer Dim s as String sLib = "Standard" oLibs = GlobalScope.BasicLibraries If Not oLibs.hasByName(sLib) Then MsgBox "Error reading " & sLib EndIf oLib = oLibs.getByName(sLib) mTmp() = oLib.getElementNames() For i = 0 To uBound(mTmp()) s = s + mTmp(i) & Chr(13) Next i MsgBox s MsgBox oLib.getByName(mTmp(0)) End Sub Regards Oliver -- GnuPG key 0xCFD04A45: 8822 057F 4956 46D3 352C 1A06 4E2C AB40 CFD0 4A45 signature.asc Description: OpenPGP digital signature