Skip to main content
insightsoftware Documentation insightsoftware Documentation
{%article.title%}
Published:
Was this article helpful?
0 out of 0 found this helpful

Sample Longview Form and supporting procedures

The following code blocks show the Longview Form (.lvfrm) document and supporting procedure used to create the sample form displayed at the beginning of this chapter, plus sample OnChange and OnClick procedures.

Note: These code blocks are intended as examples only and are not exhaustive. The examples listed here do not include every line of code required to create a Longview App and a complex Longview Form.

Sample Longview Form document

Copy
Sample Longview Form document
//Define the properties of the form - specify window title, form width, and buttons
Window "Title:New Employee", Width:500
Button "Add", "Text:Add Employee", Validate:TRUE, "OnClick:button.lvpro"
Button "Cancel", "Text:Cancel"
 
//Define formats - specify the way date values are returned to AF (display = user’s regional settings)
DateFormat "DD-MM-YYYY"
//Display information - add main heading
Heading "Add an employee", Style:Title
 
//Add interactive controls - request employee's first and last name
TextBox "Employee’s First Name", sFirstName, "OnChange:SetName.lvpro", MaxLength:200, Required:TRUE
TextBox "Employee’s Last Name", sLastName, "OnChange:SetName.lvpro", MaxLength:200, Required:TRUE
 
//Add static control - display max allowed vacation days
Number "Maximum vacation days allowed", 25
 
//Add interactive controls - request start date and dynamically display vacation days retro to start date
DatePicker "Start date", sStart, "OnChange:SetStartDate.lvpro", Min:2000-01-01, Max:2016-01-01
NumberBox "Number of vacation days", nVacation
 
//Add static control - pad with space
Separator BLANK
 
//Display information - add section 2 heading
Heading "Section 2: Employee Information", Style:Subtitle
 
//Add prompt controls - request employee's resume and currency
FileChooser "Upload resume", sResume, "DefaultPath:C:\Users", "FileRestrictions:pdf file|*.pdf|text file|*.txt", "BrowseType:SAVE", "OnChange:SetResume.lvpro", Required:TRUE
SymbolSelector "Select the employee’s currency", sCurrency, CURRENCIES, Symbols:Source_Currencies#99, AllowLeaf:TRUE, AllowParent:TRUE, AllowReadOnly:TRUE, AllowMultiple:TRUE, "OnChange:SetSymbols.lvpro", Required:TRUE
 
//Display information and add interactive controls - use heading to provide text instructions for check box controls
Heading "Select any of the following if applicable to the new employee:", Style:Normal
Checkbox "Add to company email list", sEmailList, "OnChange:SetEmaiList.lvpro"
Checkbox "Referred by internal employee", sReferred
 
//Add static control and add interactive controls - divide sections and request employee's role, salary range, and employee type
Separator LINE, "Text:Role Information"
ComboBox "Role", sRole, "QA|DOC|SD|LC", "Text:QA Analyst|Technical Writer|Software Developer|Learning Consultant", "OnChange:SetManager.lvpro"
ComboBox "Salary range", sSalary, "1|2|3|4", "Text:35,000 - 49,999|50,000 - 59,999|60,000 - 79,999|80,000 - 100,000", "OnChange:SetSalary.lvpro"
RadioGroup "Type of employee", sEmpType, "FT|PT", "Text:Full-time Employee|Part-time Employee", "OnChange:SetEmpType.lvpro"
 
//Add static control - show employee's manager after the employee’s role is selected
Text "Employee’s manager", sEmpManager

Sample supporting procedure

Copy
Sample supporting procedure
//Create required variables
create Variable nVacation as NUM
set Variable nVacation = 10
create Variable nRetrodays as NUM
create Variable sFirstName as STRING
create Variable sLastName as STRING
create Variable sDescription as STRING
create Variable sStart as STRING
create Variable sEmpManager as STRING
create Variable sEmailList as STRING
create Variable sReferred as STRING
create Variable sRole as STRING
create Variable sSalary as STRING
create Variable sEmpType as STRING
create Variable sResume as STRING
create Variable sCurrency as STRING
 
