Discussion:
How can I read my code in a module in the Basic IDE with Basic code?
Johnny Rosenberg
2011-08-14 06:11:37 UTC
Permalink
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
ジョニー・ローゼンバーグ
--
-----------------------------------------------------------------
To unsubscribe send email to dev-***@api.openoffice.org
For additional commands send email to ***@api.openoffice.org
with Subject: help
Oliver Brinzing
2011-08-14 07:55:53 UTC
Permalink
Hi Johnny,
Post by Johnny Rosenberg
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
Johnny Rosenberg
2011-08-14 15:39:07 UTC
Permalink
Post by Oliver Brinzing
Hi Johnny,
Post by Johnny Rosenberg
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…
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
ジョニー・ローゼンバーグ
Post by Oliver Brinzing
Regards
Oliver
--
-----------------------------------------------------------------
To unsubscribe send email to dev-***@api.openoffice.org
For additional commands send email to ***@api.openoffice.org
with Subject: help
Johnny Rosenberg
2011-08-14 16:12:03 UTC
Permalink
Post by Johnny Rosenberg
Post by Oliver Brinzing
Hi Johnny,
Post by Johnny Rosenberg
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…
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
ジョニー・ローゼンバーグ
Post by Oliver Brinzing
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-***@api.openoffice.org
For additional commands send email to ***@api.openoffice.org
with Subject: help
Johnny Rosenberg
2011-08-14 18:06:13 UTC
Permalink
Post by Johnny Rosenberg
Post by Johnny Rosenberg
Post by Oliver Brinzing
Hi Johnny,
Post by Johnny Rosenberg
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…
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
ジョニー・ローゼンバーグ
Post by Oliver Brinzing
Regards
Oliver
Sub Main
       Dim A As String
       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-***@api.openoffice.org
For additional commands send email to ***@api.openoffice.org
with Subject: help
Johnny Rosenberg
2011-08-14 19:01:30 UTC
Permalink
Post by Johnny Rosenberg
Post by Johnny Rosenberg
Post by Johnny Rosenberg
Post by Oliver Brinzing
Hi Johnny,
Post by Johnny Rosenberg
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…
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
ジョニー・ローゼンバーグ
Post by Oliver Brinzing
Regards
Oliver
Sub Main
       Dim A As String
       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-***@api.openoffice.org
For additional commands send email to ***@api.openoffice.org
with Subject: help
Andrew Douglas Pitonyak
2011-08-14 22:57:34 UTC
Permalink
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.
Post by Johnny Rosenberg
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-***@api.openoffice.org
For additional commands send email to ***@api.openoffice.org
with Subject: help
Loading...