Coding Restrictions

Several PowerScript coding practices are not permitted in the .NET environment.

Dashes in identifiers

In the .NET platform, you cannot use dashes in identifiers. If you include a dash or hyphen in the name of an object that you create in the IDE, you see an error message when you try to save the object. The migration wizard in PowerBuilder .NET includes a check box on the Convert Dashes in Identifiers page that you can select to convert dashes in identifiers to default "dash" strings in applications that you migrate from PowerBuilder Classic. The conversion is automatic unless you clear the check box before completing the wizard, or change the DashesInIdentifiers setting in the PB.INI file to 0. The wizard also allows you to convert dashes to a string of your own choosing.

Microsecond separators

The .NET platform requires you to use decimal points as microsecond separators in time functions, rather than colons. Although you can continue to use colons as microsecond separators in PowerScript, the PowerBuilder to .NET compiler converts colon separators to decimal points prior to deployment of .NET applications and components.

PowerScript GoTo statement

In PowerBuilder Classic, you can jump directly to a branch of a compound statement because the concept of scope inside a function does not exist in PowerScript. For example, this code works well in PowerBuilder Classic:
    if b = 0 then
      label: ...
    else
       ...
    end if
    goto label
This PowerScript translates conceptually into this C# code:
    if (b == 0)
       {    // opening a new scope
       label: ...
       }
    else
       {
        ...
       }
    goto label; 
Since a GoTo statement is not allowed to jump to a label within a different scope in .NET, the C# code would not compile. For this reason, avoid using GoTo statements in PowerBuilder .NET.

Casting objects without inheritance relationship

The PowerBuilder compiler allows you to cast an object to classes that are not ancestors of the object you are casting, such as sibling object classes. However, this is not considered good coding practice, and is not allowed for .NET targets.