Creating Library Modules

Dave dave at looktowindward.com
Thu Jul 10 08:03:21 EDT 2008


Hi,

To answer some of you questions:


> SO an independent stack library can be called by the main stack,  
> but the
> code must be independent and does not have access to any of the  
> functions or
> commands in the stack that started it.

Yes, it's much better practice to have libraries totally independent  
of the calling stack. They way they can be just dropped into any  
project and even used by other Library Stacks.

However it is possible to have the Library call functions in the main  
stack - see below. If you have "common" functions you want to call  
from all StandardReports1.rev, StandardReports2.rev,  
StandardReports3.rev it would be better to just create another  
"Common" library file that contains all your common functions. Then  
do a start using on this stack in the "libraryStack" handler of  
StandardReports1, 2, 3 etc.

> Can variables be passed between the
> functions and data returned by the function?

Yes, here is a function that accepts data and returns data in two ways:

function ATestFunction theInputData, at theOutputData

put theInputData & "-HELLO-" into theOutputData

return 76
end ATestFunction


To call it:

put ATestFunction("GoodBye",myData) into myResult

After this has been called, myData = "GoodBye-HELLO-" and myResult = 76

>
> How do I get the independent stack to start using the Main stack?   
> The main
> stack is already in memory.
>


If you *really* want to do it this way, then all you do is put:

start using me

In the preOpenStack handler of the main stack.

Hope this helps
All the Best
Dave

On 10 Jul 2008, at 05:46, dcpbarrington wrote:

>
> I have created the StandardRepor.rev as an independent stack and  
> the Main
> stack starts the independent stack by doing the following:
>
>   if "StandardReports" is not among the lines of the StacksInUse then
>     start using stack "StandardReports"
>   end if
>
> What I want to be able to do is be able to supply different sets of  
> reports
> like a set of libraries.  The main program selects either  
> StandardReports OR
> CustomReports1 OR CustomReports2 and the main stack starts a specific
> library based on the configuration.  Each of the Stacks would have  
> the same
> report functions, but depending on what stack is started, the user  
> can get
> different report formats for the same set of information.
>
> SO an independent stack library can be called by the main stack,  
> but the
> code must be independent and does not have access to any of the  
> functions or
> commands in the stack that started it.  Can variables be passed  
> between the
> functions and data returned by the function?
>
> How do I get the independent stack to start using the Main stack?   
> The main
> stack is already in memory.
>
>
> Sarah Reichelt-2 wrote:
>>
>>
>> Is the StandardReport stack a sub-stack of the Main Stack or is it a
>> separate file?
>> If it is a sub-stack, then it automatically gets access to all the
>> handlers in the Main Stack, but if it is a separate file, they are
>> independent. You would then have to "start using" the Main Stack as
>> well, if you wanted StandardReport to be able to use it's handlers.
>>
>> The "StandardReport.rev" file can be placed anywhere you like, but if
>> you want MainStack to be able to refer to it automatically, then se
>> the Main Stacks stackFiles property to include a reference to
>> "StandardReport.rev".
>>
>> HTH,
>> Sarah
>> _______________________________________________
>> use-revolution mailing list
>> use-revolution at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-revolution
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/Creating- 
> Library-Modules-tp18368070p18375828.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the Use-livecode mailing list