//Open the form
Show FORM using "SampleFormDocument.lvfrm"                 

 

Sample OnChange validation procedure

You could create an OnChange procedure such as the following to validate, for example, that a user has entered an email address in the correct format.

Copy

Sample OnChange validation procedure

If StrContains ("$sEmail$", "@")
Set Variable LVG_FormValid = 1
Else
Set Variable LVG_FormValid = 0
Set Variable LVG_FormMessage = "Your email address must include the @ sign."
End if

Sample OnChange dynamic procedure

Consider the following syntax examples for the ComboBox and Text functions:

Copy
ComboBox "Role", sRole, "QA|DOC|SD|LC", "Text:QA Analyst|Technical Writer|Software
Developer|Learning Consultant", "OnChange:SetManager.lvpro"
Text "Employee’s manager", sEmpManager

You could write the SetManager procedure such as the following so that the sEmpManager variable used in the Text function updates dynamically. After the forms user selects the new employee’s role in the combo box control, the employee’s manager displays in the text area.

Copy

Sample OnChange dynamic procedure

if $sRole$ EQ "QA"
set variable sEmpManager = "Jane Smith, QA Manager"
End If
if $sRole$ EQ "DOC"
set variable sEmpManager = "Liz Clark, Documentation Manager"
End If
if $sRole$ EQ "SD"
set variable sEmpManager = "Mary Scratch, Software Development Manager"
End If
if $sRole$ EQ "LC"
set variable sEmpManager = "Jim Coles, Director of Learning"
End If

 

 

Sample OnClick procedure

Copy

Sample OnClick procedure

MAINTENANCE ON
SET VARIABLE sDescription = $sFirstName$ + $sLastName$
CREATE SYMBOL EMPLOYEES $sFirstName$ $sDescription$ Standard Manual Neither PARENT
AllEmployees "0"
MAINTENANCE OFF

Published:

Sample Longview Form and supporting procedures

The following code blocks show the Longview Form (.lvfrm) document and supporting procedure used to create the sample form displayed at the beginning of this chapter, plus sample OnChange and OnClick procedures.

Note: These code blocks are intended as examples only and are not exhaustive. The examples listed here do not include every line of code required to create a Longview App and a complex Longview Form.

Sample Longview Form document

Copy
Sample Longview Form document
//Define the properties of the form - specify window title, form width, and buttons
Window "Title:New Employee", Width:500
Button "Add", "Text:Add Employee", Validate:TRUE, "OnClick:button.lvpro"
Button "Cancel", "Text:Cancel"
 
//Define formats - specify the way date values are returned to AF (display = user’s regional settings)
DateFormat "DD-MM-YYYY"
//Display information - add main heading
Heading "Add an employee", Style:Title
 
//Add interactive controls - request employee's first and last name
TextBox "Employee’s First Name", sFirstName, "OnChange:SetName.lvpro", MaxLength:200, Required:TRUE
TextBox "Employee’s Last Name", sLastName, "OnChange:SetName.lvpro", MaxLength:200, Required:TRUE
 
//Add static control - display max allowed vacation days
Number "Maximum vacation days allowed", 25
 
//Add interactive controls - request start date and dynamically display vacation days retro to start date
DatePicker "Start date", sStart, "OnChange:SetStartDate.lvpro", Min:2000-01-01, Max:2016-01-01
NumberBox "Number of vacation days", nVacation
 
//Add static control - pad with space
Separator BLANK
 
//Display information - add section 2 heading
Heading "Section 2: Employee Information", Style:Subtitle
 
//Add prompt controls - request employee's resume and currency
FileChooser "Upload resume", sResume, "DefaultPath:C:\Users", "FileRestrictions:pdf file|*.pdf|text file|*.txt", "BrowseType:SAVE", "OnChange:SetResume.lvpro", Required:TRUE
SymbolSelector "Select the employee’s currency", sCurrency, CURRENCIES, Symbols:Source_Currencies#99, AllowLeaf:TRUE, AllowParent:TRUE, AllowReadOnly:TRUE, AllowMultiple:TRUE, "OnChange:SetSymbols.lvpro", Required:TRUE
 
//Display information and add interactive controls - use heading to provide text instructions for check box controls
Heading "Select any of the following if applicable to the new employee:", Style:Normal
Checkbox "Add to company email list", sEmailList, "OnChange:SetEmaiList.lvpro"
Checkbox "Referred by internal employee", sReferred
 
//Add static control and add interactive controls - divide sections and request employee's role, salary range, and employee type
Separator LINE, "Text:Role Information"
ComboBox "Role", sRole, "QA|DOC|SD|LC", "Text:QA Analyst|Technical Writer|Software Developer|Learning Consultant", "OnChange:SetManager.lvpro"
ComboBox "Salary range", sSalary, "1|2|3|4", "Text:35,000 - 49,999|50,000 - 59,999|60,000 - 79,999|80,000 - 100,000", "OnChange:SetSalary.lvpro"
RadioGroup "Type of employee", sEmpType, "FT|PT", "Text:Full-time Employee|Part-time Employee", "OnChange:SetEmpType.lvpro"
 
//Add static control - show employee's manager after the employee’s role is selected
Text "Employee’s manager", sEmpManager

Sample supporting procedure

Copy
Sample supporting procedure
//Create required variables
create Variable nVacation as NUM
set Variable nVacation = 10
create Variable nRetrodays as NUM
create Variable sFirstName as STRING
create Variable sLastName as STRING
create Variable sDescription as STRING
create Variable sStart as STRING
create Variable sEmpManager as STRING
create Variable sEmailList as STRING
create Variable sReferred as STRING
create Variable sRole as STRING
create Variable sSalary as STRING
create Variable sEmpType as STRING
create Variable sResume as STRING
create Variable sCurrency as STRING
 
//Open the form
Show FORM using "SampleFormDocument.lvfrm"                 

 

Sample OnChange validation procedure

You could create an OnChange procedure such as the following to validate, for example, that a user has entered an email address in the correct format.

Copy

Sample OnChange validation procedure

If StrContains ("$sEmail$", "@")
Set Variable LVG_FormValid = 1
Else
Set Variable LVG_FormValid = 0
Set Variable LVG_FormMessage = "Your email address must include the @ sign."
End if

Sample OnChange dynamic procedure

Consider the following syntax examples for the ComboBox and Text functions:

Copy
ComboBox "Role", sRole, "QA|DOC|SD|LC", "Text:QA Analyst|Technical Writer|Software
Developer|Learning Consultant", "OnChange:SetManager.lvpro"
Text "Employee’s manager", sEmpManager

You could write the SetManager procedure such as the following so that the sEmpManager variable used in the Text function updates dynamically. After the forms user selects the new employee’s role in the combo box control, the employee’s manager displays in the text area.

Copy

Sample OnChange dynamic procedure

if $sRole$ EQ "QA"
set variable sEmpManager = "Jane Smith, QA Manager"
End If
if $sRole$ EQ "DOC"
set variable sEmpManager = "Liz Clark, Documentation Manager"
End If
if $sRole$ EQ "SD"
set variable sEmpManager = "Mary Scratch, Software Development Manager"
End If
if $sRole$ EQ "LC"
set variable sEmpManager = "Jim Coles, Director of Learning"
End If

 

 

Sample OnClick procedure

Copy

Sample OnClick procedure

MAINTENANCE ON
SET VARIABLE sDescription = $sFirstName$ + $sLastName$
CREATE SYMBOL EMPLOYEES $sFirstName$ $sDescription$ Standard Manual Neither PARENT
AllEmployees "0"
MAINTENANCE OFF

For an optimal Community experience, Please view on Desktop