- Function not available
- A function is not available in Linux: how to adapt the existing code?
- Control not available
- Using the available controls
- I must modify the GUI of a window. How can I be sure to use controls that are available for all my configurations?
- Paths of files
- Tree structure
- Case and accented characters
Linux application: Tips and tricks
Available only with this kind of connection
In Windows/Linux multi-configuration applications, several limitations may appear: control not supported, functions not available, ...
The possible solutions are presented in this help page.
A function is not available in Linux: how to adapt the existing code?
Some functions or properties may not be available in Linux configuration:
- because they have no reason to exist (the RegistryXXX functions for example).
- because the associated controls are not available (TreeXXX functions).
- because they are not yet available in this version.
The conditional target-code is used to define, for a given process (click code of a button for example), the code that will be run according to the current platform.
To create a conditional target-code:
- In the code editor, select "Code .. Conditional target-code .. New area".In the code editor, on the "Code" pane, in the "Target code" group, expand "Target code" and select "New area".
- In the window that is displayed, click the "Advanced" button.
- Define the different areas and the platforms for each area. In our case, if the unavailable functions can be replaced by another process, two areas must be created:
- a "Windows" area that contains the "Windows 32-bit applications" and "Windows 64-bit applications" platforms.
- a "Linux" area that contains the "Linux 32-bit code" and "Linux 64-bit code" platforms.
Tip: If the initial code cannot be replaced and it it must be run for a given platform, use a conditional target-code by defining the available platforms only. You have the ability to use a block such as "IF InLInuxMode() = False THEN" that will have the same operating mode at run time ; however, in this case, an error will always be displayed in the editor.
- When the target-code area is created, the code editor is divided into 2 sections (or more). Then, all you have to do is enter the code of each area, as usual.
The areas of conditional target-code can be surrounded by areas of "common" code (and conversely).
Some controls are not yet available in the Linux framework: the treeviews, the treeview tables, the bar codes and the shapes for example.
At run time in Linux, if a single control is not supported in the window, no control will be displayed and a WLanguage error will occur.
In this case, several possibilities exist.
The control can be deleted
It is a "minor" control (the shape control for example, used to identify areas in the GUI). You can choose to depending on the case:
- delete it,
- replace it by an image or by an "empty" static with a border.
The control can be moved
It is an important control that cannot be deleted but that can be moved into another window (a Bar Code control for example). In this case, you must:
- create a new window intended to the display of the control.
- move the control into this new window.
- add into the source window a button used to open the created window. This button must not be accessible in Linux.
The control cannot be deleted or moved
It is an important control that cannot be deleted or moved (a TreeView control or a TreeView Table table for example). In this case, the only solution consists in duplicating the window in order for each configuration to have its OWN window.
To duplicate a window:
- Select "File .. Save as" in the window editor. In the window editor, on the "Home" pane, in the "General" group, expand "Save" and select "Save as".
- Give a new name to the window. A suffix can be added to the name according to the platform ("WIN_ CustomerForm_Linux" for example).
- Use a conditional target-code to call the window adapted to the runtime platform.
Caution: This solution must be used with great care and for the windows containing little code and GUI. Indeed, once the window is duplicated, all the modifications, corrections, ... must be performed twice, with the risk of forgetting some of them.
Using the available controls
I must modify the GUI of a window. How can I be sure to use controls that are available for all my configurations?
WINDEV, WEBDEV and WINDEV Mobile clearly indicate the controls and the control parameters that are not available in one or more project configurations.
- The different types of controls
The options and the buttons found in the toolbar that are used to create the controls are grayed if the current configuration does not support this type of control.
If you are using a control that is not available in one of the project configurations, an error is displayed in the error pane.
- The options of controls
Some control parameters may not be available according to the runtime platform.
These parameters can be modified in the description window of the control but they will be signaled:
- in gray if the parameter is not available for any of the project configurations.
- in purple if the parameter is available for some configurations and not available for other configurations.
Differences can be noticed in the file management between Windows and Linux:
- regarding the tree structure of the files.
- regarding the case and the accented characters.
The separator used in the tree structure of the paths differs according to the platform:
- "\" in Windows,
- "/" in Linux.
Two WLanguage functions can be used to manage this problem:
- fSep returns the separator corresponding to the platform currently run. This function is used to build a path regardless of the current platform.
Note: CompleteDir is used to add the proper separator to a tree structure. However, the code becomes less readable after 2 inclusions.
// Builds the path of the configuration file
sConfigFile = fExeDir() + fSep() + "config.ini"
- fSeparator is used to retrieve a path with normalized separators. This function is very useful if the application is using paths stored/built on a different platform.
sConfigFile = ".\Temp\MyFile.txt"
// Normalizes the path
sConfigFile = fSeparator(sConfigFile)
// In Windows: ".\Temp\MyFile.txt"
// In Linux : "./Temp/MyFile.txt"
Case and accented characters
Unlike Windows, Linux is case sensitive.
For example, the following command line:
// Opens the "MyFile.Txt" file
will not open the "myfile.txt" file in Linux while it will be properly opened in Windows.
Therefore, don't forget to check the case of the files on disk and the case used in the WLanguage code.
Click [Add] to post a comment