Methods and Libraries question

I have not used methods before nor used Libraries and the documentation out there is bit confusing to me. Can somebody that has used methods and libraries provide an example of how to create and run a method, then use the libraries to what? store them??.

On libraries: Where do you enter the objects for the library are I imaging these to be methods or functions correct?

Last question is a real dumb question but I have to get out of being dumb and ask away.
What is the difference between a javascript method and a php method and more important when to use a javascript method vs. a php method.

I have an application to setup a project with people to work on it so I need the number of people on the project which I already have, I then need to distribute records from the database to each participant or “peple” working on that project, now the problem is that if there are more people than records available to distribute the process stops so I need to know beforehand how to check this condition using a “button” to run a method or function to give this information and thus, "this is the reason of me asking about methods and libraries.

Thanks in advance.

Re: Methods and Libraries question

In SC / Tools / Libraries select “New” (Public, Project or User) and write your PHP-Code and save it to mylib.php:


<?php
/*
 * MyLib
*/

function MyLib_Func($param1, $param2, ... $paramX)
{

 $result = 0;
 
 /* your PHP Code */

 return $result;
}
?>

Then select in your Application / Programming / Libraries (Public, Project or User) your Library.

In your PHP-Code (Event x) you can use your Library:

$result = MyLib_Func($param1, $param2, … $paramX);

If you want to use a lot of code in different projects, then I would use libraries. Will you only call a method here and there, then take Application / Programming / Methods.

Methods PHP => running on server side
Methods Javascript => running on client side

Re: Methods and Libraries question

Wow! thanks for the reply, very helpful.
When you said if you are going to use a lot of code use Libraries, mmm, not sure what that means have an example?? …

Thanks again.

Re: Methods and Libraries question

A library is a php file that can be used in all of your applications. While if you create only a method you’ll need to create the same method where you want to use.

Re: Methods and Libraries question

A method is available only for the application it is defined in.
If you put a function in a library, the function can be made available to more than one, or all, applications by including the library in the application (Programming -> libraries)).

If you change the code in a library, don’t forget to:

  • upload it again (Tools -> libraries) so SC can see the new version
  • regenereate applications using this library.

Cheers.