Paradox Community

Items in pnews.paradox-programming

Subject:Re: Library To Library
Date:Fri, 11 Jan 2019 18:38:33 -0800
From:Peter <peter@whiteknight.email>
Newsgroups:pnews.paradox-programming
It'll take a bit to digest, but I want to say thanks right away.

Peter


On 01/11/2019 12:30 PM, Mark Bannister wrote:
> I have one library that I open as a library and it opens all the other 
> libraries as forms.
> Technically it opens the each library as a library but then attaches a 
> from variable to the library that is used by other libraries and forms.
> 
> 
> Main Opening library  code
> 
> Global to library
> Var
> libar dynarray[] library
> libNamearGL array[] string
> loCloseGL  logical
> endvar
> 
> Const
>     stTitleTagCT = " Library Form"
> endconst
> 
> 
> 
> method to open each library
> 
> var
>      errar array[] string
> endvar
> 
> method cmOpenAlpha(stLibName string
>                    ,stALias string
>                    ,var LibForm form
>                    ) logical
> var
>     answer   logical
>     loOpen logical
>     loErr    logical
> endvar
> 
> try
>     loOpen = False
>     if libar.contains( stLibname ) then
>         loOpen =  libar[ stlibname ] .isassigned()
> 
>     endif
>     if  errar.contains( stLibname ) then
>         answer = False
>     else
> 
>           if NOt loOpen then
>               ;need to open it
>               try
>                  ;// open ldl unless in debug mode
>                  libar[ stlibname ] .open(stAlias+stLibName+ 
> iif(DebugModeLO(),".lsl",".ldl") )
>               onfail
>                  ErrorClear()
>                  ;// open lsl version
>                  libar[ stlibname ] .open(stAlias+stLibName+".lsl")
>               endtry
> 
> 
>               ;/////////////////////////////////////////
>               ;/////////////////////////////////////////
>               sleep()
> 
> 
> 
>               if NOT libForm.attach(stLibName+stTitleTagCT) then
>                  fail(UserError,"Did not attach form var to libary")
>               endif
> 
>               LibForm.SetTitle(stLibName+stTitleTagCT+" run")
> 
> 
> 
>               if  loErr then
>                  errar.addlast( stLibName )
>               endif
> 
>               answer = NOT loErr
>            else
> 
>                if NOT libForm.attach(stLibName+stTitleTagCT+" run") then
>                  fail(UserError,"Failed to attach to library that should

> be open.")
>                endif
> 
>               answer = true
> 
>            endif
> 
> 
>     endif
> 
> Onfail
>      errorshow("mngrOpenLibs.CMOpenALpha\nDid not open library: 
> "+stalias+stlibname)
>       errar.addlast( stLibName )
>      answer = false
> endtry
> return answer
> endMethod
> 
> 
> 
> method cmCloseLib( stlibname string) string
> var
>     answer string
> endvar
> 
> try
>     answer = ""
>        if libar[ stlibname ] .isassigned() then
>           answer = "assigned"
> 
>           libar[ stlibname ] .close()
> 
>           sleep()
>            answer = "\t\t-- closed"
>        else
>           answer = "\t\t-- not open"
>        endif
> 
> onfail
>     errorshow("******  Errorclosing library *******")
>     answer = answer + "\t\t******  Errorclosing library *******"
> endtry
> return answer
> endMethod
> 
> method close(var eventInfo Event)
> var
>     stLib   string
> 
> endvar
> loCloseGL = true
> 
> 
> 
> foreach stlib in libar
> 
>      cmcloselib( stlib )
> 
> endforeach
> 
> 
> 
> dodefault
> 
> return
> 
> endMethod
> 
> 
> ;// call this once for each libary to add titles to your libraries so we 
> can attach to them later
> method Titlelibrary(stShortName        string  ;cont or mngrforms w/o 
> extension
>                     ,stAlias            string   ;with ::
> 
>                      )   logical
> var
>     lib library
>     f   form
>     sttemp,stFile,sttitle  string
>     fs  filesystem
> 
>     answer
>     ,loErr        logical
> endvar
> try
> 
>    loerr = iserrortraponwarnings()
>     ErrorTraponwarnings(yes)
> 
>        ;stShortName = "mngrOPenLibs"
> 
>        sttemp = "__temp"
> 
>        stFile  =stAlias + stShortName
>        stTitle = stShortName + stTitleTagCT
> 
>        fs.copy(stfile+".lsl", stFile+"__notitle"+".lsl")
>        sleep()
>        fs.rename(stfile+".lsl",stFile+sttemp+".fsl")
>        sleep()
>        f.load(stFile+sttemp+".fsl")
>        sleep()
>        f.settitle(stTitle)
>        f.HorizontalScrollbar = false
> 
>        f.VerticalScrollBar = false
>        f.save()
>        sleep()
>        f.close()
>        f.unassign()
> 
> 
>        sleep()
>        fs.rename(stFile+sttemp+".fsl",stFile+".lsl" )
>        sleep()
> 
> 
> 
>        ; lib.open(stfile+".lsl")
> 
>        ;f.attach(stTitle)
> answer = true
> onfail
>        errorshow()
>        answer = false
> endtry
> ErrorTraponwarnings(loErr)
> return answer
> 
> endMethod
> 
> 
> 
> To open a library from a form...
> In the form's init method:
> ;// open the main library opening form as a library
>     if not libOpenLibs.open ( ":MngrForms:mngrOpenLibs.ldl" ) then
>             errorclear ( )
>             if not libOpenLibs.open ( ":MngrForms:MngrOpenlibs.lsl" ) then
>                  errorShow ( "Library mngrOpnelibs did not open" )
>             endIf
>        endIf
> 
> ;// open each library you need WITH a FORM VAR declared globally to this 
> form
>        if Not libOpenLibs.cmOpenLibrary ( "mngrforms" , "alias" , 
> libForms ) then
>             fail ( USererror + 1 , "" )
>             close ( )
>        endIf
> 
> 
> 
> 
> 
> On 1/11/2019 11:17 AM, Peter wrote:
>> Thanks for the replies guys.
>>
>> Mark, I am interested in exploring your method if you have time to 
>> post your code.
>>
>> Peter
>>
>>
>> On 01/11/2019 06:03 AM, Mark Bannister wrote:
>>> Yes, but you have to be careful about getting methods calling each 
>>> other recursively.  Things get messy really fast.  Also only work on 
>>> one library at a time because if you save a library with errors it 
>>> causes any other libraries that use that library to have compile errors.
>>>
>>> I open libraries as forms to avoid the recursive problems, but I have 
>>> a lot of libraries.  I create the library.  Give it a title (using 
>>> code). Then open the library with myform.open or if the library is 
>>> already open I use myform.attach("library title").
>>> I can post the code I use if you need it.
>>>
>>>
>>> On 1/10/2019 7:22 PM, Peter wrote:
>>>> Can a library call/use a method in another library? Thank you.
>>>>
>>>> Peter
>>>
> 


Copyright © 2004 thedbcommunity.com