IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
To/From Code
-Collapse +Expand Cross Ref Guide
-Collapse +Expand Members-Only
Sign in to see member-only pages.
   ► KBTo/From GuidesJavaScript  Print This     

Custom Routines (JavaScript and Delphi Prism Cross Reference Guide)

By Mike Prestwood

JavaScript versus Delphi Prism: A side by side comparison between JavaScript and Delphi Prism.

 
Language Details
 

Language Details is kind of a catch all for stuff that didn't make it into language basics nor any other category.

Custom Routines

[Other Languages] 

Languages Focus

For non-OOP languages, a custom routine is a function, procedure, or subroutine and for pure OOP languages, a custom routine is a class method. Hybrid languages (both non-OOP and OOP) combine both.

JavaScript:   function

JavaScript uses functions and loosely typed parameters. Function definitions must come before their usage so the usual preference when adding JavaScript to HTML pages is to include them between the head tags.

Syntax Example:
function SayHello(pName) {
 document.write("Hello " + pName + "<br>");
}
 
function add(p1, p2) {
 var result;
 
 result = p1 + p2;
 return result;
}
Delphi Prism:   method, procedure, function

In Prism, everything is within a class (just like with C#, VB.Net, and Java). So you create class methods using the method keyword. Alternatively, you can use procedure or function if you want the compiler to enforce returning or not returning a value.

[function/procedure] RoutineName : ReturnType; 

As with C++, your custom routine must come before it's first usage or you have to prototype it in the Interface section.

Syntax Example:
method Form1.IntroduceYourself;
begin
  MessageBox.Show("Hello, I do not have a name yet.");
end;

procedure Form1.SayHello(pName: String);
begin
  MessageBox.Show("Hello " + pName);
end;
 
function Form1.Add(p1, p2 : Double): Double;
begin
  Result := p1 + p2;
end;












Go ahead!   Use Us! Call: 916-726-5675  Or visit our new sales site: 
www.prestwood.com


©1995-2024 Prestwood IT Solutions.   [Security & Privacy]