<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1441221853004571308</id><updated>2012-02-16T16:48:42.776-08:00</updated><category term='Win32 API'/><category term='DataWindow'/><category term='Database'/><category term='PowerScript'/><title type='text'>PowerBuilder Tips &amp; Tricks</title><subtitle type='html'>Advanced PowerBuilder Tips &amp;amp; Tricks Programming, that I copied from books, website, blog, literature, and other resources.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://power-builder.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>34</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-8450324066307067771</id><published>2008-03-16T14:59:00.000-07:00</published><updated>2008-09-04T15:01:44.131-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PowerScript'/><title type='text'>Retrieve an environment variable</title><content type='html'>Retrieve an environment variable&lt;br /&gt;&lt;pre&gt;&lt;code&gt;ContextKeyword lcxk_base&lt;br /&gt;string ls_Path&lt;br /&gt;string ls_values[]&lt;br /&gt;&lt;br /&gt;this.GetContextService("Keyword", lcxk_base)&lt;br /&gt;lcxk_base.GetContextKeywords("path", ls_values)&lt;br /&gt;IF Upperbound(ls_values) &gt; 0 THEN&lt;br /&gt;   ls_Path = ls_values[1]&lt;br /&gt;ELSE&lt;br /&gt;   ls_Path = "*UNDEFINED*"&lt;br /&gt;END IF&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Common XP environment variables:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;ALLUSERSPROFILE      location of the All Users Profile.&lt;br /&gt;APPDATA              location where applications store data by default.&lt;br /&gt;CD                   current directory string.&lt;br /&gt;CLIENTNAME           client's NETBIOS name when connected to terminal server session.&lt;br /&gt;CMDCMDLINE           command line used to start the current cmd.exe.&lt;br /&gt;CMDEXTVERSION        version number of the current Command Processor Extensions.&lt;br /&gt;CommonProgramFiles   path to the Common Files folder.&lt;br /&gt;COMPUTERNAME         name of the computer.&lt;br /&gt;COMSPEC              path to the command shell executable.&lt;br /&gt;DATE                 current date.&lt;br /&gt;ERRORLEVEL           error code of the most recently used command.&lt;br /&gt;HOMEDRIVE            drive letter is connected to the user's home directory.&lt;br /&gt;HOMEPATH             full path of the user's home directory.&lt;br /&gt;HOMESHARE            network path to the user's shared home directory.&lt;br /&gt;LOGONSEVER           name of the domain controller that validated the current logon session.&lt;br /&gt;NUMBER_OF_PROCESSORS   number of processors installed on the computer.&lt;br /&gt;OS                   name of the operating system.&lt;br /&gt;                     (Windows XP and Windows 2000 list the operating system as Windows_NT.)&lt;br /&gt;Path                 search path for executable files.&lt;br /&gt;PATHEXT              file extensions that the operating system considers to be executable.&lt;br /&gt;PROCESSOR_ARCHITECTURE   processor's chip architecture.&lt;br /&gt;PROCESSOR_IDENTFIER  description of the processor.&lt;br /&gt;PROCESSOR_LEVEL      model number of the computer's processor.&lt;br /&gt;PROCESSOR_REVISION   revision number of the processor.&lt;br /&gt;ProgramFiles         path to the Program Files folder.&lt;br /&gt;PROMPT               command-prompt settings for the current interpreter.&lt;br /&gt;RANDOM               random decimal number between 0 and 32767.&lt;br /&gt;SESSIONNAME          connection and session names when connected to terminal server session.&lt;br /&gt;SYSTEMDRIVE          drive containing the Windows root directory.&lt;br /&gt;SYSTEMROOT           location of the Windows root directory.&lt;br /&gt;TEMP and TMP         default temporary directories for applications that are available to&lt;br /&gt;                     users who are currently logged on.&lt;br /&gt;TIME                 current time.&lt;br /&gt;USERDOMAIN           name of the domain that contains the user's account.&lt;br /&gt;USERNAME             name of the user currently logged on.&lt;br /&gt;USERPROFILE          location of the profile for the current user.&lt;br /&gt;WINDIR               location of the OS directory.&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-8450324066307067771?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/8450324066307067771'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/8450324066307067771'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/03/retrieve-environment-variable.html' title='Retrieve an environment variable'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-8868956323666706864</id><published>2008-03-15T14:12:00.000-07:00</published><updated>2008-09-04T14:16:37.958-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><title type='text'>Get a list of printers installed</title><content type='html'>In this example, we populate a listbox with the printers name&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;/* Get Printer List */&lt;br /&gt;string printers[]&lt;br /&gt;int rtn, i, nbPrinters&lt;br /&gt;rtn = RegistryKeys &amp;amp;&lt;br /&gt;   ("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Printers", &amp;amp;&lt;br /&gt;      printers)&lt;br /&gt;nbPrinters = UpperBound(printers)&lt;br /&gt;FOR i = 1 TO nbPrinters&lt;br /&gt;    lb_1.addItem(printers[i])&lt;br /&gt;NEXT&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-8868956323666706864?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/8868956323666706864'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/8868956323666706864'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/03/get-list-of-printers-installed.html' title='Get a list of printers installed'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-4579434901168901613</id><published>2008-03-14T17:26:00.000-07:00</published><updated>2008-09-02T17:29:57.022-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>List available ODBC datasources</title><content type='html'>You can list available ODBC datasources from within PowerBuilder. You need to declare the following external functions :&lt;br /&gt;&lt;pre&gt;&lt;code&gt;FUNCTION integer SQLAllocEnv(ref long henv) LIBRARY "odbc32.dll"&lt;br /&gt;FUNCTION integer SQLFreeEnv(long henv) LIBRARY "odbc32.dll"&lt;br /&gt;FUNCTION integer SQLDataSources &amp;amp;&lt;br /&gt;(long henv, integer idirection, ref string szdsn, int idsnmax, &amp;amp;&lt;br /&gt;ref integer idsn, ref string szdesc, integer idescmax, ref integer idesc) &amp;amp;&lt;br /&gt;library "odbc32.dll"&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;The following snippet will initialize a DropDownListbox with DataSources defined on the current workstation.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;long ll_henv&lt;br /&gt;string ls_dsn, ls_desc&lt;br /&gt;integer li_direction, li_dsnmax, li_dsnlen, li_descmax, li_desclen, li_rc&lt;br /&gt;integer li_length = 255&lt;br /&gt;&lt;br /&gt;ls_dsn = Space(li_length)&lt;br /&gt;li_dsnmax = li_length&lt;br /&gt;ls_desc = Space(li_length)&lt;br /&gt;li_descmax = li_length&lt;br /&gt;&lt;br /&gt;IF SQLAllocEnv(ll_henv) = -1 THEN&lt;br /&gt;    MessageBox("SQLAllocEnv", "FAILURE")&lt;br /&gt;ELSE&lt;br /&gt;    li_direction = 1&lt;br /&gt;    DO WHILE SQLDataSources &amp;amp;&lt;br /&gt;        (ll_henv, li_direction, ls_dsn, li_dsnmax, li_dsnlen, &amp;amp;&lt;br /&gt;         ls_desc, li_descmax, li_desclen) = 0&lt;br /&gt;         ddlb_1.AddItem(ls_dsn + "  [" + ls_desc + "]")&lt;br /&gt;    LOOP&lt;br /&gt;    SQLFreeEnv(ll_henv)&lt;br /&gt;END IF&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-4579434901168901613?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/4579434901168901613'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/4579434901168901613'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/03/list-available-odbc-datasources.html' title='List available ODBC datasources'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-104936539804837632</id><published>2008-03-13T17:21:00.000-07:00</published><updated>2008-09-02T17:25:30.285-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>How to get the current DBMS, Database or user through ODBC</title><content type='html'>These useful informations can be retrieved via direct calls to the ODBC API. This way we don't need DBMS-specific SELECT statement.&lt;br /&gt;External Function Declaration :&lt;br /&gt;&lt;pre&gt;&lt;code&gt;FUNCTION integer SQLGetInfo  &amp;amp;&lt;br /&gt;  (long hconn, integer infotype, ref string infotypeptr, &amp;amp;&lt;br /&gt;   integer bufferlength, ref integer bufferlengthptr) &amp;amp;&lt;br /&gt;  LIBRARY "odbc32.dll"&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;PowerScript:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;string ls_dbms, ls_database, ls_user&lt;br /&gt;integer li_length&lt;br /&gt;CONSTANT integer SQL_DBMS_NAME = 17&lt;br /&gt;CONSTANT integer SQL_DATABASE_NAME = 16&lt;br /&gt;CONSTANT integer SQL_USER_NAME = 47&lt;br /&gt;long   ll_dbhandle&lt;br /&gt;&lt;br /&gt;ls_dbms = space(256)&lt;br /&gt;ls_database = space(256)&lt;br /&gt;ls_user = space(256)&lt;br /&gt;ll_dbhandle = SQLCA.DbHandle()&lt;br /&gt;SQLGetInfo(ll_dbhandle, SQL_DBMS_NAME, ls_dbms, 255, li_length)&lt;br /&gt;SQLGetInfo(ll_dbhandle, SQL_DATABASE_NAME, ls_database, 255, li_length)&lt;br /&gt;SQLGetInfo(ll_dbhandle, SQL_USER_NAME, ls_user, 255, li_length)&lt;br /&gt;&lt;br /&gt;MessageBox("Current DBMS" , trim(ls_dbms))&lt;br /&gt;MessageBox("Current DATABASE" , trim(ls_database))&lt;br /&gt;MessageBox("Current USER" , trim(ls_user))&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-104936539804837632?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/104936539804837632'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/104936539804837632'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/09/how-to-get-current-dbms-database-or.html' title='How to get the current DBMS, Database or user through ODBC'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-7978847833810337824</id><published>2008-03-12T16:58:00.000-07:00</published><updated>2008-06-04T17:06:31.452-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DataWindow'/><title type='text'>Sorting Datawindow</title><content type='html'>Here's a script to sort datawindow rows when the column header is clicked as in windows explorer.&lt;br /&gt;Requirements : Column header should be same as column name and ended with '_t'. For Example,  Column Name : 'emp_id' &lt;br /&gt;Column Header : 'emp_id_t'&lt;br /&gt;Condition : Only one column can sort at a time.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;String ls_old_sort, ls_column&lt;br /&gt;Char lc_sort&lt;br /&gt;/* Check whether the user clicks on the column header */&lt;br /&gt;IF Right(dwo.Name,2) = '_t' THEN&lt;br /&gt;    ls_column = LEFT(dwo.Name, LEN(String(dwo.Name)) - 2)&lt;br /&gt;    /* Get old sort, if any. */&lt;br /&gt;    ls_old_sort = dw_1.Describe("Datawindow.Table.sort")&lt;br /&gt;    /* Check whether previously sorted column and currently clicked column are same or not. If     both are same then check for the sort order of previously sorted column (A - Asc, D - Des) and     change it. If both are not same then simply sort it by Ascending order. */&lt;br /&gt;    IF ls_column = LEFT(ls_old_sort, LEN(ls_old_sort) - 2) THEN&lt;br /&gt;         lc_sort = RIGHT(ls_old_sort, 1)&lt;br /&gt;        IF lc_sort = 'A' THEN&lt;br /&gt;             lc_sort = 'D'&lt;br /&gt;        ELSE&lt;br /&gt;             lc_sort = 'A'&lt;br /&gt;        END IF&lt;br /&gt;        dw_1.SetSort(ls_column+" "+lc_sort)&lt;br /&gt;    ELSE&lt;br /&gt;        dw_1.SetSort(ls_column+" A")&lt;br /&gt;    END IF&lt;br /&gt;    dw_1.Sort()&lt;br /&gt;END IF&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-7978847833810337824?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/7978847833810337824'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/7978847833810337824'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/03/sorting-datawindow.html' title='Sorting Datawindow'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-1995555586141222210</id><published>2008-03-11T05:09:00.000-07:00</published><updated>2008-06-04T05:11:23.408-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PowerScript'/><title type='text'>Hexadecimal to Decimal</title><content type='html'>Here's function to convert Hexadecimal number to Decimal number&lt;br /&gt;&lt;pre&gt;&lt;code&gt;/**********************************************/&lt;br /&gt;/*  public long uf_Hex2Dec ( string as_Hex )  */&lt;br /&gt;/**********************************************/&lt;br /&gt;&lt;br /&gt;CONSTANT STRING ls_HexSet = "0123456789ABCDEF"&lt;br /&gt;&lt;br /&gt;STRING  ls_Hex, ls_Bit&lt;br /&gt;LONG    ll_Div, ll_RetVal = 0&lt;br /&gt;INTEGER li_C, li_Len, li_Pos&lt;br /&gt;BOOLEAN lb_Error = FALSE&lt;br /&gt;&lt;br /&gt;ls_Hex = Upper( as_Hex )&lt;br /&gt;&lt;br /&gt;IF NOT IsNull( ls_Hex ) AND ls_Hex &lt;&gt; "" THEN&lt;br /&gt;   &lt;br /&gt;    li_Len = Len( ls_Hex )&lt;br /&gt;   &lt;br /&gt;    FOR li_C = 1 TO li_Len&lt;br /&gt;        ls_Bit = Mid( ls_Hex, li_C, 1 )&lt;br /&gt;        li_Pos = Pos( ls_HexSet, ls_Bit )&lt;br /&gt;       &lt;br /&gt;        IF li_Pos = 0 THEN&lt;br /&gt;            lb_Error = TRUE&lt;br /&gt;        ELSE&lt;br /&gt;            ll_RetVal += ( ( li_Pos - 1 ) * ( 16 ^ ( li_Len - li_C ) ) )&lt;br /&gt;        END IF&lt;br /&gt;    NEXT&lt;br /&gt;    IF lb_Error THEN ll_RetVal = 0&lt;br /&gt;END IF&lt;br /&gt;&lt;br /&gt;RETURN ll_RetVal&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-1995555586141222210?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/1995555586141222210'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/1995555586141222210'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/03/hexadecimal-to-decimal.html' title='Hexadecimal to Decimal'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-3096236957579653097</id><published>2008-03-10T02:14:00.000-07:00</published><updated>2008-06-04T02:18:15.571-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PowerScript'/><title type='text'>Julian Date</title><content type='html'>Here's a function to calculate Julian Day number for the specified day, month, year. If the year is B.C. it must be negative.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;/*  public long uf_JulianDate ( integer ai_Day, integer ai_Month, integer ai_Year )   */&lt;br /&gt;DOUBLE  lr_ycorr&lt;br /&gt;LONG    ll_Day, ll_Month, ll_Year, ll_ca, ll_cb, ll_RetVal = 0&lt;br /&gt;&lt;br /&gt;ll_Day = Long( ai_Day );  ll_Month = Long( ai_Month );  ll_Year = Long( ai_Year );&lt;br /&gt;&lt;br /&gt;IF ll_Day &gt; 0 OR ll_Month &gt; 0 OR ll_Year &gt; 0 THEN&lt;br /&gt;    IF ll_Year &gt; 0 THEN&lt;br /&gt;        lr_ycorr = 0.0&lt;br /&gt;    ELSE&lt;br /&gt;        lr_ycorr = 0.75&lt;br /&gt;    END IF&lt;br /&gt;    &lt;br /&gt;    if ll_Month &lt;= 2 THEN&lt;br /&gt;        ll_Year  = Long( ll_Year  -  1 )&lt;br /&gt;        ll_Month = Long( ll_Month + 12 )&lt;br /&gt;    END IF&lt;br /&gt;   &lt;br /&gt;    ll_cb = 0&lt;br /&gt;   &lt;br /&gt;    IF ( ( Double( ll_Year ) * Double( 10000.0 ) + Double( ll_Month ) * Double( 100.0 ) + &amp;amp;&lt;br /&gt;         Double( ll_Day ) ) &gt;= Double( 15821015.0 ) ) THEN&lt;br /&gt;      ll_ca = Long( ll_Year / 100 )&lt;br /&gt;        ll_cb = Long( 2 - ll_ca ) + Long( ll_ca / 4 )&lt;br /&gt;    END IF&lt;br /&gt;   &lt;br /&gt;    ll_RetVal = Long( Double( 365.25  ) * Double( ll_Year ) - lr_ycorr ) +  &amp;amp;&lt;br /&gt;                    Long( Double( 30.6001 ) * Double( ll_Month + 1 ) ) +  &amp;amp;&lt;br /&gt;                    Long( Double( ll_Day  ) + Double( 1720994.5 ) + Double( ll_cb ) )&lt;br /&gt;END IF&lt;br /&gt;&lt;br /&gt;RETURN ll_RetVal&lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-3096236957579653097?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/3096236957579653097'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/3096236957579653097'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/03/julian-date.html' title='Julian Date'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-6233732148089109128</id><published>2008-03-09T18:08:00.000-07:00</published><updated>2008-06-01T18:17:06.536-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><title type='text'>Hiding Application on Windows Taskbar</title><content type='html'>With this simple tips you can hide the application on Windows Taskbar even if its running&lt;br /&gt;1. Declare Win32 API module on Declare -&gt; Local External Functions:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;FUNCTION boolean SetWindowLongA (ulong hWnd, int nIndex, long newValue) Library "user32.dll"&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;2. Add below codes on Open event on main window&lt;br /&gt;&lt;pre&gt;&lt;code&gt;IF NOT SetWindowLongA(Handle(This), -20,128) THEN&lt;br /&gt;   messageBox ('Error','Cannot Hide!')&lt;br /&gt;END IF&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In order the code to take effect you should compile your application into EXE first&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-6233732148089109128?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/6233732148089109128'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/6233732148089109128'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/06/hiding-application-on-windows-taskbar.html' title='Hiding Application on Windows Taskbar'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-3426405372039808699</id><published>2008-03-08T19:38:00.000-08:00</published><updated>2008-05-29T19:38:33.464-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><title type='text'>Hiding Desktop and Taskbar</title><content type='html'>With this tips you can easily hide the desktop and taskbar from the user&lt;br /&gt;&lt;br /&gt;1. Declare win32 API module on Declare -&gt; Local External FUnctions&lt;br /&gt;&lt;pre&gt;&lt;code&gt;Function Long FindWindowEx (Long hwnd1, Long hwnd2, String lpsz1, String lpsz2) Library "user32" Alias For "FindWindowExA"&lt;br /&gt;Function Long ShowWindow (Long hwnd, Long nCmdShow) Library "user32" Alias For "ShowWindow"&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;2. Declare constants below on Declare -&gt; Instance Variables&lt;br /&gt;&lt;pre&gt;&lt;code&gt;Constant Long SW_HIDE = 0&lt;br /&gt;Constant Long SW_NORMAL = 1&lt;br /&gt;Constant Long SW_SHOWMINIMIZED = 2&lt;br /&gt;Constant Long SW_SHOWMAXIMIZED = 3&lt;br /&gt;Constant Long SW_SHOWNOACTIVATE = 4&lt;br /&gt;Constant Long SW_SHOW = 5&lt;br /&gt;Constant Long SW_MINIMIZE = 6&lt;br /&gt;Constant Long SW_SHOWMINNOACTIVE = 7&lt;br /&gt;Constant Long SW_SHOWNA = 8&lt;br /&gt;Constant Long SW_RESTORE = 9&lt;br /&gt;Constant Long SW_SHOWDEFAULT = 10&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;3. Type the example codes below to hide the desktop and taskbar&lt;br /&gt;&lt;pre&gt;&lt;code&gt;String ls_ShellViewWnd = "Progman"&lt;br /&gt;String ls_ShellTaskBarWnd = "Shell_TrayWnd"&lt;br /&gt;String ls_Null&lt;br /&gt;Long ll_HTaskBar, ll_HDeskTop&lt;br /&gt;&lt;br /&gt;setNull (ls_Null)&lt;br /&gt;//Hide TaskBar&lt;br /&gt;ll_HTaskBar = FindWindowEx ( 0, 0, ls_ShellTaskBarWnd, ls_Null)&lt;br /&gt;ShowWindow ( ll_HTaskBar, SW_HIDE )&lt;br /&gt;//Hide Desktop&lt;br /&gt;ll_HDeskTop = FindWindowEx ( 0, 0, ls_ShellViewWnd, ls_Null )&lt;br /&gt;ShowWindow ( ll_HDeskTop, SW_HIDE )&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;To show up the desktop and taskbar again, use codes below&lt;br /&gt;&lt;pre&gt;&lt;code&gt;//Show Task Bar&lt;br /&gt;ll_HTaskBar = FindWindowEx ( 0, 0, ls_ShellTaskBarWnd, ls_Null)&lt;br /&gt;ShowWindow ( ll_HTaskBar, SW_SHOW )&lt;br /&gt;//Show Desktop&lt;br /&gt;ll_HDeskTop = FindWindowEx ( 0, 0, ls_ShellViewWnd, ls_Null )&lt;br /&gt;ShowWindow ( ll_HDeskTop, SW_SHOW )&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-3426405372039808699?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/3426405372039808699'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/3426405372039808699'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/03/hiding-desktop-and-taskbar.html' title='Hiding Desktop and Taskbar'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-128179220373643128</id><published>2008-03-07T17:03:00.000-08:00</published><updated>2008-05-29T17:20:18.428-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PowerScript'/><category scheme='http://www.blogger.com/atom/ns#' term='DataWindow'/><title type='text'>Keeping Column into Array</title><content type='html'>With this simple tips you can keep all the column name on DataWindow into an array&lt;br /&gt;&lt;pre&gt;&lt;code&gt;int colNum, numCols&lt;br /&gt;string colName[]&lt;br /&gt;&lt;br /&gt;numCols = Integer(dw_control.Describe("DataWindow.Column.Count"))&lt;br /&gt;&lt;br /&gt;FOR colNum = 1 TO numCols //Get Column Name with describe&lt;br /&gt;    colName[colNum] = dw_control.Describe("#"+String(colNum) +".name")&lt;br /&gt;NEXT&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-128179220373643128?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/128179220373643128'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/128179220373643128'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/03/keeping-column-into-array.html' title='Keeping Column into Array'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-8879655834951260307</id><published>2008-03-06T17:10:00.000-08:00</published><updated>2008-04-22T17:53:00.546-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PowerScript'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>Calling Oracle Stored Procs/Functions from PB</title><content type='html'>Whenever you want to make a call to an Oracle stored procedure or stored function, a good approach is to first declare it as an external function and then invoke it based on that declaration.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;A. Declaring an Oracle Stored Procedure so that PowerBuilder Knows About it&lt;br /&gt;&lt;/span&gt;This function/procedure declaration is done in the transaction user object. First create transaction object.  Select File &gt; New then choose &lt;span style="font-style: italic;"&gt;Standard Class&lt;/span&gt; under &lt;span style="font-style: italic;"&gt;Object&lt;/span&gt; Tab. Then select &lt;span style="font-style: italic;"&gt;Transaction Type&lt;/span&gt; on Select Standard Class Type. Once inside the transaction user object, choose "Declare-Local External Functions" and follow the syntax below.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Stored Procedure (no package)&lt;br /&gt;The declaration syntax for a stored procedure (on its own, outside package) is:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;    SUBROUTINE SubRtnName(args) RPCFUNC&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In example, the declaration passes a string by value (i.e. IN) and a string by reference (i.e. IN OUT or OUT).&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;    SUBROUTINE CalcAmount(string LS_In1, ref string LS_Out2) RPCFUNC&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Notes:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;if the procedure is not in a package and does not take any array parameters, then you can click the procedures button to paste in the procedure declaration directly from the database.&lt;/li&gt;&lt;li&gt;an optional alias clause can be added to allow PowerBuilder to use a different function name from Oracle (see alias format used with package declarations).&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;li&gt;Procedure inside an Oracle package&lt;br /&gt;The declaration syntax for a stored procedure inside a package is:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;    SUBROUTINE SubRtnName(args) RPCFUNC ALIAS FOR "PackageName.ProcName"&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In example, the declaration passes a string by value (i.e. IN) and a string array by reference&lt;br /&gt;(i.e. IN OUT or OUT).&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;    SUBROUTINE CalcPenaltyAmt(string LS_In1, ref string LS_Out2[]) RPCFUNC ALIAS FOR "Penalty.P_Calc_Amount"&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Stored Function (no package)&lt;br /&gt;The declaration syntax for a stored function (on its own, outside package) is:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;    FUNCTION ReturnType FcnName(args) RPCFUNC&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In example, the declaration passes a string by value (i.e. IN) and a string array by reference (i.e. IN OUT or OUT) and it returns a long.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;    FUNCTION long CalcAmount(string LS_In1, ref string LS_Out2[]) RPCFUNC&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note: the same notes given for stored procedure declarations apply to stored functions.&lt;/li&gt;&lt;li&gt;Function inside an Oracle package&lt;br /&gt;Function inside an Oracle package&lt;br /&gt;&lt;br /&gt;The declaration syntax for a stored function inside a package is:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;    FUNCTION ReturnType FcnName(args) RPCFUNC ALIAS FOR "PackageName.FunctionName"&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In example, the declaration passes a string by value (i.e. IN) and a string array by reference (i.e. IN OUT or OUT) and returns a long.&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;    FUNCTION long CalcPenaltyAmt(string LS_In1, ref string LS_Out2[])) RPCFUNC ALIAS FOR "Penalty.f_Calc_Amount"&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-weight: bold;"&gt;B. Invoking an Oracle Stored Procedure/Function&lt;/span&gt;&lt;br /&gt;This is the invocation syntax for a stored procedure/function that has been declared in the transaction object is shown below.&lt;br /&gt;Notes on Variables passed by Reference:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Dynamically-sized output variables (i.e. strings and arrays) must be preallocated up to the size needed. When using this invocation method, PowerBuilder does not dynamically allocate the space needed for them.&lt;/li&gt;&lt;li&gt;Array Size Limitation: number of array elements times maximum element size cannot exceed 32K.&lt;/li&gt;&lt;/ul&gt;&lt;ol&gt;&lt;li&gt;Invoking a Stored Procedure&lt;br /&gt;The invocation syntax for a stored procedure is:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;    TransactionObjectName.ProcName(args)&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Sample invocation:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;   string in_parm1&lt;br /&gt;   string out_parm2&lt;br /&gt;&lt;br /&gt;   in_parm1 = "input value"&lt;br /&gt;   out_parm2 = space(50) // preallocating space for string&lt;br /&gt;&lt;br /&gt;   SQLCA.CalcAmount(in_parm1, out_parm2)&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Invoking a Stored Function (shown using an array variable)&lt;br /&gt;The invocation syntax is:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;    ReturnValue = TransactionObjectName.FcnName(args)&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Sample invocation:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;br /&gt;   string in_parm1&lt;br /&gt;   string out_parm2[5] // defining fixed sized array&lt;br /&gt;   long ll_return&lt;br /&gt;&lt;br /&gt;   in_parm1 = "input value"&lt;br /&gt;&lt;br /&gt;   // preallocating space for 500 chars for whole string array.&lt;br /&gt;   // Each element will effectively be 500 bytes by allocating&lt;br /&gt;   // the first.&lt;br /&gt;   out_parm2[1] = space(500)&lt;br /&gt;&lt;br /&gt;   ll_Return = SQLCA.CalcAmount(in_parm1, out_parm2[])&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-8879655834951260307?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/8879655834951260307'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/8879655834951260307'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/04/calling-oracle-stored-procsfunctions.html' title='Calling Oracle Stored Procs/Functions from PB'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-2932722753046819924</id><published>2008-03-05T16:59:00.000-08:00</published><updated>2008-04-22T17:02:44.958-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PowerScript'/><title type='text'>Re-initializing an Unbounded Array</title><content type='html'>Suppose that you have been filling an array with values. Now you want to reinitialize the array to its original empty state. PowerBuilder doesn’t have an explicit function to help re-initialize the array, so you have to do it manually as described below.&lt;br /&gt;&lt;br /&gt;Declare a dummy array of the same type. Never put any values into this array. When you want to re-initialize your "working array", assign it to the value of the empty array. This will clear out the "working" array and make the UpperBound function return the correct value (zero). See sample code below:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;string ls_EmptyArray[]&lt;br /&gt;string ls_NameArray[]&lt;br /&gt;&lt;br /&gt;ls_NameArray[1] = "James"&lt;br /&gt;... more work ...&lt;br /&gt;&lt;br /&gt;// empty out Name Array&lt;br /&gt;ls_NameArray = ls_EmptyArray&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-2932722753046819924?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/2932722753046819924'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/2932722753046819924'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/03/re-initializing-unbounded-array.html' title='Re-initializing an Unbounded Array'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-6947439391840966012</id><published>2008-03-04T04:33:00.000-08:00</published><updated>2008-03-04T04:39:41.484-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PowerScript'/><title type='text'>Tracing on Running Application</title><content type='html'>On PowerBuilder we can trace the running compiled application (*.exe) by running application with the &lt;span style="font-weight: bold;"&gt;/PBDEBUG&lt;/span&gt; option.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;application_name.exe /PBDEBUG&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;After that, just run your application as usual. On the same directory with the compiled PowerBuilder application, you will find file with an extension &lt;span style="font-weight: bold;"&gt;*.dbg &lt;/span&gt;( eg. application_name.dbg). Within this file you will find useful orderly manner information . This is just an alternative for debugging the program.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-6947439391840966012?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/6947439391840966012'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/6947439391840966012'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/03/tracing-on-running-application.html' title='Tracing on Running Application'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-353239469985751660</id><published>2008-03-04T01:50:00.000-08:00</published><updated>2008-03-04T02:19:14.630-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PowerScript'/><title type='text'>Using Windows Scripting Host</title><content type='html'>You can use Windows Scripting Host on PowerBuilder for many purpose. On sample code below, you can use it to get the network domain, user name and computer name. To do so, you need Windows Scripting Host Object Model component (wshom.ocx)&lt;br /&gt;&lt;pre&gt;&lt;code&gt;integer li_rc&lt;br /&gt;OleObject ole_wsh&lt;br /&gt;&lt;br /&gt;ole_wsh = CREATE OleObject&lt;br /&gt;li_rc = ole_wsh.ConnectToNewObject ( "WScript.Network" )&lt;br /&gt;IF li_rc = 0 THEN&lt;br /&gt;     MessageBox ("Domain", string( ole_wsh.UserDomain ))&lt;br /&gt;     MessageBox ("User", string( ole_wsh.UserName ))&lt;br /&gt;     MessageBox ("Computer", string( ole_wsh.ComputerName ))&lt;br /&gt;END IF&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;With WSH, you can execute other application from PowerBuilder application. On example below, Notepad will be called by clicking a  button from PowerBuilder application&lt;br /&gt;&lt;pre&gt;&lt;code&gt;integer li_rc&lt;br /&gt;OleObject ole_wsh&lt;br /&gt;&lt;br /&gt;ole_wsh = CREATE OleObject&lt;br /&gt;li_rc = ole_wsh.ConnectToNewObject ( "WScript.Shell" )&lt;br /&gt;ole_wsh.Run ("Notepad")&lt;br /&gt;ole_wsh.AppActivate("Untitled - Notepad")&lt;br /&gt;Sleep (500)&lt;br /&gt;ole_wsh.SendKeys (''Hello from PB")&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Sleep is a function from Win32 API module with a declaration like this :&lt;br /&gt;&lt;pre&gt;&lt;code&gt;Subroutine Sleep (Long dwMilliseconds) Library "kernel32" Alias for "Sleep"&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You also can run Calculator program and send some key stroke on it&lt;br /&gt;&lt;pre&gt;&lt;code&gt;integer li_rc&lt;br /&gt;OleObject ole_wsh&lt;br /&gt;&lt;br /&gt;ole_wsh = CREATE OleObject&lt;br /&gt; li_rc = ole_wsh.ConnectToNewObject ( "WScript.Shell" )&lt;br /&gt;ole_wsh.Run("calc")&lt;br /&gt;ole_wsh.AppActivate ("Calculator", 100)&lt;br /&gt;Sleep (1000)&lt;br /&gt;ole_wsh.SendKeys("1{+}")&lt;br /&gt;Sleep (1000)&lt;br /&gt;ole_wsh.SendKeys("2")&lt;br /&gt;Sleep (1000)&lt;br /&gt;ole_wsh.SendKeys("=")&lt;br /&gt;Sleep (1000)&lt;br /&gt;ole_wsh.SendKeys("*4")&lt;br /&gt;Sleep (1000)&lt;br /&gt;ole_wsh.SendKeys("=")&lt;br /&gt;// 1+2 = ( 3, then) * 4 = 12&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;You also can run VBScript from PowerBuilder easily. To do that you need Microsoft Script Control component (msscript.ocx)&lt;br /&gt;&lt;pre&gt;&lt;code&gt;OleObject ole_wsh&lt;br /&gt;Integer li_rc, i, j, k&lt;br /&gt;&lt;br /&gt;ole_wsh = Create OleObject&lt;br /&gt;li_rc = ole_wsh.ConnectToNewObject ("MSScriptControl.ScriptControl")&lt;br /&gt;ole_wsh.language = "vbscript"&lt;br /&gt;ole_wsh.addcode("function retfnc(s) retfnc = s end function")&lt;br /&gt;ole_wsh.executestatement ('if 1 &gt; 1 then msgbox retfnc("true") else msgbox retfnc("false") end if&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-353239469985751660?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/353239469985751660'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/353239469985751660'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/03/using-windows-scripting-host.html' title='Using Windows Scripting Host'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-1085028165328765774</id><published>2008-02-11T16:38:00.000-08:00</published><updated>2008-02-11T16:43:08.563-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>Faster Exist Checking in Oracle</title><content type='html'>When performing checks in business logic to see if a record is used as part of a foreign key in a child table people often opt for the Select Count(*) type SQL call. This is a clean way to check for dependant rows but not necessarily the fastest. The Count(*) function call may  result in a table scan. A better way to check for this is to make use of a handy Oracle feature called ROWNUM. Using this feature we can select a single row matching our parent key and then check the number of rows returned. This will be quicker than the Count(*) method. For example:&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;SQL Using Count(*)&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;SELECT Count(*) INTO :ll_Count&lt;br /&gt;      FROM ORDER&lt;br /&gt;      WHERE PROD_ID = :ls_CheckProd&lt;br /&gt;      USING SQLCA;&lt;br /&gt;IF ll_Count &gt; 0 THEN // Cannot delete product&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;SQL Using ROWNUM&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;SELECT ORDER_ID INTO :ll_OrderID&lt;br /&gt;      FROM ORDER&lt;br /&gt;      WHERE PROD_ID = :ls_CheckProd&lt;br /&gt;         AND ROWNUM &lt; 2        USING SQLCA;     &lt;br /&gt;IF SQLCA.SQLNRows &lt;&gt; 0 THEN // cannot delete product&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-1085028165328765774?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/1085028165328765774'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/1085028165328765774'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/02/faster-exist-checking-in-oracle.html' title='Faster Exist Checking in Oracle'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-1309563097152596042</id><published>2008-01-28T00:39:00.000-08:00</published><updated>2008-01-28T00:41:54.604-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DataWindow'/><title type='text'>Avoiding "Double" Error Messages in DW Validation</title><content type='html'>A common problem when setting up validation logic in ItemChanged is that two message get&lt;br /&gt;displayed. First, the intended message in ItemChanged and then a default PowerBuilder message:&lt;br /&gt;"Item '[value]' does not pass validation test". One simple solution to avoid this problem is to&lt;br /&gt;have descendents set a flag (ib_SuppressMsg) in the ItemChanged event, when they've already&lt;br /&gt;displayed an error message.&lt;br /&gt;In ItemChanged event:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;IF ... error situation ... THEN&lt;br /&gt;  ... display message ...&lt;br /&gt;  li_Return = 1 // reject value&lt;br /&gt;END IF&lt;br /&gt;&lt;br /&gt;// Bottom of ItemChanged script ...&lt;br /&gt;// set flag so ItemError know to suppress its default message&lt;br /&gt;IF li_Return = 1 THEN&lt;br /&gt;  ib_SuppressMsg = True&lt;br /&gt;END IF&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;In ItemError, check this flag and, if set, return 1 so the default ItemError  message is suppressed:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;IF ib_SuppressMsg THEN&lt;br /&gt;  li_Return = 1&lt;br /&gt;  ib_SuppressMsg = False // reset flag for next time&lt;br /&gt;ELSE&lt;br /&gt;  ... error not caused by ItemChanged&lt;br /&gt;END IF&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-1309563097152596042?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/1309563097152596042'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/1309563097152596042'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/avoiding-double-error-messages-in-dw.html' title='Avoiding &quot;Double&quot; Error Messages in DW Validation'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-704323064401813341</id><published>2008-01-27T23:47:00.000-08:00</published><updated>2008-01-28T00:23:07.257-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='DataWindow'/><title type='text'>Capturing Special Keys on your DataWindow</title><content type='html'>A common requirement for applications is to capture certain keystrokes and perform special&lt;br /&gt;actions when the user presses these keys. To capture keystrokes on your DataWindow, do the&lt;br /&gt;following:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Declare an event on your DataWindow (possibly your ancestor DW, as is done here) and     assign that event the pbm_dwnkey event id. This causes all keystrokes to be processed     through the event.&lt;/li&gt;&lt;li&gt;Code that event to handle the special keystrokes in the desired manner. Ideally, common     keystrokes (like Enter, Tab) will be captured at the ancestor level and a standard event     will be called. A sample event that catches certain keystrokes is shown below.&lt;/li&gt;&lt;/ol&gt;In this sample event, the following keystrokes can be captured:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;tabs: to do so, a descendant DW sets the ib_CaptureTab instance variable to True. The&lt;br /&gt;ue_Tab or ue_BackTab event are then invoked when Tab/BackTab is pressed to allow&lt;br /&gt;the descendant to code appropriate logic.&lt;/li&gt;&lt;li&gt;enter keys: to do so, a descendant DW sets the ib_CaptureEnter instance variable to True.&lt;br /&gt;The ue_Enter event is then called when Enter is pressed to allow the descendant to code&lt;br /&gt;appropriate logic.&lt;/li&gt;&lt;/ul&gt;sample ue_key event code:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;// if descendent DW wants tab ... capture it&lt;br /&gt;IF ib_CaptureTab AND KeyDown(KeyTab!) THEN&lt;br /&gt;  // determine whether it is a tab or back-tab&lt;br /&gt;  IF NOT KeyDown(KeyShift!) THEN&lt;br /&gt;    This.POST ue_Tab()&lt;br /&gt;  ELSE&lt;br /&gt;    This.POST ue_BackTab()&lt;br /&gt;  END IF&lt;br /&gt;  Return 1 // have key not otherwise be ignored by PB&lt;br /&gt;&lt;br /&gt;// if descendent DW wants enter keys ... capture it&lt;br /&gt;ELSEIF ib_CaptureEnter AND KeyDown(KeyEnter!) THEN&lt;br /&gt;  This.POST ue_Enter()&lt;br /&gt;  Return 1 // have key not otherwise be ignored by PB&lt;br /&gt;&lt;br /&gt;// otherwise send the key to the window-level for standard processing&lt;br /&gt;ELSE&lt;br /&gt;  IF IsValid(iw_ParentWin) THEN&lt;br /&gt;    iw_ParentWin.TriggerEvent(Key!)&lt;br /&gt;  ELSE&lt;br /&gt;    // how did we get a key event for invalid parent?&lt;br /&gt;    f_SignalError(0/gi_zero,"Invalid Parent Window in Key Event")&lt;br /&gt;  END IF&lt;br /&gt;END IF&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note: a handle to the parent window (iw_ParentWin) is obtained in the Constructor event. PFC's&lt;br /&gt;of_GetParentWindow function is a good method to generically get a handle to the parent&lt;br /&gt;window.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-704323064401813341?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/704323064401813341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/704323064401813341'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/capturing-special-keys-on-your.html' title='Capturing Special Keys on your DataWindow'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-5927435017556892960</id><published>2008-01-27T17:38:00.000-08:00</published><updated>2008-01-27T17:59:37.994-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PowerScript'/><title type='text'>Center a Response Window</title><content type='html'>You can centralized your windows with the following code and put it on open event:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;LONG   ll_X, ll_Y, ll_XCtr, ll_YCtr&lt;br /&gt;WINDOW      lWin&lt;br /&gt;&lt;br /&gt;lWin = aw_Window.ParentWindow();&lt;br /&gt;&lt;br /&gt;ll_XCtr = lWin.X + ( lWin.Width  / 2 );&lt;br /&gt;ll_YCtr = lWin.Y + ( lWin.Height / 2 );&lt;br /&gt;&lt;br /&gt;ll_X = ll_XCtr - ( aw_Window.Width  / 2 );&lt;br /&gt;ll_Y = ll_YCtr - ( aw_Window.Height / 2 );&lt;br /&gt;&lt;br /&gt;IF ll_X &lt; 0 THEN ll_X = 0;&lt;br /&gt;IF ll_Y &lt; 0 THEN ll_Y = 0;&lt;br /&gt;&lt;br /&gt;RETURN aw_Window.Move( ll_X, ll_Y )&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;For MDI child window you can use the following code:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;LONG   ll_X, ll_Y, ll_XCtr, ll_YCtr&lt;br /&gt;WINDOW      lWin&lt;br /&gt;&lt;br /&gt;lWin = aw_Window.ParentWindow();&lt;br /&gt;&lt;br /&gt;IF ( ( ( lWin.WindowType = MDI! ) OR ( lWin.WindowType = MDIHelp! ) ) AND  &amp;amp;&lt;br /&gt;  ( aw_Window.WindowType = Child! ) ) THEN&lt;br /&gt; ll_XCtr = lWin.WorkSpaceWidth() / 2;&lt;br /&gt; ll_YCtr = lWin.WorkSpaceHeight() / 2;&lt;br /&gt;&lt;br /&gt; IF lWin.WindowType = MDIHelp! THEN&lt;br /&gt;  ll_YCtr = ll_YCtr - 40;&lt;br /&gt; END IF&lt;br /&gt;&lt;br /&gt; ll_X = ll_XCtr - ( aw_Window.Width  / 2 );&lt;br /&gt; ll_Y = ll_YCtr - ( aw_Window.Height / 2 ) - 200;&lt;br /&gt;&lt;br /&gt; IF ll_X &lt; 0 THEN ll_X = 0;&lt;br /&gt; IF ll_Y &lt; 0 THEN ll_Y = 0;&lt;br /&gt;ELSE&lt;br /&gt; ll_X = aw_Window.X;&lt;br /&gt; ll_Y = aw_Window.Y;&lt;br /&gt;END IF&lt;br /&gt;&lt;br /&gt;RETURN aw_Window.Move( ll_X, ll_Y )&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-5927435017556892960?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/5927435017556892960'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/5927435017556892960'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/center-response-window.html' title='Center a Response Window'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-9094946242794363405</id><published>2008-01-24T23:44:00.001-08:00</published><updated>2008-01-24T23:50:15.951-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>If Statements Using SQL</title><content type='html'>When building list windows for users you often want to allow them to specify search criteria. If the search criteria are simple and only have a single field or all fields must be entered than a simple WHERE clause with retrieval arguments will do the job.&lt;br /&gt;&lt;br /&gt;For very complicated arguments with multiple selections you will have to resort to dynamically altering the SQL behind the datawindow. But you may not realize that if you do not require multiple selections for a single field then with some clever SQL coding you can avoid time consuming dynamic SQL.&lt;br /&gt;&lt;br /&gt;For example if we were building a selection window for employees, you may want to allow the user to search based on employee number, employee name, Address or any combination of the three. We can achieve this by declaring three retrieval arguments of the correct datatypes. In your retrieve script on the window you would have designed the arguments input criteria using a datawindow! so you could select the empty field is null option of the edit control. If you have not and shame on you then if the field is empty you will need to manually set it to null.&lt;br /&gt;Then in the SQL you would code for the NULL values:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;SELECT emp_no, emp_name, emp_addr1, emp_telno&lt;br /&gt; FROM employee&lt;br /&gt; WHERE ( emp_no = :al_emp_no OR :al_emp_no IS NULL )&lt;br /&gt;   AND ( emp_name = :as_emp_name OR :as_emp_name IS NULL )&lt;br /&gt;   AND ( emp_addr1 = :as_emp_addr OR :as_emp_addr1 IS NULL )&lt;/code&gt;&lt;/pre&gt;You would also want to concatenate '%' on to the end of the strings to allow for pattern matching and convert both sides of the comparison to Lower case to make it more user friendly, you would convert the retrieval argument to lower case once in Powerscript and pass it to the datawindow:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;( Lower( emp_name ) LIKE :as_emp_name...&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-9094946242794363405?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/9094946242794363405'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/9094946242794363405'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/if-statements-using-sql.html' title='If Statements Using SQL'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-5982898669129066594</id><published>2008-01-24T22:25:00.000-08:00</published><updated>2008-12-11T01:19:14.298-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><title type='text'>Run an Application Only Once</title><content type='html'>In this tips, I would like to discuss how to make an application run only once at a time. When user try to run your application, first try to see if it is already running. If it is already running bring it to top and return. There are some sleek SDK functions you can make use of to implement this. The following are the steps to create this feature:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Create a "&lt;span style="font-weight: bold;"&gt;Custom Class UserObject&lt;/span&gt;"&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_jCDKRlOd7m8/R5mDKtDsThI/AAAAAAAAAM8/sjXFz8OAj7k/s1600-h/001.JPG"&gt;&lt;img style="cursor: pointer;" src="http://2.bp.blogspot.com/_jCDKRlOd7m8/R5mDKtDsThI/AAAAAAAAAM8/sjXFz8OAj7k/s320/001.JPG" alt="Custom Class PowerBuilder UserObject" id="BLOGGER_PHOTO_ID_5159299068046626322" border="0" /&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;Set the &lt;span style="font-weight: bold;"&gt;AutoInstantiate&lt;/span&gt; to &lt;span style="font-weight: bold;"&gt;TRUE&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Declare the Win32 API modul at the UserObject on Declare -&gt; Local External Functions&lt;br /&gt;&lt;pre&gt;&lt;code&gt;Function Long GetLastError () Library 'kernel32.dll'&lt;br /&gt;Function ULong CreateMutex (ULong lpsa, Boolean fInitialOwner, String lpszMutexName) Library 'kernel32.dll' Alias for CreateMutexA&lt;/code&gt;&lt;span style="font-family:Georgia,serif;"&gt;&lt;/span&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Create a UserObject Function like this:&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_jCDKRlOd7m8/R5mF8tDsTjI/AAAAAAAAANM/JZ_dGFBwGLo/s1600-h/002.JPG"&gt;&lt;img style="cursor: pointer;" src="http://2.bp.blogspot.com/_jCDKRlOd7m8/R5mF8tDsTjI/AAAAAAAAANM/JZ_dGFBwGLo/s320/002.JPG" alt="Create UserObject Function - isRunning" id="BLOGGER_PHOTO_ID_5159302126063341106" border="0" /&gt;&lt;/a&gt;&lt;pre&gt;&lt;code&gt;String ls_name&lt;br /&gt;If Handle(GetApplication()) &gt; 0 Then&lt;br /&gt;ls_name = GetApplication().AppName + Char(0)&lt;br /&gt;CreateMutex(0, True, ls_name)&lt;br /&gt;If GetLastError() = 183 Then Return True&lt;br /&gt;End If&lt;br /&gt;Return False&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Save the UserObject as uo_mutex (for example)&lt;/li&gt;&lt;/ol&gt;Below is how to use the object. Put this code at the beginning of &lt;span style="font-weight: bold;"&gt;open&lt;/span&gt; event from your &lt;span style="font-weight: bold;"&gt;Application&lt;/span&gt; object:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;uo_mutex lou_mutex&lt;br /&gt;If lou_mutex.uf_isrunning() Then&lt;br /&gt;  MessageBox ('Warning', 'Application is already running', StopSign!)&lt;br /&gt;  HALT CLOSE&lt;br /&gt;End If&lt;br /&gt;//...&lt;br /&gt;// Your next line code&lt;br /&gt;//...&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-5982898669129066594?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/5982898669129066594'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/5982898669129066594'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/run-application-only-once.html' title='Run an Application Only Once'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_jCDKRlOd7m8/R5mDKtDsThI/AAAAAAAAAM8/sjXFz8OAj7k/s72-c/001.JPG' height='72' width='72'/></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-5695357856009088888</id><published>2008-01-24T20:17:00.000-08:00</published><updated>2008-01-24T22:08:34.519-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><title type='text'>C/C++ Datatype Conversion</title><content type='html'>If you want to use the Win32 API within PowerBuilder, you have to know the prototype modul. The following list is not an exhaustive list of all C and C++ to PowerBuilder Datatype but most of the common Datatype that I've used over the years of interfacing PowerBuilder and C/C++ programs. There are two lists, the first is PowerBuilder to C++ Datatype, useful for the C Proxy Generator. Then there is a list of C/C++ to PowerBuilder Datatype useful for people writing DLL's and the like:&lt;br /&gt;&lt;table style="width: 300px;" border="0" cellpadding="3" cellspacing="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="c5" align="center"&gt;&lt;b&gt;PowerBuilder Datatype&lt;/b&gt;&lt;/td&gt;&lt;td class="c5" align="center"&gt;&lt;b&gt;C/C++ Datatype&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class="c6"&gt;&lt;td align="center"&gt;Blob&lt;/td&gt;&lt;td align="center"&gt;PBBlob&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="center"&gt;Boolean&lt;/td&gt;&lt;td align="center"&gt;int&lt;/td&gt;&lt;/tr&gt;&lt;tr class="c6"&gt;&lt;td align="center"&gt;Character&lt;/td&gt;&lt;td align="center"&gt;char&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="center"&gt;Date&lt;/td&gt;&lt;td align="center"&gt;PBDate&lt;/td&gt;&lt;/tr&gt;&lt;tr class="c6"&gt;&lt;td align="center"&gt;DateTime&lt;/td&gt;&lt;td align="center"&gt;PBDateTime&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="center"&gt;Decimal&lt;/td&gt;&lt;td align="center"&gt;PBDecimal&lt;/td&gt;&lt;/tr&gt;&lt;tr class="c6"&gt;&lt;td align="center"&gt;Double&lt;/td&gt;&lt;td align="center"&gt;double&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="center"&gt;Integer&lt;/td&gt;&lt;td align="center"&gt;int&lt;/td&gt;&lt;/tr&gt;&lt;tr class="c6"&gt;&lt;td align="center"&gt;Real&lt;/td&gt;&lt;td align="center"&gt;float&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="center"&gt;String&lt;/td&gt;&lt;td align="center"&gt;PBString&lt;/td&gt;&lt;/tr&gt;&lt;tr class="c6"&gt;&lt;td align="center"&gt;Time&lt;/td&gt;&lt;td align="center"&gt;PBTime&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="center"&gt;UnSignedInteger&lt;/td&gt;&lt;td align="center"&gt;unsigned int&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;&lt;table style="width: 300px;" border="0" cellpadding="3" cellspacing="1"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="c5" align="center"&gt;&lt;b&gt;C/C++ Datatype&lt;/b&gt;&lt;/td&gt;&lt;td class="c5" align="center"&gt;&lt;b&gt;PowerBuilder Datatype&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr class="c6"&gt;&lt;td align="center"&gt;BOOL&lt;/td&gt;&lt;td align="center"&gt;Boolean&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="center"&gt;WORD&lt;/td&gt;&lt;td align="center"&gt;UnSignedInteger&lt;/td&gt;&lt;/tr&gt;&lt;tr class="c6"&gt;&lt;td align="center"&gt;DWORD&lt;/td&gt;&lt;td align="center"&gt;UnSignedLong&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="center"&gt;HANDLE&lt;/td&gt;&lt;td align="center"&gt;UnSignedLong&lt;/td&gt;&lt;/tr&gt;&lt;tr class="c6"&gt;&lt;td align="center"&gt;HWND&lt;/td&gt;&lt;td align="center"&gt;UnSignedLong&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="center"&gt;LPSTR&lt;/td&gt;&lt;td align="center"&gt;String Ref&lt;/td&gt;&lt;/tr&gt;&lt;tr class="c6"&gt;&lt;td align="center"&gt;LPBYTE&lt;/td&gt;&lt;td align="center"&gt;String Ref&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="center"&gt;LPINT&lt;/td&gt;&lt;td align="center"&gt;Long Ref&lt;/td&gt;&lt;/tr&gt;&lt;tr class="c6"&gt;&lt;td align="center"&gt;char&lt;/td&gt;&lt;td align="center"&gt;Blob {1}&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="center"&gt;int&lt;/td&gt;&lt;td align="center"&gt;Integer&lt;/td&gt;&lt;/tr&gt;&lt;tr class="c6"&gt;&lt;td align="center"&gt;unsigned int&lt;/td&gt;&lt;td align="center"&gt;UnsignedInt&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="center"&gt;long&lt;/td&gt;&lt;td align="center"&gt;Long&lt;/td&gt;&lt;/tr&gt;&lt;tr class="c6"&gt;&lt;td align="center"&gt;ULONG/unsigned long&lt;/td&gt;&lt;td align="center"&gt;UnsignedLong&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td align="center"&gt;double&lt;/td&gt;&lt;td align="center"&gt;Double&lt;/td&gt;&lt;/tr&gt;&lt;tr class="c6"&gt;&lt;td align="center"&gt;char *&lt;/td&gt;&lt;td align="center"&gt;String Ref&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-5695357856009088888?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/5695357856009088888'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/5695357856009088888'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/cc-datatype-conversion.html' title='C/C++ Datatype Conversion'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-2555078282091702242</id><published>2008-01-23T20:56:00.000-08:00</published><updated>2008-01-23T21:10:57.276-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><title type='text'>Registering OCX Components in an Exe</title><content type='html'>Having problems with OCX's which work fine in development and EXE on your machine but when you ship the EXE to a users machine and install your program the OCX does not work?&lt;br /&gt;&lt;br /&gt;The problem is that the way OCX's are designed to work is that every OCX should attempt on its own to register with the system during its constructor event. This is done by the container calling a function that is in EVERY OCX called DLLRegisterServer.&lt;br /&gt;&lt;br /&gt;The problem is that PowerBuilder does not call this function. Even if you run the REGSRV utility, the OCX will fail to register itself. To correct this problem, in object where you are using the OCX you need to goto the constructor event and call the OCX DLLRegesterServer function.&lt;br /&gt;&lt;br /&gt;Declare a local external function in the container object&lt;br /&gt;&lt;pre&gt;&lt;code&gt;Function long DllRegisterServer() Library "ocxname.OCX"&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;In the constructor event&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;LONG ll_RC&lt;br /&gt;ll_RC = DllRegisterServer()&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-2555078282091702242?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/2555078282091702242'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/2555078282091702242'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/registering-ocx-components-in-exe.html' title='Registering OCX Components in an Exe'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-6347338094895377830</id><published>2008-01-23T20:43:00.000-08:00</published><updated>2008-01-23T20:47:19.360-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><title type='text'>Get The Name of a Network Share</title><content type='html'>Using the &lt;a href="http://power-builder.blogspot.com/2008/01/get-volume-information.html"&gt;Get Volume API&lt;/a&gt; tip previously posted will return the names of the drives connected to your machine. Unfortunately for network drives this returns the name of the physical drive not the name of the share you have mapped to. If you have many shares mapped to a single physical network drive you will not be able to distinguish between the drives.&lt;br /&gt;&lt;br /&gt;To improve this situation you can use an API call to return the name of the network share. This is more meaningful and easier for the user. The API call you will need to use is WNetGetConnectionA. To use the API call declare the local external function as follows:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;function ulong WNetGetConnectionA( string szLocalPath, &amp;amp;&lt;br /&gt;   ref string szNameBuffer,  ref ulong lpBufferSize) Library "mpr.dll"&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Then in your script you can call the API as follows:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;Ulong lul_Max&lt;br /&gt;Long ll_RC&lt;br /&gt;String ls_Drive, ls_Volume&lt;br /&gt;&lt;br /&gt;// hard coded for the f: drive&lt;br /&gt;ls_Drive = 'f:'&lt;br /&gt;lul_Max = 2000&lt;br /&gt;&lt;br /&gt;// pre allocate string to stop GPF&lt;br /&gt;ls_Volume = Space( 2000 )&lt;br /&gt;&lt;br /&gt;// call the API function, the share name&lt;br /&gt;// will be in the ls_Volume variable&lt;br /&gt;ll_RC = WNetGetConnectionA( ls_Drive, ls_Volume, lul_Max )&lt;br /&gt;ls_Volume = Trim( ls_Volume )&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-6347338094895377830?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/6347338094895377830'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/6347338094895377830'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/get-name-of-network-share.html' title='Get The Name of a Network Share'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-4969425576298959651</id><published>2008-01-23T20:40:00.000-08:00</published><updated>2008-09-18T01:54:12.202-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><title type='text'>Get Volume Information</title><content type='html'>In order to show a list of Drives We needed to get the name of the Drive. The following API call gets the volume name as well as the serial number.&lt;br /&gt;&lt;br /&gt;Create an NVO add the following local external function:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;function long GetVolumeInformationA( ref string ls_RootPath, &amp;amp;&lt;br /&gt; ref string ls_VolName, long ll_VolLen, ref string ls_volserial, &amp;amp;&lt;br /&gt; long ll_maxcomplen, long ll_systemflags, &amp;amp;&lt;br /&gt; ref string ls_SystemName,&amp;amp;&lt;br /&gt; long ll_SystemLen ) Library 'kernel32'&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Then add a function called GetVolumeName which accepts a string and returns a string and add the following code:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;// Call the API function to get the volume &lt;/code&gt;&lt;code&gt;label from a drive letter&lt;/code&gt;&lt;code&gt;&lt;br /&gt;&lt;/code&gt;&lt;code&gt;Long ll_Max, ll_Flags, ll_Ret, ll_FileSys&lt;br /&gt;Long ll_Vol&lt;/code&gt;&lt;br /&gt;&lt;code&gt;String ls_Vol&lt;br /&gt;String ls_Drv, ls_FileSys, ls_Flags, ls_Serial&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ls_Drv = as_Vol&lt;br /&gt;ls_Vol = Space(32)&lt;br /&gt;ls_FileSys = Space(32)&lt;br /&gt;ls_Serial = Space(32)&lt;br /&gt;ll_Vol = Len( ls_Vol )&lt;br /&gt;ll_FileSys = Len( ls_Filesys )&lt;br /&gt;&lt;br /&gt;ll_Ret = GetVolumeInformationA( ls_Drv, ls_Vol, ll_Vol, &amp;amp;&lt;br /&gt;  ls_Serial, ll_Max, ll_Flags, ls_FileSys, ll_FileSys )&lt;br /&gt;&lt;br /&gt;IF (ll_Ret = 0) THEN&lt;br /&gt;  ls_Vol = ''&lt;br /&gt;ELSE&lt;br /&gt;  ls_Vol = Trim( ls_Vol )&lt;br /&gt;END IF&lt;br /&gt;&lt;br /&gt;RETURN (ls_Vol)&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Call the function passing the drive you want the volume name for. For example C:\&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-4969425576298959651?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/4969425576298959651'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/4969425576298959651'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/get-volume-information.html' title='Get Volume Information'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-7158428883570311528</id><published>2008-01-23T20:28:00.000-08:00</published><updated>2008-01-23T20:35:31.441-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><title type='text'>Mapping a Network Drive</title><content type='html'>This tip show how to use the Window API for mapping a network drive from PowerBuilder.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Function Declaration&lt;/span&gt;:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;FUNCTION ulong WNetUseConnectionA (ulong hwndOwner, &amp;amp;&lt;br /&gt;   REF s_netresource lpNetResource, string lpPassword,&lt;br /&gt;   string lpUsername, ulong dwFlags, REF string lpAccessName, &amp;amp;&lt;br /&gt;   REF ulong lpBufferSize, REF ulong lpResult) library "mpr.dll"&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Structure Definition&lt;/span&gt;:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;$PBExportHeader$s_netresource.srs&lt;br /&gt;global type s_netresource from structure&lt;br /&gt; unsignedlong  dwScope&lt;br /&gt; unsignedlong  dwType&lt;br /&gt; unsignedlong  dwDisplayType&lt;br /&gt; unsignedlong  dwUsage&lt;br /&gt; string  lpLocalName&lt;br /&gt; string  lpRemoteName&lt;br /&gt; string  lpComment&lt;br /&gt; string  lpProvider&lt;br /&gt;end type&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Mapping Code&lt;/span&gt;:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;CONSTANT ulong NO_ERROR = 0&lt;br /&gt;CONSTANT ulong CONNECT_REDIRECT = 128&lt;br /&gt;CONSTANT ulong RESOURCETYPE_DISK = 1&lt;br /&gt;&lt;br /&gt;s_netresource lstr_netresource&lt;br /&gt;&lt;br /&gt;String   ls_null&lt;br /&gt;String   ls_buffer&lt;br /&gt;String   ls_MappedDrive&lt;br /&gt;&lt;br /&gt;uLong    ll_bufferlen&lt;br /&gt;uLong    ll_null&lt;br /&gt;uLong    ll_ErrInfo&lt;br /&gt;uLong    ll_success&lt;br /&gt;&lt;br /&gt;SetNull(ll_null)&lt;br /&gt;SetNull(ls_null)&lt;br /&gt;&lt;br /&gt;ls_buffer = Space(32)&lt;br /&gt;ll_bufferlen = Len(ls_buffer)&lt;br /&gt;&lt;br /&gt;lstr_netresource.dwType = RESOURCETYPE_DISK&lt;br /&gt;lstr_netresource.lpLocalName = ls_null&lt;br /&gt;lstr_netresource.lpRemoteName = "UNC resource name here"&lt;br /&gt;lstr_netresource.lpProvider = ls_null&lt;br /&gt;&lt;br /&gt;ll_ErrInfo = WNetUseConnectionA(ll_null, lstr_netresource, &amp;amp;&lt;br /&gt;   'password', 'username', &amp;amp;&lt;br /&gt;   CONNECT_REDIRECT, ls_buffer, ll_bufferlen, ll_success)&lt;br /&gt;&lt;br /&gt;IF ll_ErrInfo = NO_ERROR THEN&lt;br /&gt;   MessageBox("Drive Mapped", "Drive Letter is " + ls_buffer)&lt;br /&gt;   Return 1&lt;br /&gt;ELSE&lt;br /&gt;   MessageBox("Mapping Falied", "Error is " + String(ll_ErrInfo))&lt;br /&gt;   Return -1&lt;br /&gt;END IF&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-7158428883570311528?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/7158428883570311528'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/7158428883570311528'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/mapping-network-drive.html' title='Mapping a Network Drive'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-6977701138127386439</id><published>2008-01-23T17:34:00.000-08:00</published><updated>2008-01-23T17:39:47.831-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><title type='text'>Getting Active Directory</title><content type='html'>With this simple trick you can get the current active directory. Declare the Win32 API modul on &lt;span style="font-weight: bold;"&gt;Declare -&gt; Local External Functions&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;Function boolean GetCurrentDirectoryA (long nBufferLength, ref string lpBuffer) Library "kernel32.dll"&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Write this code:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;string ls_temp&lt;br /&gt;ulong lul_value&lt;br /&gt;boolean lb_rc&lt;br /&gt;&lt;br /&gt;lul_value = 255&lt;br /&gt;ls_temp = space(255)&lt;br /&gt;lb_rc = GetCurrentDirectoryA (lul_value, ls_temp)&lt;br /&gt;If lb_rc Then MessageBox('Current Directory', ls_temp, information!)&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-6977701138127386439?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/6977701138127386439'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/6977701138127386439'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/getting-active-directory.html' title='Getting Active Directory'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-2542958526511717964</id><published>2008-01-23T17:20:00.000-08:00</published><updated>2008-01-23T17:40:11.616-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><title type='text'>Getting Computer Name</title><content type='html'>You can get the computer name from within the application. Declare the Win32 API modul on &lt;span style="font-weight: bold;"&gt;Declare -&gt; Local External Functions&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;Function boolean GetComputerNameA (ref string lpBuffer, ref ulong nSize) Library "kernel32.dll"&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Now write this code:&lt;br /&gt;&lt;pre&gt;&lt;code&gt;string ls_temp&lt;br /&gt;ulong lul_value&lt;br /&gt;boolean lb_rc&lt;br /&gt;&lt;br /&gt;lul_value = 255&lt;br /&gt;ls_temp = space(255)&lt;br /&gt;lb_rc = GetComputerNameA (ls_temp, lul_value)&lt;br /&gt;messageBox ('Computer Name', ls_temp, information!)&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-2542958526511717964?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/2542958526511717964'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/2542958526511717964'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/getting-computer-name.html' title='Getting Computer Name'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-645704301363718213</id><published>2008-01-23T16:58:00.000-08:00</published><updated>2008-01-23T17:14:36.061-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PowerScript'/><category scheme='http://www.blogger.com/atom/ns#' term='Win32 API'/><title type='text'>Sending Key Press</title><content type='html'>With this tips, you can make a control likely pressing (a) key(s). First declare the Win32 API modul on &lt;span style="font-weight: bold;"&gt;Declare -&gt; Local External Functions&lt;/span&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;Subroutine keybd_event( int bVk, int bScan, int dwFlags, int dwExtraInfo) Library "user32.dll"&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Next is an example to simulate pressing "A" key&lt;br /&gt;&lt;pre&gt;&lt;code&gt;integer li_vkey&lt;br /&gt;li_vkey = 65 // Character A&lt;br /&gt;sle_1.setfocus() // the desired control to view&lt;br /&gt;keybd_event( li_vkey, 1, 0, 0)&lt;/code&gt;&lt;/pre&gt;&lt;br /&gt;Another example to simulate "Backspace" key&lt;br /&gt;&lt;pre&gt;&lt;code&gt;integer li_vkey&lt;br /&gt;integer li_pos&lt;br /&gt;li_pos = len(sle_1.Text) + 1&lt;br /&gt;sle_1.selectText(li_pos, 0)// Cursor position on last text&lt;br /&gt;li_vkey = asc ("~b") // backspace&lt;br /&gt;keybd_event( li_vkey, 1, 0, 0)&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-645704301363718213?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/645704301363718213'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/645704301363718213'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/sending-key-press.html' title='Sending Key Press'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-3969782754767645356</id><published>2008-01-23T16:44:00.000-08:00</published><updated>2008-01-23T16:50:43.968-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PowerScript'/><title type='text'>Sending Hexadecimal Character to Printer</title><content type='html'>When using several types of printer for a special purpose, sometime we have to send hexadecimal character to control the printer and to by pass the printer driver.&lt;br /&gt;The example is shown below&lt;br /&gt;&lt;pre&gt;&lt;code&gt;int li_job&lt;br /&gt;li_job = PrintOpen()&lt;br /&gt;// Print Mode&lt;br /&gt;PrintText ( li_job, "~h1B~h21~001", 0, 0)&lt;br /&gt;// Spacing&lt;br /&gt;PrintText ( li_job, "~h1B~h33~001", 0, 0)&lt;br /&gt;PrintClose ( li_job )&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-3969782754767645356?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/3969782754767645356'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/3969782754767645356'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/sending-hexadecimal-character-to.html' title='Sending Hexadecimal Character to Printer'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-6112202697746919630</id><published>2008-01-23T16:33:00.000-08:00</published><updated>2008-01-23T16:38:32.314-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PowerScript'/><title type='text'>Calling an Internet Browser from Application</title><content type='html'>From PowerBuilder application, we can call (open) the default internet browser, as well as setting the default home page for the browser&lt;br /&gt;&lt;pre&gt;&lt;code&gt;Inet linet_base&lt;br /&gt;GetContextService("Internet", linet_base)&lt;br /&gt;linet_base.HyperlinkToURL("http://...")&lt;br /&gt;If IsValid(linet_base) Then Destroy linet_base&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-6112202697746919630?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/6112202697746919630'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/6112202697746919630'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/calling-internet-browser-from.html' title='Calling an Internet Browser from Application'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-305743585578586831</id><published>2008-01-23T04:21:00.001-08:00</published><updated>2008-01-23T16:27:05.982-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PowerScript'/><title type='text'>Getting Date Format from Windows Registry</title><content type='html'>By getting the date format from the Windows registry, we can use it for various need when you build a PowerBuilder application&lt;br /&gt;&lt;pre&gt;&lt;code&gt;RegistryGet("HKEY_CURRENT_USER\Control Panel\International","sShortDate", ls_shortdate&lt;br /&gt;messageBox ("ShortDate", ls_shortdate)&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-305743585578586831?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/305743585578586831'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/305743585578586831'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/getting-date-format-from-windows.html' title='Getting Date Format from Windows Registry'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-9199477529536051532</id><published>2008-01-23T03:48:00.000-08:00</published><updated>2008-01-23T16:24:05.249-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PowerScript'/><title type='text'>Return Code on Application Exit</title><content type='html'>Sometime when a PowerBuilder application is called by other program or a shell script, programmer want a return code after exiting the PowerBuilder application, just to get the status of the application called.&lt;br /&gt;&lt;br /&gt;To give a return code, simply set the &lt;span style="font-weight: bold;"&gt;Message.LongParm&lt;/span&gt; property on the &lt;span style="font-weight: bold;"&gt;close&lt;/span&gt; event of the &lt;span style="font-weight: bold;"&gt;Application&lt;/span&gt; object with the desirable value.&lt;br /&gt;&lt;pre&gt;&lt;code&gt;   If ib_endingOK then&lt;br /&gt;       Message.LongParm = 1&lt;br /&gt;   Else&lt;br /&gt;       Message.LongParm = 0&lt;br /&gt;   End If&lt;/code&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-9199477529536051532?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/9199477529536051532'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/9199477529536051532'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/return-code-on-application-exit.html' title='Return Code on Application Exit'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-1261092685085766323</id><published>2008-01-19T03:42:00.000-08:00</published><updated>2008-04-02T21:10:44.939-07:00</updated><title type='text'>Sitemap</title><content type='html'>Sitemap :&lt;br /&gt;&lt;ul id="Feed1_feedItemListDisplay"&gt;&lt;li&gt;&lt;span class="item-title"&gt;&lt;/span&gt;&lt;a href="http://power-builder.blogspot.com/2008/01/if-statements-using-sql.html"&gt; If Statements Using SQL&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://power-builder.blogspot.com/2008/01/run-application-only-once.html"&gt;Run an Application Only Once&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://power-builder.blogspot.com/2008/01/cc-datatype-conversion.html"&gt;C/C++ Datatype Conversion&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://power-builder.blogspot.com/2008/01/registering-ocx-components-in-exe.html"&gt;Registering OCX Components in an Exe&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://power-builder.blogspot.com/2008/01/get-name-of-network-share.html"&gt;Get The Name of a Network Drive&lt;/a&gt;&lt;br /&gt;&lt;span class="item-title"&gt; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="item-title"&gt;&lt;a href="http://power-builder.blogspot.com/2008/01/mapping-network-drive.html"&gt; Mapping a Network Drive &lt;/a&gt; &lt;/span&gt; &lt;/li&gt;&lt;li&gt; &lt;span class="item-title"&gt; &lt;a href="http://power-builder.blogspot.com/2008/01/getting-active-directory.html"&gt; Getting Active Directory &lt;/a&gt; &lt;/span&gt; &lt;/li&gt;&lt;li&gt;&lt;a href="http://power-builder.blogspot.com/2008/01/getting-active-directory.html"&gt; Getting Active Directory&lt;/a&gt; &lt;span class="item-title"&gt; &lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class="item-title"&gt;&lt;a href="http://power-builder.blogspot.com/2008/01/getting-computer-name.html"&gt; Getting Computer Name &lt;/a&gt; &lt;/span&gt; &lt;/li&gt;&lt;li&gt; &lt;span class="item-title"&gt; &lt;a href="http://power-builder.blogspot.com/2008/01/sending-key-press.html"&gt; Sending Key Press &lt;/a&gt; &lt;/span&gt; &lt;/li&gt;&lt;li&gt; &lt;span class="item-title"&gt; &lt;a href="http://power-builder.blogspot.com/2008/01/sending-hexadecimal-character-to.html"&gt; Sending Hexadecimal Character to Printer &lt;/a&gt; &lt;/span&gt; &lt;/li&gt;&lt;li&gt; &lt;span class="item-title"&gt; &lt;a href="http://power-builder.blogspot.com/2008/01/calling-internet-browser-from.html"&gt; Calling an Internet Browser from Application &lt;/a&gt; &lt;/span&gt; &lt;/li&gt;&lt;li&gt; &lt;span class="item-title"&gt; &lt;a href="http://power-builder.blogspot.com/2008/01/getting-date-format-from-windows.html"&gt; Getting Date Format from Windows Registry &lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://power-builder.blogspot.com/2008/01/return-code-on-application-exit.html"&gt;&lt;span class="item-title"&gt;Return Code on Application Exit&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;Friend's Blog:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://oracletipstricks.blogspot.com/"&gt;Oracle Tips &amp;amp; Tricks&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://misterpopo.wordpress.com/"&gt;Misterpopo Blog&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://direktoriinfokerja.blogspot.com/"&gt;Indonesian Career Information Directory&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://thelegendavatar.blogspot.com/"&gt;Avatar Fansite&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://www.info-karir.com/"&gt;Info Karir&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-1261092685085766323?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/1261092685085766323'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/1261092685085766323'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/01/sitemap.html' title='Sitemap'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-1441221853004571308.post-2753238969833382421</id><published>2008-01-18T21:15:00.000-08:00</published><updated>2009-03-15T17:01:35.828-07:00</updated><title type='text'>Privacy Policy</title><content type='html'>&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Privacy Policy&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;If you require any more information or have any questions about our privacy policy, please feel free to contact us by email at sprpopo@yahoo.com.&lt;br /&gt;&lt;br /&gt;At power-builder.blogspot.com, the privacy of our visitors is of extreme importance to us. This privacy policy document outlines the types of personal information is received and collected by power-builder.blogspot.com and how it is used.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Log Files&lt;/span&gt;&lt;br /&gt;Like many other Web sites, power-builder.blogspot.com makes use of log files. The information inside the log files includes internet protocol ( IP ) addresses, type of browser, Internet Service Provider ( ISP ), date/time stamp, referring/exit pages, and number of clicks to analyze trends, administer the site, track user’s movement around the site, and gather demographic information. IP addresses, and other such information are not linked to any information that is personally identifiable.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Cookies and Web Beacons&lt;/span&gt;&lt;br /&gt;power-builder.blogspot.com does use cookies to store information about visitors preferences, record user-specific information on which pages the user access or visit, customize Web page content based on visitors browser type or other information that the visitor sends via their browser.&lt;br /&gt;&lt;br /&gt;Some of our advertising partners may use cookies and web beacons on our site. Our advertising partners include Google Adsense, .&lt;br /&gt;&lt;br /&gt;PowerBuilder Tips &amp;amp; Tricks utilizes certain services from Google for ad serving and web traffic analysis. Please review Google's &lt;a href="http://www.google.com/privacy.html"&gt;privacy policy&lt;/a&gt; for more information on how Google AdSense and Google Analytics stores your personal information. These Google servies may place and read cookies on your browser, or use web beacons to collect information, in the course of ads being served on the PowerBuilder Tips &amp;amp; Tricks website. Additionally, Google uses the DART cookie to enables it to serve ads to based on your visits to PowerBuilder Tips &amp;amp; Tricks and other sites on the Internet. You may opt out of the use of the DART cookie by visiting the &lt;a href="http://www.google.com/privacy_ads.html"&gt;Google ad and content network privacy policy&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;These third-party ad servers or ad networks use technology to the advertisements and links that appear on power-builder.blogspot.com send directly to your browsers. They automatically receive your IP address when this occurs. Other technologies ( such as cookies, JavaScript, or Web Beacons ) may also be used by the third-party ad networks to measure the effectiveness of their advertisements and / or to personalize the advertising content that you see.&lt;br /&gt;&lt;br /&gt;power-builder.blogspot.com has no access to or control over these cookies that are used by third-party advertisers.&lt;br /&gt;&lt;br /&gt;You should consult the respective privacy policies of these third-party ad servers for more detailed information on their practices as well as for instructions about how to opt-out of certain practices. power-builder.blogspot.com's privacy policy does not apply to, and we cannot control the activities of, such other advertisers or web sites.&lt;br /&gt;&lt;br /&gt;If you wish to disable cookies, you may do so through your individual browser options. More detailed information about cookie management with specific web browsers can be found at the browsers' respective websites.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1441221853004571308-2753238969833382421?l=power-builder.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/2753238969833382421'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1441221853004571308/posts/default/2753238969833382421'/><link rel='alternate' type='text/html' href='http://power-builder.blogspot.com/2008/03/privacy-policy.html' title='Privacy Policy'/><author><name>popo</name><uri>http://www.blogger.com/profile/16237649873018882101</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry></feed>
