Showing posts with label Script. Show all posts
Showing posts with label Script. Show all posts

Tuesday, March 7, 2017

Powerbuilder with MySQL Database

One of the easiest way to connect to MySQL DB from Powerbuilder is thru ODBC connection. You have to install latest version of MySQL ODBC Driver  from their official site: https://dev.mysql.com/downloads/file/?id=415028 Download the 32 bits version

Tuesday, September 15, 2015

Send SMS with Powerbuilder

Even prestige has begun to decline, in fact, text message (SMS / Short Message System) is still used for 2-way mobile communication. SMS even today is used as a medium for authenticating an application, especially those related to security issues. From social media applications such as Facebook and Twitter, to the e-commerce and even banking applications such as internet banking.

Wednesday, May 20, 2015

Powerbuilder Function to Check Email Address Validity

This function was made based on Visual Basic scripting. The original was created by Chad M. Kovac, and I tried to translate into Powerbuilder language and fix some minor bugs.

Saturday, June 28, 2014

Fingerprint Verification with Powerbuilder

Mr. Yakov Werde, one of the Powerbuilder guru, shown us how to use a free SDK for fingerprint device within Powerbuilder. He using Powerbuilder version 12.5 and free fingerprint SDK from Neuro Technology.

This video shows how to do it in detail

Thursday, April 3, 2014

Powerbuilder Function to Get Last Date in Month

This function is to get last date in particular month

Create a function named f_lastdate

Specify a date type as return value
Specify a date type parameter name dTgl, then type this script below

1:  integer iMonth, iDate  
2:  iMonth = Month(dTgl)  
3:  CHOOSE CASE iMonth  
4:       CASE 1, 3, 5, 7, 8, 10, 12  
5:            iDate = 31  
6:       CASE 4, 6, 9, 11  
7:            iDate = 30       
8:       CASE 2  
9:            IF isDate( '29/' + String(iMonth) + '/' + String(Year(dTgl))) THEN  
10:                 iDate = 29  
11:            ELSE  
12:                 iDate = 28  
13:            END IF  
14:  END CHOOSE       
15:  dTgl = Date( String(iDate) + '/' + String(iMonth) + '/' + String(Year(dTgl)))  
16:  RETURN dTgl  

To use the function, use this script

1:  Date dLastDate  
2:  dLastDate = f_lastdate(today())  

dLastDate value should be: 30 April 2014, if assume today is 3rd April 2014.

Saturday, January 12, 2013

Web CD Player with Powerbuilder & Appeon

Chris Pollach, one of master of Powerbuilder demonstrated the power of Appeon. Build with Powerbuilder 12.1 and compile to be pure web-based version with the Appeon. He made the CD player application.



Read the full article and download the apps for free.


Wednesday, November 14, 2012

Webcam with Powerbuilder

Going back to March 2012, someone call Grace posted the script in Powerbuilder about how to using webcam with Powerbuilder, powered by EZTW32.dll

So, I shared the file to all of you, who need also using webcam within Powerbuilder. I didn't her permission to share this, since I assume her already shared in the group. Anyway, thanks to Grace :)

Here's you can download the file: webcam powerbuilder.

Tuesday, October 23, 2012

Wednesday, September 12, 2012

Binary to Decimal function in Powerbuilder

This script below is the user function in Powerbuilder to convert Binary number into Decimal number.

Create function name: f_bintodec, set Integer as return value, and add sBin as parameter. sBin should be String type, and choose Value as Pass By.

Wednesday, September 5, 2012

Calling Web Service from Powerbuilder

On the last post, I explained how to make web service with Powerbuilder. This time I will explain how to access the web service via PowerBuilder. I am using the Classic version of PowerBuilder 12.5.

The scenario is you have a windows application created with PowerBuilder and you want to access a web service over the internet within the Powerbuilder application.

All you need is certainly a web service that is ready to use. You can get it for free on the internet, or create your own web service. In this example I will create a self service web applications using Visual Studio 2008 and run. NET framework 3.5. In the web service, there is a function that we named of_add2value which serves to add 2 numbers through which we put on the parameters of these functions.

Tuesday, July 3, 2012

Picture Control on Grid Datawindow

Anvil-of-time, one of my colleague, expert on Powerbuilder programming, share to us how to using picture control on Grid Datawindow. One of importing feature on grid datawindow is capability to re-size the column width in user side, like what you have see on Microsoft Excel.

And because of re-size feature, when we put the picture control inside the grid datawindow, when we do the column resizing, the picture will stretched following the size of the column.
(c) Anvil-of-time


Let's take a look of the full article of the tips and trick how to using picture control in grid datawindow, by clicking here

Thursday, February 16, 2012

Powerbuilder Datastore


Basicly, DataStore is a nonvisual DataWindow control.

DataStores act just like DataWindow controls except that many of the visual properties associated with DataWindow controls do not apply to DataStores. However, because you can print DataStores, PowerBuilder provides some events and functions for DataStores that pertain to the visual presentation of the data.

