Schultz’s PowerBuilder Notes

Getting a Reference to a Submenu


Getting a reference to the window’s menu is easily accomplished using the window’s MenuId property.  But what if you want to get a reference to a submenu and all you have is a string with the menu’s name?  This following function will do the trick: Continue reading

Advertisements

August 1, 2009 Posted by | 1. PowerBuilder General, Menus, Powerscript | , , | 1 Comment

Columns


How do I copy a DataWindow value to a variable?

li_seq = dw_1.GetItemNumber(li_row, “SEQ_NO”)

Continue reading

May 25, 2008 Posted by | Datawindow PowerScript | , , , , , , , , , , | Leave a comment

Variables


Arrays

Initializing

String ls_array[]
Ls_array = {“value1”, “value2”,“value3”, “value4”}

Set to null

String ls_arrayofnulls
SetNull(ls_arrayofnulls)
// …
// … some code that loads values into ls_array[]
// ..
ls_array – ls_arrayofnulls

Decimal

decimal {4} a,b,d,e,f
decimal {3} c
a = 20.0/3                  // a contains  6.6667
b = 3 * a                   // b contains 20.0001
c = 3 * a                   // c contains 20.000
d = 3 * (20.0/3)            // d contains 20.0000
e = Truncate(20.0/3, 4)     // e contains  6.6666
f = Truncate(20.0/3, 5)     // f contains  6.6667

Default Values

Variable

Default Value

Blob

A blob of 0 length; an empty blob

Char (or character)

ASCII value 0

Boolean

FALSE

Date

1900-01-01 (January 1, 1900)

DateTime

1900-01-01 00:00:00

Numeric (integer, long, decimal, real, double, UnsignedInteger, and UnsignedLong)

0

String

Empty string (“”)

Time

00:00:00 (midnight)

Variable Declaration, setting to null

To set a variable to null in the declaration statement

integer si_dup_printer_adjust = SetNull(si_dup_printer_adjust)

Integer

integer i
i = 32767
i = i + 1     // i is now –32768

String

A standard data type that is characters enclosed in single (‘) or double (“) quotation marks, including a string of 0 length (the empty string “”). The maximum number of characters in a string is 60,000.

Null

integer a, b=100, c
SetNull(c)
a = b+c    // all
statements set a to NULL
a = b - c
a = b*c
a = b/c

Masks

! Upper Case
^ Lower Case
a Alphabetical
x Any character
# Number

Sample format

5

-5

.5

[General]

5

-5

0.5

0

5

-5

1

0.00

5.00

-5.00

0.05

#,##0

5

-5

1

#,##0.00

5.00

-5.00

0.50

$#,##0;($#,##0)

$5

($5)

$1

$#,##0;-$#,##0

$5

-$5

$1

$#,##0;[RED]($#,##0)

$5

($5)

$1

$#,##0.00;($#,##0.00)

$5.00

($5.00)

$0.50

$#,##0.00;[RED]($#,##0.00)

$5.00

($5.00)

$0.50

0%

500%

-500%

50%

0.00%

500.00%

-500.00%

50.00%

0.00E+00

5.00E+00

-5.00E+00

5.00E-01

April 21, 2008 Posted by | Powerscript | , , , , , , , , | Leave a comment

Working with Dates


Day of the week

DayNumber(date)

Returns an integer (1-7) representing the day of the week of date. Sunday is day 1, Monday is day 2, and so on.

Day of month

Day(date)

Returns the day of the month 1-31.

April 16, 2008 Posted by | 1. PowerBuilder General | , , , , , | Leave a comment

Application Environment


Operating System

Function to check the OS versioning, so far it works with the XP workstation:

// get Windows version information

String ls_version
Environment le_env

GetEnvironment(le_env)

If le_env.OSType = WindowsNT! Then
   If le_env.OSMajorRevision = 5 Then
      ls_version = "Windows "
      CHOOSE CASE le_env.OSMinorRevision
         CASE 0
            ls_version += "2000"
         CASE 1
            ls_version += "XP"
         CASE ELSE
            ls_version += String(le_env.OSMajorRevision) + "."
            ls_version += String(le_env.OSMinorRevision)
      END CHOOSE
   Else
      ls_version = "Windows NT "
      ls_version += String(le_env.OSMajorRevision) + "."
      ls_version += String(le_env.OSMinorRevision)
   End If
Else
   CHOOSE CASE le_env.OSMinorRevision
      CASE 0, 3
         ls_version = "Windows 95"
      CASE 1
         ls_version = "Windows 3.1"
      CASE 10
         ls_version = "Windows 98"
      CASE 90
         ls_version = "Windows ME"
   END CHOOSE
End If

April 16, 2008 Posted by | 1. PowerBuilder General | , , , , , , , , , | Leave a comment