Integrated software for developing cross-platform applications    Integrated software for developing cross-platform applications
The WINDEV, WEBDEV and WINDEV Mobile environments are compatible and share project elements. It has never been easier to build multi-target applications.
WLanguage functions (3480)

Both static typing and dynamic typing are proposed in WLanguage.
It includes a flexible system for type management that allows for fast development by using the dynamic typing while taking advantage of static typing.
Its virtual machine includes a system for automatic memory management.
Advanced types of data are available as well as high-precision numerics (38 significant digits).
It supports several programming paradigms: object-oriented, procedural and imperative programming.


This page presents WLanguage code samples.

This is what L5G code looks like!
(and don't forget that there is nothing to code for several functions, all you have to do is click the choices proposed by the IDE ; these examples present the language only).

Example 1: Scanning a document

// Saves the document found in the scanner in the "MyPhoto.JPEG" file
// The document will be saved in black and white
IF TwainToBMP("C:\Temp\MyPhoto.BMP", False, TwainBlackWhite) = True THEN
Info("The document was saved")
Error("The document was not scanned")

Example 2: Reading a registry key

// Reads the "Language" value in the "HKEY_LOCAL_MACHINE\SOFTWARE\App" key
// ResExecute is a boolean used to find out whether the value was read
ResRead = RegistryQueryValue("HKEY_LOCAL_MACHINE\SOFTWARE\App", "Language", ResExecute)

IF ResExecute = True THEN
Info("The value was read and it is set to: " + ResRead)

Example 3: Selecting a color

Value is int 
SelectionResult is boolean

Value =  RGB(10, 17, 69)
Info("Initial color: " + Value)
SelectionResult = SelectColor(Value, scInit)
Info("Final color: " + Value)

Example 4: Calculating the number of days between 2 dates

// Displays the number of days passed since 01/01/1998
Info(NumToString(DateDifference("19980101", DateSys())) + "days spent")

Example 5: Extracting part of a file path

sFilePath is string
sResFileName is string

sFilePath = "C:\MyDirectories\File.psw"

// Retrieve the name of the file
sResFileName = fExtractPath(sFilePath, fFileName)
// sResFileName corresponds to "File"

Example 6: Transforms a number into a character string corresponding to the number "written in words"

// Displays "eighty three point thirty four"

Info(NumberInWords(1.10, "Euro(s)"))
// Displays "one Euro ten"

Info(NumberInWords(1.01, "Euro(s)", "cent(s)"))
// Displays "one Euro and one cent"

Example 7: Sending an email

IF EmailStartSession(USER, PASSWORD, "", ...
"") = True THEN
UserName = USER
  UserName = ""
  Error("Unable to establish the connection")

// Initializes the email components
// The sender
Email.Sender = "<>"
// The recipient
Email.Recipient[1] = RECIPIENT
// The number of recipients
Email.NbRecipient = 1
// The subject
Email.Subject = SUBJECT
// The message body
Email.Message = TEXT
// The number of attachments
Email.NbAttach = 0

// Sends the email
IF EmailSendMessage(UserName) = False THEN

Example 8: Adding an icon in the systray

// Add the "C:\Icons\Icon.ICO" icon into the taskbar
ResAddIcon = SysIconAdd("C:\Icons\Icon.ICO", "", "Sales 2013")

Example 9: Saving a screen shot

// Saves in memory the image found in "IMG_ImageDrawing"
ResSave = dSaveImageJPEG(IMG_ImageDrawing, inMemory)

Example 10: Example for declaring variables

// Declaration of variables

is int
SelectionResult is boolean
Price is real
i,j,k are int

Example 11: Code/Interface interaction

// Runs the click code on a button
ExecuteProcess(BTN_Save, trtClick)

Example 12: Managing threads by programming

// Run a thread while passing parameters
sDate is string 
sDate = DateSys()
// Run the thread
ThreadExecute("THREADNAME", threadNormal, "pExecQry", sDate)

// Details of the "pExecQry" procedure 
// This procedure expects a date in parameter of a query
PROCEDURE pExecQry(sDate)
IF HExecuteQuery(Del_Date, hQueryDefault, sDate) = False THEN

Example 13: Print preview

// No button in the preview

Example 14: Printing in HTML

// Print a report based on a query without parameter in an HTML file
// Generate a unique file name
MyReportFile is string = fWebDir() + "\" + "ReportQuery_" + DateSys() + TimeSys() + ".htm"
// Configure the destination of the print
iDestination(iHTML, MyReportFile)
// Print the RPT_QueryReport report
// Extract the name and extension of the generated file
NameGeneratedFile is string = fExtractPath(MyReportFile, fFileName + fExtension)
// Send the file to the browser

Example 15: Generating a PDF file

// Generate a unique PDF file name
AFile is string  
AFile = fWebDir() + "\" + DateSys() + TimeSys() + ".pdf" 
// Configure the destination of the print 
iDestination(iPDF, AFile) 
// Print the RPT_InvoicePDF report
// Send the file to the browser 
FileDisplay(AFile, "application/pdf") 
// Delete the file 

Example 16: Protecting a PDF file

// In this example, the password is "password"
iParameterPDF("opening", "password", iProtectionPrinting + iProtectionSelection)

// Create the PDF file
iPreview(iPDF, "MyPDF.PDF")

// Code for print
iCreateFont(1, 16, iBold, iRoman)
iPrintWord("First line of my PDF" + CR + "Second line of my PDF" + ...
CR + "Last line of my PDF")

// End of print and close the created PDF file

// Display the PDF

Example 17: Selecting a PCL printer (mobile)

// PCL printer to use
iDestination(iPCL, "\\MyNetwork\MyPrinter")

Example 18: Print in PCL format (mobile)

iDestination(iPCL, "\MyDocuments\MyFile.PCL")

Example 19: Dialing a phone number

IF tapiDial(EDT_PhoneNumber, "LineStatus")=True THEN 
Info("Click OK to hang up") 

PROCEDURE TestLineStatus(ValueLineStatus is int) 
SWITCH ValueLineStatus 
CASE tapiLineBusy: Message("The line is busy") 
CASE tapiLineConnected: Message("OK, connected")
CASE tapiLineDialing: Message("Dialing in progress") 
CASE tapiLineDialTone: Message("Dial tone")
CASE tapiLineDisconnected: Message("The correspondent has hung up")
CASE tapiLineProceeding: Message("Searching for your correspondent")
CASE tapiLineRingBack: Message("Ringing")

Example 20: Financial calculations

// Interest rate for a loan of 25000 Euros. Six payments
// of 5000 Euros are required to pay off the loan.
ResInterestRate = FinInterestRate(6, -5000, 25000)

Example 21: Reading a text file line by line

// Exit according to an IF condition
        // Read a line in the text file
        ALine = fReadLine(FileNum)
        IF ALine = EOT THEN BREAK

Example 22: Exit according to a WHILE condition

MyList = INIRead("Examples", "", "", INIFile)
Keyword = ExtractString(MyList, nb, CR)
WHILE Keyword <> ""
        nb = nb + 1
        ExplName = INIRead("Projects installed", Keyword, "", INIFile)
        Keyword = ExtractString(MyList, nb + 1, CR)

Example 23: Exit according to an iteration

// Exit according to an iteration
LOOP (10)
        // Read a line in the text file
        ALine = fReadLine(FileNum)

Example 24: Export to Excel

sFile is string
// Asks for the name of the file
sFile = fSelect("", "", "Choose the export file", ...
"Excel files (*.xls) *.xls", "xls", fselCreate + fselExist)
// If the name was not specified, cancels the export
// Otherwise, exports the content of TABLE_TABLE1
IF sFile <> "" THEN TableToWord(TABLE_TABLE1, sFile, taNoTitle)

Example 25: Export to XML

sFile is string
// Name of the file
sFile = fSelect("", "", "Choose the export file", ...
"XML files (*.XML) *.xml", "xml", fselCreate + fselExist)
// The export is canceled if no name was specified
// Otherwise, export the content of TABLE_TABLE1
IF sFile <> "" THEN TableToXML(TABLE_TABLE1, sFile, taNoTitle)

Example 26: Extracting part of a file path

sFile is string
// Asks for the name of the file
sFile = fSelect("", "", "Choose the export file", ...
"Word files (*.rtf) *.rtf", "rtf", fselCreate + fselExist)
// If the name was not specified, cancels the export
// Otherwise, exports the content of TABLE_TABLE1
IF sFile <> "" THEN TableToWord(TABLE_TABLE1, sFile, taNoTitle)

Example 27: Sending an SMS

// Initialize the SMS structure for a standard number 
SMS.Number = "0610203040" 
SMS.Message = "I am sending SMSs with WINDEV Mobile!" 

// Send the SMS 
ResSend is boolean = SMSSend() 

// Error occurred? 
IF ResSend = False THEN 

Example 28: Sending a fax

ConnectID is int
ConnectID = FaxConnect()
IF ConnectID = 0 THEN 
Error("The connection to the fax server failed." + ...
 "Check whether it has been started", ...
 ListAdd(LIST_FaxSend, FaxOutbox(ConnectID))
// Click code of the list box
IF FaxStatus(LIST_FaxSend..DisplayedValue) = FaxStatusHandled THEN


Example 29: Acquisition on the serial port
(this code is generated by a wizard, you don't even have to type it!)

Result1 = sOpen(1, 2000, 2000) // Open COM1
IF Result1 = True THEN
// Configure Com1: Rate 9600, even parity, 
// 8 data bits, 1 stop bit
sParameter(1, 9600, 1, 8, 0) // Configure COM1 
// Rest of process...
sClose(1) // Close COM1
Error("Error while opening COM1")