PHP Method or Library or ?

I have bits of my code as PHP functions, where I create and then call the function from within an event, usually onLoad.

Is there a way to make these functions available to other Scriptcase programs so that if I need to change the function it changes it for all programs?

would that be a library? Perhaps an internal library?

I haven’t used PHP methods much but they seem like I would have to edit the method in every application that used the same method.

I need to send a variable to my function and it needs to return an array back to my code.

any advice on the way to do this best would be great. The goal is to get reusable bits of code that can be easily updated in the future in one place.

Also my functions include Scriptcase macros to lookup data in the database, so they have to work in order for my function to work.

thanks!

You must create your own libraries with functions: Tools -> Internal Libraries -> Select (Public - Project - User) -> Button NEW.
Put Your Code Php .

For use it: in your apps In Programming Sections: Select: Internal Libraries and check your libraries.

@alvagar Nailed it!! Thanks so much!

I just got my “a ha!” moment and am now developing my own libraries that are full of functions I can re-use over and over and enhance when changes need to made!

For anyone else or my future self lest I forget… here is what I have done:

  1. Created a function in PHP that accepts data from a variable and returns an array of data.
  2. Put that function into an “Internal Library” within the “Project” scope and named it according the the group of functions I will be using… eg. “ShippingFunctionsV1” for a group of functions that are to be used in my shipping system.
  3. Check the box next to the Library name on the application I want to use these functions in.
  4. Call the functions from within the event(s) where I need them by using the following syntax:
    eg. Function named GetAvailableRates
    Within Scriptcase event onLoad I put $availrates = GetAvailableRates(565593);
    This function GetAvailableRates has a “return $rates;” at the bottom of it which is an array of data.
    The function takes the number 565593 in this example to go look up the rates, that number could also be a variable like $var and not a direct number.
    My application now has that array of data named $availrates

This is going to be awesome!

:);):cool: Good Luck.