Why and when DataStore is used?
We use the datastore, if we want to work with the data in datawindow, but only at the background. User doesn't need to see the data itself. Yes, indeed, we can use datawindow also to do that, with disable in the visible property. But, it's mean you need to insert the database control on your application, and also means that the control will always in the memory as long as the application is running. With the datastore, you just need to create the control when is needed, and can be destroyed when no longer needed.

Creating Datastore
First of all, you need the datawindow object. Create the datawindow object, and named as "d_mydatawindow".

1:  // declare the variable  
2:  DataStore dsMyDataStore  
3:    
4:  // create the control  
5:  dsMyDataStore = Create DataStore  
6:    
7:  // assign the datawindow object to datastore  
8:  dsMyDataStore.DataObject = "d_mydatawindow"  
9:    
10:  // bind the data  
11:  dsMyDataStore.SetTransObject(SQLCA)  
12:  dsMyDataStore.Retrieve()  
13:    
14:  // script to process the datastore control, same treatment like datawindow control except the visual functions or properties.  
15:  .....  
16:    
17:  // destroy datastore  
18:  DESTROY myDataStore  

Wednesday, February 15, 2012

How to get screen resolution with Powerbuilder


This is the "old" trick, to get the screen resolution.

I'm using Powerbuilder reserved function, call GetEnvironment, which it can be used for another purpose beside screen resolution.

First of all, we must create a ENVIRONMENT variable like below
1:  environment myEnv  

Then we use GetEnvironment function to get the data(s).
1:  GetEnvironment(myEnv)  

Finally, we retrieve all the Environment objects, depending what kind of information do you need. For this case, I want to show how to get the screen resolution:

1:  messagebox("Screen Resolution",String(myEnv.ScreenWidth) + "x" + String(myEnv.ScreenHeight))  

For the complete Environment Object, you can search the Powerbuilder Help, or see the list below.


Environment property Datatype Description
CharSet CharSet (enumerated) The international character set used by PowerBuilder. Values include:
  • CharSetAnsi!
  • CharSetUnicode!
  • CharSetDBCS!
  • CharSetDBCSJapanese!
The values CharSetAnsiArabic! and CharSetAnsiHebrew! are not valid choices in PowerBuilder 6 or later.

ClassDefinition PowerObject An object of type PowerObject containing information about the class definition of the object or control.

CPUType CPUTypes (enumerated) The type of CPU. For a complete list of CPUTypes values, see the Enumerated tab of the Browser.

Language LanguageID
(enumerated)
Specifies the value of the language setting for the machine. For a complete list of LanguageID values, see the Enumerated tab of the Browser.

MachineCode Boolean Specifies whether the application executable is machine code (compiled). Values are:
  • TRUE – Executable is machine code.
  • FALSE – Executable is not machine code (pseudo-code).
OSFixesRevision Integer The maintenance version of the operating system.

OSMajorRevision Integer The major version of the operating system. For example, this value would be 4 for Windows 95, 98, ME, and NT 4.x, 5 for Windows 2000, XP, or 2003, and 6 for Vista, Windows Server 2008, and Windows 7.

OSMinorRevision Integer The point release of the operating system. For example, this value would be 0 for Windows Server 2008 and Vista, 1 for Windows XP or Windows 7, 2 for Windows Server 2003 and 64-bit XP, and 10 for SunOS 5.10 (Solaris 10).

PBBuildNumber Integer The build number of this version of PowerBuilder.

PBFixesRevision Integer The maintenance version of PowerBuilder.

PBMajorRevision Integer The major version of PowerBuilder.

PBMinorRevision Integer The point release of PowerBuilder.

NumberOfColors LongLong Number of colors on the screen.

ScreenHeight Long Height of the screen in pixels.

ScreenWidth Long Width of the screen in pixels.

OSType OSTypes (enumerated) Operating system or environment. For a complete list of OSType values, see the Enumerated tab of the Browser.

PBType PBTypes (enumerated) Version of the PowerBuilder product. For a complete list of PBType values, see the Enumerated tab of the Browser.

Win16 (obsolete) Boolean Indicates the type of the operating system in which the application executable is running. Values are:
  • TRUE – Executable is running under a 16-bit operating system.
  • FALSE – Executable is running under a 32-bit operating system.

Wednesday, January 4, 2012

WMI Win32_PhysicalMedia table structure

For all of you who need the Win32_PhysicalMedia table structure, here is the list.

Win32_PhysicalMedia is a build in class in Windows, which store all the information about Drive (Hard drive, Removable Drive, etc). It is a part of WMI.

With this class you can retrieve all the information about your drive, like Serial Number.

Wednesday, November 30, 2011

Web Service with Powerbuilder

Since Powerbuilder 10, Sybase introduced the web service feature.

According to Wikipedia, A Web service is a method of communication between two electronic devices over the web. In other word, is a brigde technology for communicating 2 different devices over the web.

Simple explaination, imagine that you want to build a web project, and want to put status ticker to show the exchange rate from your bank. As long as your bank has a web service system to provide their customer to check the exchange rate, you can use it without making an own coding. You just need ask the bank for documentation how to use the exchange rate function.

In this article, I want to show you how to build web service within Powerbuilder and call it from Visual Studio in ASP.NET Visual basic language.

Global explaination is:
  1. Build 1 function in Powerbuilder as a web service to add 2 values or numbers and display the result.
  2. Put the web service in a server, let say the name is: abc.com
  3. Build 1 web project in Visual Studio, and put at xyz.com as a web server
  4. Call the function from abc.com from xyz.com
In this sample, I'm using Sybase Powerbuilder 12.5 Classic Evaluation version, and Microsoft Visual Studio 2008.

Chapter 1 - Building a web service in Powerbuilder
  1. Create a new Workspace and name it as you like (Pict 1)
  2. Create a new Target, choose .NET Web Service, and give a name as n_webservice (Pict 2a and 2b)
  3. Create a new FUNCTION in n_web service object, called of_add2number. Return type is Decimal. Add 2 value arguments in Decimal type, and named it as ARG1 and ARG2
  4. In a script canvas, type RETURN ARG1 + ARG2 (Pict 3)
  5. Create a new new Project and give p_webservice as a name (Pict 4)
  6. In Object tab, make sure you check the of_add2number function in Message Name list. (Pict 5)
  7. Deploy the project, by clicking menu Run then Deploy web service
  8. Make sure that you didn't get an error when you deploy the web service
  9. Let say you uploading the web service into your web server at http://ww.abc.com/webservice directory
Pict 1

Pict 2a
Pict 2b
Pict 3
Pict 4
Pict 5


Chapter 2 - Calling the web service from Visual Studio
  1. Create a new web project and give WSPB as the name, IN OTHER COMPUTER / PC
  2. In Solution Explorer window, right click the WSPB project, and choose Add Web Service
  3. In URL field, fill in with http://www.abc.com/webservice/n_webservice.asmx?WSDL then click Go
  4. It should be like an picture 10, rename the Web reference name as wsPBObj then click Add Reference button. Now we have a web service object with wsPBObj as a name. (Pict 6)
  5. In Default.aspx, add:
  • 2 textboxes and named it as tbNum1 and tbNum2
  • 1 label as lblResult
  • 1 button.
     6. In code behind at Button1 Click event, type the following code.

1:  Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click  
2:       Dim wsFromPB As New wsPBobj.n_webservice  
3:    
4:       Dim dResult As Decimal  
5:       Dim dNum1 As Decimal  
6:       Dim dNum2 As Decimal  
7:    
8:       dNum1 = System.Convert.ToDecimal(tbNum1.Text)  
9:       dNum2 = System.Convert.ToDecimal(tbNum2.Text)  
10:    
11:       dResult = wsPBFromPB.of_add2number(dNum1, dNum2)  
12:    
13:       lblResult.Text = dResult.ToString  
14:  End Sub  

     7. Click Ctrl + F5 to run the form and try to put 10 in Number #1 and 65 in Number #2, click EQUAL (Pict 7).
Pict 6
Pict 7

Wednesday, October 5, 2011

Play MP3 with Powerbuilder


This is the tips how to play single MP3 file with Powerbuilder script

First, declare external function called mciSendStringW. This function originally is from winmm.dll file. When I tried this function, I'm using Windows XP with SP2.

1:  Public Function long mciSendStringW (string lpstrCommand, ref string lpstrReturnString, long uReturnLength, long hwndCallback) Library "winmm.dll"  

then use following script to run mp3 file,

1:  string ls_string  
2:  ls_string=space(500)  
3:    
4:  mcisendstringW("Play "+<your mp3 file including the path>,ls_string,len(ls_string),0)  

to stop the playback,

1:  mcisendstringW("Stop "+<your mp3 file including the path>,ls_string,len(ls_string),0)  

Tuesday, September 27, 2011

How to read Windows Active Directory with Powerbuilder


Here is the tips and trick how to read Windows Active Directory in Powerbuilder script, made by William Franklin (wfranklin@plg.cc) with Powerbuilder version 8, but I'm sure it will run smoothly in other newest version.

First of all we cannot retrieve the password from LDAP, only we can validate the password against it. Here is the code, do the following steps and I tested it in my network it is working fine.

Wednesday, September 14, 2011

INI file with Powerbuilder

In the world of Windows, INI files is one of the most widely file encountered. INI is an acronym for Initialization. Usually processed when an application has just started. INI file typically contains configuration data of an application.

INI file is essentially a plain text file that has a standard structure. For more details, please see http://en.wikipedia.org/wiki/Ini_file

Monday, September 12, 2011

How to check mandatory column in Powerbuilder

Often, we need to check whatever the user(s) fill or not the mandatory columns.

One of my team mates made the function check all the mandatory columns in one datawindow.

His idea is to utilize the TAG property in every columns. Just fill the TAG property value with Column's full name, if you think that column is mandatory.

Monday, June 27, 2011

Creating MDI Window with Background in Powerbuilder

MDI Window is a type of window that have capabilities to have a menu inside, microhelp bar, Child window inside, etc. Unfortunally, it can't be have an image background capability, at least in Powerbuilder programming. MDI is standing for Multiple Document Interface.