PC SOFT

ONLINE HELP
FOR WINDEV, WEBDEV AND WINDEV MOBILE

  • Overview
  • Global variable
  • Variables global to a project
  • Variables global to a window
  • Variables global to a page
  • Variables global to a report
  • Variables global to a set of procedures
  • How to use a global variable from a component
  • Global variable: Syntax
  • Declaring one or more global variables
  • Local variable
  • Local variable: Syntax
  • Declaring one or more local variables
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
Two types of variables are available:
  • Local variable: can only be used in the process where this variable was declared.
  • Global variable: can be used in all the processes related to the process in which this variable was declared.
Important: You must not declare two variables with the same name (especially a global variable and a local variable).
Versions 21 and later
WINDEVWINDEV MobileUniversal Windows 10 App This feature is available in Universal Windows 10 App mode.
WINDEV MobileApple Watch This feature is available in Apple Watch mode.
New in version 21
WINDEVWINDEV MobileUniversal Windows 10 App This feature is available in Universal Windows 10 App mode.
WINDEV MobileApple Watch This feature is available in Apple Watch mode.
WINDEVWINDEV MobileUniversal Windows 10 App This feature is available in Universal Windows 10 App mode.
WINDEV MobileApple Watch This feature is available in Apple Watch mode.
Global variable

Variables global to a project

The global variables declared in the initialization process of a project can be used in all the processes:
  • of the project.
  • of the window or page (processes of the window or page, processes of its controls and processes of the associated local procedures).
  • of the report (processes of the report, processes of its controls and processes of the associated local procedures).
WEBDEV - Server codeWEBDEV - Browser code Availability of the variables in Browser code:
  • The server variables global to project are available in the browser codes for the following types only: Boolean, Integer, Real, String.
  • Versions 21 and later
    You have the ability to protect the variable global to the project so that it becomes unavailable on the browser side. To do so, use the Server only attribute when declaring the variable.
    The following syntax must be used:
    VariableName is VariableType <server only>

    or:
    VariableName is VariableType, server only

    Example:
    myvariable is int <server only>
    myvariable1 is int, server only
    New in version 21
    You have the ability to protect the variable global to the project so that it becomes unavailable on the browser side. To do so, use the Server only attribute when declaring the variable.
    The following syntax must be used:
    VariableName is VariableType <server only>

    or:
    VariableName is VariableType, server only

    Example:
    myvariable is int <server only>
    myvariable1 is int, server only
    You have the ability to protect the variable global to the project so that it becomes unavailable on the browser side. To do so, use the Server only attribute when declaring the variable.
    The following syntax must be used:
    VariableName is VariableType <server only>

    or:
    VariableName is VariableType, server only

    Example:
    myvariable is int <server only>
    myvariable1 is int, server only
  • Caution: the modifications made to these global variables in browser code are not carried over onto the server.
  • Tip: the global variables declared in a server code can be used to transmit information to the browser.
WINDEVWINDEV Mobile

Variables global to a window

The global variables declared in the declaration process of the global variables of a window can be used in all the processes:
  • of the window.
  • of the window controls.
  • of the local procedures associated with the window.
Limits:
  • The global variables of a window cannot be used by its sibling windows.
  • The global variables declared in a child window cannot be used in its parent window.
  • When the window where the variable was declared is closed, this variable cannot be used anymore.
Note: Using a global variable in a child window of the declaration window
The variables declared global in a window are visible in the child windows of this window in the following cases:
  • If the Extern keyword is used to declare the variable in the child window.
  • If the name of the variable is prefixed by the name of the window.
  • If the variable is passed in parameter to the child window.
WEBDEV - Server codeWEBDEV - Browser code

Variables global to a page

WEBDEV - Server code Server code
The global variables declared in the declaration process of the global variables of a page can be used in all the processes:
  • of the page.
  • of the page controls.
  • of the local procedures associated with the page.
When the page where the variable was declared is closed, this variable cannot be used anymore.
Availability of the variables in Browser code: The server variables global to a page are available in the browser codes of the page for the following types only: Boolean, Integer, Real, String.
Caution: the modifications made to these global variables in browser code are not carried over onto the server.
Tip: the global variables declared in a server code can be used to transmit information to the browser.
WEBDEV - Browser code Browser code
The global variables declared in the "Page load (onLoad)" code can be used in all the browser processes:
  • of the page.
  • of the page controls.
  • of the local procedures associated with the page.
Availability of the variables in Server code: The browser variables global to a page are not available in the server codes of the page.
Tip: the global variables declared in a browser code can be used to exchange information between the different processes run on the browser.
Notes:
  • The global browser variables cannot be initialized on the declaration line.
  • The global Browser variables can be initialized with the value of a global server variable (for the boolean, integer, real and string types only).
  • We recommend that you disable the "cache" of your browser when developing the WEBDEV application. Indeed, the global variables are translated into JavaScript in ".JS" files. If the "cache" is enabled, the tests of your pages may reload files corresponding to former values of variables.
To disable the cache of your browser (Microsoft Internet Explorer):
  1. Find "Internet options" in one of the menus ("Edit", "Display" or "Tools" according to the version of Internet Explorer).
  2. In the "General" tab, click "Parameters" in the "Temporary Internet Files" section.
  3. Check "Whenever the page is visited".
WINDEVWEBDEV - Server codeWINDEV MobileiPhone/iPadWindows Mobile

Variables global to a report

The global variables declared in the "Opening process" of a report can be used in all the processes:
  • of the report.
  • of the report controls.
  • of the local procedures associated with the report.

Variables global to a set of procedures

The global variables declared in the initialization process of a set of procedures can be used in all the processes:
  • of the different procedures found in the set.
  • of the current project.

How to use a global variable from a component

Since the purpose of a component is to be stand-alone, no global variable of the project should be used from this one.
However, the recommended method is as follows:
  • create a global variable in the component
  • in the component, create a procedure used to initialize these global variables.
  • from the initialization code of the project and whenever the value of the global variables of the project is modified, call this procedure to assign a similar value to the global variables of the component.
Global variable: Syntax

Declaring one or more global variables

GLOBAL
<Global variables>
Details of syntax
GLOBALBeginning of declaration of global variables.
<Global variables>Global variables to declare.
Note: PCS_SANS_TRADUCTION_US
GLOBAL // All the declarations that follow are global variables
Subscript is int
CustomerName is string
Rate is real

LOCAL // All the declarations that follow are local variables
I is int
CustomerFName is string
Price is currency
Local variable
The local variables can only be used in the processes where they have been declared. The local variables are unknown outside these processes. These variables cannot be shared among several processes.
By default, a variable is local when it is declared.
WEBDEV - Browser code In browser code, only the following types can be used to declare the local variables:
  • boolean
  • integer
  • real
  • string
  • array of one of the previous types
Local variable: Syntax

Declaring one or more local variables

[LOCAL]
<Local variables>
Details of syntax
LOCALBeginning of declaration of the local variables. The LOCAL keyword is optional.
<Local variables>Local variables to declare.
Note: PCS_SANS_TRADUCTION_US
LOCAL // All the declarations that follow are local variables
I is int
CustomerFName is string
Price is currency
// All the declarations that follow are local variables
I is int
CustomerFName is string
Price is currency
Minimum required version
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment