Creating Library Modules

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Creating Library Modules

dcpbarrington
Greetings,

I have a Rev 2.9 application that I'm building that creates a set of reports.  I have the report working as a button in the main stack, but I now want to create a library module that will allow me to seperate the report code from the main stack so it can be pulled in with different report versions as needed.

I created a new STACK called it "StandardReports.rev"

I moved the code that I know was working to the "StandardReports.rev" stack script area.

In the original stack I make the following call to see if the new stack is running.

  if "StandardReports" is not among the lines of the StacksInUse then  
    start using stack "StandardReports"
  end if

The function call to the new stack works, but in that stack there are a number of Commands that are defined in the Main Stack that are no longer found by the routines in the "StandardReport" stack.

One example is when I do a DB call, I check for an error with handleRevDBerror command that is defined as:

on handleRevDBerror pError
  switch
  case item 1 of pError is "revdberr"
    return "Database Error: " & pError
    break
   end switch
end handleRevDBerror

Revolution errors when ever the "StandardReport" stack tries to call this command.

What do I need to do to be able to access Commands and Functions that are in the Main Stack?

ALSO, can the "StandardReport.rev" file be placed in any directory or does it need to be with the main stack?


Thanks for the help
Reply | Threaded
Open this post in threaded view
|

Re: Creating Library Modules

masmit
What's the error that you see?

Best,

Mark

On 9 Jul 2008, at 19:39, dcpbarrington wrote:

>
> Greetings,
>
> I have a Rev 2.9 application that I'm building that creates a set of
> reports.  I have the report working as a button in the main stack,  
> but I now
> want to create a library module that will allow me to seperate the  
> report
> code from the main stack so it can be pulled in with different report
> versions as needed.
>
> I created a new STACK called it "StandardReports.rev"
>
> I moved the code that I know was working to the  
> "StandardReports.rev" stack
> script area.
>
> In the original stack I make the following call to see if the new  
> stack is
> running.
>
>   if "StandardReports" is not among the lines of the StacksInUse then
>     start using stack "StandardReports"
>   end if
>
> The function call to the new stack works, but in that stack there  
> are a
> number of Commands that are defined in the Main Stack that are no  
> longer
> found by the routines in the "StandardReport" stack.
>
> One example is when I do a DB call, I check for an error with
> handleRevDBerror command that is defined as:
>
> on handleRevDBerror pError
>   switch
>   case item 1 of pError is "revdberr"
>     return "Database Error: " & pError
>     break
>    end switch
> end handleRevDBerror
>
> Revolution errors when ever the "StandardReport" stack tries to  
> call this
> command.
>
> What do I need to do to be able to access Commands and Functions  
> that are in
> the Main Stack?
>
> ALSO, can the "StandardReport.rev" file be placed in any directory  
> or does
> it need to be with the main stack?
>
>
> Thanks for the help
> --
> View this message in context: http://www.nabble.com/Creating- 
> Library-Modules-tp18368070p18368070.html
> Sent from the Revolution - User mailing list archive at Nabble.com.
>
> _______________________________________________
> use-revolution mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution

_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Creating Library Modules

mwieder
In reply to this post by dcpbarrington
Sounds like you may have a problem with the message hierarchy. Try

insert the script of stack "StandardReports" into front

instead of

start using stack "StandardReports"

and check out Richard Gaskin's article on message paths at:

http://www.fourthworld.com/embassy/articles/revolution_message_path.html

--
 Mark Wieder
 [hidden email]



_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
--
 Mark Wieder
 ahsoftware@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: Creating Library Modules

dcpbarrington
Mark,

  I looked at the article, which is very good, but I still don't understand when I start a library, it should be at a higher level then the Main Stack, so there shouldn't be a problem finding the handleRevDBerror command.

  It looks like because I created the library as an independent stack, it looks like Revolution is putting it at the Main Stack level, so it doesn't find the commands that are defined in the original Main Stack.

  I changed the start to be

    insert the script of stack "StandardReports" into front

I Saved and Restarted Revolution.  Had the same error.

      executing at 5:11:05 PM
Type Handler: can't find handler
Object StandardReports
Line handleRevDBerror theDataVal
Hint handleRevDBerror

I created the Stack as a NEW stack and then started it.  Do I need to make it a SubStack and then select FILE -> MOVE SUBSTACK to FILE

I cann't find anything in the documentation about creating a library.  Do I need to declare within the stack that it is a library that is to be used with the main stack?
Reply | Threaded
Open this post in threaded view
|

Re: Creating Library Modules

Sarah Reichelt-2
In reply to this post by dcpbarrington
> I have a Rev 2.9 application that I'm building that creates a set of
> reports.  I have the report working as a button in the main stack, but I now
> want to create a library module that will allow me to seperate the report
> code from the main stack so it can be pulled in with different report
> versions as needed.
>
> I created a new STACK called it "StandardReports.rev"
>
> I moved the code that I know was working to the "StandardReports.rev" stack
> script area.
>
> In the original stack I make the following call to see if the new stack is
> running.
>
>  if "StandardReports" is not among the lines of the StacksInUse then
>    start using stack "StandardReports"
>  end if
>
> The function call to the new stack works, but in that stack there are a
> number of Commands that are defined in the Main Stack that are no longer
> found by the routines in the "StandardReport" stack.
>
> One example is when I do a DB call, I check for an error with
> handleRevDBerror command that is defined as:
>
> on handleRevDBerror pError
>  switch
>  case item 1 of pError is "revdberr"
>    return "Database Error: " & pError
>    break
>   end switch
> end handleRevDBerror
>
> Revolution errors when ever the "StandardReport" stack tries to call this
> command.
>
> What do I need to do to be able to access Commands and Functions that are in
> the Main Stack?
>
> ALSO, can the "StandardReport.rev" file be placed in any directory or does
> it need to be with the main stack?


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
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Creating Library Modules

mwieder
In reply to this post by dcpbarrington
> I created the Stack as a NEW stack and then started it.  Do I need to make
> it a SubStack and then select FILE -> MOVE SUBSTACK to FILE

Er... wait... this is a separate stack entirely? Not a substack of your main
stack? Have you already loaded it into memory? Neither the "start using"
command nor the "insert" command are going to be able to find the stack
otherwise unless you specify a physical location for it. Much better to make
your library stack a substack. Then your "start using" command will probably
do the trick for you.

> I cann't find anything in the documentation about creating a library.  Do
> I
> need to declare within the stack that it is a library that is to be used
> with the main stack?

Nope. You've done that all correctly. Any stack can be used as a library
stack without any fiddling about.

--
 Mark Wieder
 [hidden email]



_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
--
 Mark Wieder
 ahsoftware@gmail.com
Reply | Threaded
Open this post in threaded view
|

Re: Creating Library Modules

dcpbarrington
In reply to this post by Sarah Reichelt-2
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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Creating Library Modules

Dave-272
Hi,

I think your problem is that you are not loading the library stack  
correctly. The best way to do this is to use a full path name to  
the .rev file, as in: <FULLPATH>StandardReports.rev. You can grab the  
full path of the currently running stack like so:

put the filename of this stack into myStackFilePathName
set the itemDelimiter to "/"
put "StandardReports.rev" into item -1 of myStackFilePathName

start using myStackFilePathName

Put this in the preOpenStack handler in card 1 of your main stack.

Hope this helps
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
>> [hidden email]
>> 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
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution


_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
Reply | Threaded
Open this post in threaded view
|

Re: Creating Library Modules

Dave-272
In reply to this post by dcpbarrington
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,@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
>> [hidden email]
>> 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
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your  
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution


_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution