System Examples

Example 1. Opening Bing Maps on Windows Store App/Windows Phone

System.RunProgram("bingmaps:?where=106 Derby Street, Silverwater NSW, Australia","")

Note:

 

Example 2. Opening Apple Maps on iOS

System.RunProgram("http://maps.apple.com/?q=106%20Derby%20Street,%20Silverwater%20NSW,%20Australia","")

Note:

Example 3. Using RunProgram() on Android

System.RunProgram("geo:0,0?q=106 Derby Street, Silverwater NSW, Australia","android.intent.action.VIEW")

Note:

local.vHtmlFile = System.GetProjectPath() & "/" & "testfile.html";

local.vOpenStr = "content://com.android.htmlfileprovider" & local.vHtmlFile & "?text/html";

local.vOpenResult = System.RunProgram(local.vOpenStr, "android.intent.action.VIEW");

Note:

 

Example 4. Using RunProgram() with Windows Desktop/Mobile

System.RunProgram("C:\Program Files\Microsoft Office\Office10\WINWORD.EXE", "")

Form.Close()

Note:

System.RunProgram("C:\Program Files\Microsoft Office\Office10\WINWORD.EXE", "")

Form.Close()

Note:

System.RunProgram("C:\Program Files\Microsoft Office\Office10\WINWORD.EXE", "")

Note:

System.RunProgramAndWait("C:\Program Files\BrightSoftware\BrightForms\BrightForms.exe", ""C:\DemoApps\export\DemoCustomer.bss"")

Note:

Example 5. Login using BrightForms User Settings.

// Check username first.

IF System.IsUserNameCorrect(edtUserName)

{

    // Check password.

    IF System.IsPasswordCorrect(edtPassword)

    {

        // Open Main form if username and password are correct.

        Form.ResetChildData()

        Form.OpenChildForm("Main")

    }

    ELSE

    {

        // Display error message.

        Form.MessageBox("Login", "Incorrect Password.", MB_ICONEXCLAMATION)

    }

}

ELSE

{

    // Display error message.

    Form.MessageBox("Login", "Incorrect Username.", MB_ICONEXCLAMATION)

}

Note:

Example 6. Display device and project properties.

//Display the unique device ID assigned to device running BrightForms

label1 = System.GetDeviceId()

//Display project specific properties

label2 = System.GetProjectAuthor()

label3 = System.GetProjectDescription()

label4 = System.GetProjectId()

label5 = System.GetProjectVersion()    

Note:

Example 7. Set dialup entry to use for connecting to BrightServer.

System.SetDialupEntry("Local Dialup")

Note:

Example 8. Create a delay in the form before performing an action.

//Sleep for a second

System.Sleep(1000)

//Enable a button

button1.enable()

//Other actions

...

Note:

Example 9. Obtaining the OS of the device used.

intOSResult = System.GetOS()

IF OS_PPC == intOSResult

{

    edit_control1 = "OS Result is : " & intOSResult & CHAR_NEWLINE

    edit_control1 = edit_control1 & "This is PPC OS"

}

IF OS_WIN32 == intOSResult

{

    edit_control1 = "OS Result is : " & intOSResult & CHAR_NEWLINE

    edit_control1 = edit_control1 & "This is WIN32 OS"

}

IF OS_WINCE == intOSResult

{

    edit_control1 = "OS Result is : " & intOSResult & CHAR_NEWLINE

    edit_control1 = edit_control1 & "This is WINCE"

IF OS_ANDROID == intOSResult

{

    edit_control1 = "OS Result is : " & intOSResult & CHAR_NEWLINE

    edit_control1 = edit_control1 & "This is ANDROID"

IF OS_WEB == intOSResult

{

    edit_control1 = "OS Result is : " & intOSResult & CHAR_NEWLINE

    edit_control1 = edit_control1 & "This is WEB"

IF OS_IOS == intOSResult

{

    edit_control1 = "OS Result is : " & intOSResult & CHAR_NEWLINE

    edit_control1 = edit_control1 & "This is IOS"

IF OS_WINPHONE == intOSResult

{

    edit_control1 = "OS Result is : " & intOSResult & CHAR_NEWLINE

    edit_control1 = edit_control1 & "This is WINPHONE"

IF OS_WINRT == intOSResult

{

    edit_control1 = "OS Result is : " & intOSResult & CHAR_NEWLINE

    edit_control1 = edit_control1 & "This is WINRT"

Note:

Example 10. Check the web browser used.

IF(System.GetOS() == OS_WEB)

{

    local.vUserAgent = System.GetUserAgent();

    IF(String.IndexOf(local.vUserAgent, "iPad", 0) <> -1 OR

       String.IndexOf(local.vUserAgent, "iPhone", 0) <> -1)

    {

        //If iPhone or iPad

    }

    ELSE

    {

        //Any other web browser

}

}

Note:

Example 11. Send File to user via web browser.

IF(System.GetOS() == OS_WEB)

{

    local.Filename = "C:/BrightServer/data/doc.pdf";

    local.vFileDisplay = "important_document.pdf";

    System.MarkFileForDownload(local.Filename, local.vFileDisplay);

}

Note: