PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

Home | Sign in | English US
  • Overview
  • How to create a procedure in Java code?
  • Typing the code of a global procedure in Java
  • Important notes
  • How to run a WLanguage procedure?
  • Running a WLanguage procedure from the Java code
  • Important notes
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Overview
You have the ability to type Java code:
  • in the Java applications generated with WINDEV.
  • in the Android applications generated with WINDEV Mobile.
This allows you to create global procedures in Java.
Versions 17 and later
These Java procedures can directly call the WLangage procedures of your project.
New in version 17
These Java procedures can directly call the WLangage procedures of your project.
These Java procedures can directly call the WLangage procedures of your project.
How to create a procedure in Java code?

Typing the code of a global procedure in Java

To type the code of a global procedure in Java:
  1. Create a new global procedure (via "New global procedure" from the popup menu of sets of procedures in the "Project explorer" pane). Specify the name of this procedure.
  2. In the code editor, click the "WL" letters displayed in front of the caption of global procedure. The bar becomes purple and the "Java" characters appear in front of the procedure name. The existing code is changed into comments.
For example:
WLanguage procedure
becomes:
Java procedure
Note: To go back to WLanguage code, all you have to do is click "Java" in the procedure bar.

Important notes

  • Passing parameters to a Java procedure is automatically done by value.
  • The parameters of procedures written in Java must necessarily be typed with a primitive type (integer, real, string, ...).
    Caution: The float type is not supported, it can be replaced by the double type.
  • The return values of methods must necessarily correspond to a primitive type (integer, real, string, ...).
    Caution: The float type is not supported, it can be replaced by the double type.
  • Caution: you must add the imports corresponding to the Java classes used in the native Java code entered (via the "Import" keyword). For better legibility, we advise you to add these imports before declaring the method.
  • Android The Java classes used in the native Java code must be specified in the wizard for generating the Android application:
    • "Integrating libraries" step for the classes included in ".jar" or ".aar" libraries.
    • "Integrating Maven dependencies" step for the Maven dependencies.
      Note: The test of these classes cannot be run in GO mode. The application must be generated and started.
  • Java The Java classes used in the native Java code must be specified in the wizard for generating the Java application ("Other archive files" step).
    Note: The test of these classes cannot be run in GO mode. The application must be generated and started.
Versions 17 and later
How to run a WLanguage procedure?

Running a WLanguage procedure from the Java code

To run a WLanguage procedure from the Java code, you must call one of the following methods according to the type of value returned by the procedure:
Method NameReturn Java type
callWLProcedurevoid (no return value)
callWLProcedure_StringString
callWLProcedure_intint
callWLProcedure_doubledouble
callWLProcedure_longlong
callWLProcedure_booleanboolean
During the call to the selected method:
  • the first parameter to pass to the method corresponds to the name of the WLanguage procedure to run.
  • the other parameters correspond to the parameters expected by the WLanguage procedure (if necessary). You have the ability to use parameters of any simple Java type (string, int, double, long, boolean, ...). If the specified parameter does not correspond to a simple Java type, it will be automatically converted into "string" by a call to its "toString()" method.
Example:
Code of WLanguage procedure:
GLOBAL PROCEDURE MyProcedure(n is int, b is boolean, s is string)
...

RESULT s
To call the MyProcedure procedure from the Java code:
callWLProcedure_String("MyProcedure",5,false,"test")

Important notes

  • If the procedure to run is a local procedure, we advise you to give its full name by specifying the name of the element to which the procedure belongs. Example : "WIN_Window1.MyProcedure".
  • The name of procedure to run must only contain non-accented alphanumeric characters.
  • If the procedure to run returns a value, this value will be automatically converted into the primitive Java type corresponding to the method used when calling the procedure. A fatal error will occur if the conversion cannot be performed.
  • The procedure parameters are passed by copy.
New in version 17
How to run a WLanguage procedure?

Running a WLanguage procedure from the Java code

To run a WLanguage procedure from the Java code, you must call one of the following methods according to the type of value returned by the procedure:
Method NameReturn Java type
callWLProcedurevoid (no return value)
callWLProcedure_StringString
callWLProcedure_intint
callWLProcedure_doubledouble
callWLProcedure_longlong
callWLProcedure_booleanboolean
During the call to the selected method:
  • the first parameter to pass to the method corresponds to the name of the WLanguage procedure to run.
  • the other parameters correspond to the parameters expected by the WLanguage procedure (if necessary). You have the ability to use parameters of any simple Java type (string, int, double, long, boolean, ...). If the specified parameter does not correspond to a simple Java type, it will be automatically converted into "string" by a call to its "toString()" method.
Example:
Code of WLanguage procedure:
GLOBAL PROCEDURE MyProcedure(n is int, b is boolean, s is string)
...

RESULT s
To call the MyProcedure procedure from the Java code:
callWLProcedure_String("MyProcedure",5,false,"test")

Important notes

  • If the procedure to run is a local procedure, we advise you to give its full name by specifying the name of the element to which the procedure belongs. Example : "WIN_Window1.MyProcedure".
  • The name of procedure to run must only contain non-accented alphanumeric characters.
  • If the procedure to run returns a value, this value will be automatically converted into the primitive Java type corresponding to the method used when calling the procedure. A fatal error will occur if the conversion cannot be performed.
  • The procedure parameters are passed by copy.
How to run a WLanguage procedure?

Running a WLanguage procedure from the Java code

To run a WLanguage procedure from the Java code, you must call one of the following methods according to the type of value returned by the procedure:
Method NameReturn Java type
callWLProcedurevoid (no return value)
callWLProcedure_StringString
callWLProcedure_intint
callWLProcedure_doubledouble
callWLProcedure_longlong
callWLProcedure_booleanboolean
During the call to the selected method:
  • the first parameter to pass to the method corresponds to the name of the WLanguage procedure to run.
  • the other parameters correspond to the parameters expected by the WLanguage procedure (if necessary). You have the ability to use parameters of any simple Java type (string, int, double, long, boolean, ...). If the specified parameter does not correspond to a simple Java type, it will be automatically converted into "string" by a call to its "toString()" method.
Example:
Code of WLanguage procedure:
GLOBAL PROCEDURE MyProcedure(n is int, b is boolean, s is string)
...

RESULT s
To call the MyProcedure procedure from the Java code:
callWLProcedure_String("MyProcedure",5,false,"test")

Important notes

  • If the procedure to run is a local procedure, we advise you to give its full name by specifying the name of the element to which the procedure belongs. Example : "WIN_Window1.MyProcedure".
  • The name of procedure to run must only contain non-accented alphanumeric characters.
  • If the procedure to run returns a value, this value will be automatically converted into the primitive Java type corresponding to the method used when calling the procedure. A fatal error will occur if the conversion cannot be performed.
  • The procedure parameters are passed by copy.
Related Examples:
WM Expense Account Cross-platform examples (WINDEV Mobile): WM Expense Account
[ + ] This example allows you to manage your fees.

Let's see the main features of this application:
- The input of invoices
- Management of foreign currencies
- Inclusion of photo document for the invoices
- Ability to email the expense account
- Ability to track the expense accounts
- ...
Minimum required version
  • Version 10
This page is also available for…
Comments
Click [Add] to post a comment