powerbuilder initialize values

Posted on 2009-04-08
Last Modified: 2013-12-26
i want to create a function(lets call it initialize)  that will receive a data window as input (dw_imp)  and act as follows

all numeric fields of dw_imp  should be equal to 0
all string fields should be equal to '' (empty)
Question by:basilhs_s
  • 3
LVL 18

Accepted Solution

diasroshan earned 500 total points
ID: 24104985

Import the attached function.
Save the below contents in notepad and save as f_update_dw.srf
Import it into ur pbl.

From ur code call the function as


global type f_update_dw from function_object

end type

forward prototypes

global subroutine f_update_dw (datawindow arg_dw)

end prototypes

global subroutine f_update_dw (datawindow arg_dw);Long ll_ColCount,ll_ColNo, i

String ls_ColType, ls_ColName

For i = 1 to arg_Dw.RowCount()

	ll_ColCount = Long(arg_dw.Describe("Datawindow.Column.Count"))

	For ll_ColNo = 1 To ll_ColCount

		ls_ColType = arg_dw.Describe("#"+String(ll_ColNo)+".ColType")

		ls_ColName = arg_dw.Describe("#"+String(ll_ColNo)+".Name")

		Choose Case Upper(Mid(ls_Coltype,1,4))

			Case "CHAR"

				arg_dw.SetItem ( i, ls_ColName, '' )

			Case "DECI"	

				arg_dw.SetItem ( i, ls_ColName, 0 )

		End Choose	



end subroutine

Open in new window

LVL 14

Expert Comment

ID: 24107466
If you are not creating your datawindow dynamically then it would be better if you give Initial Value while designing the datawindow. Hence for any new row in datawindow will have the default value.

open datawindow > from menu.. view > column specifications > set 'Initial Value'


Author Comment

ID: 24110521
thanks Rosh. i will let you know if it is working

Author Comment

ID: 24111741
Sandeep thanks for your reply. i know it but in many cases we used datawindows with a lage number of fields and we forget sometimes to give initial values to some of them

Author Closing Comment

ID: 31568173
i just tried it. it works perfectly.thanks

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Android Studio - Gradle project sync failed 5 3,054
What xml editor to use. 8 84
java. non-English characters encoding problem. intellij idea 3 74
Online file editor, manager 6 62
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now