[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

To further refine an external function.

Posted on 2006-05-30
8
Medium Priority
?
303 Views
Last Modified: 2013-12-26
PB7

The exported version of the function is

$PBExportHeader$f_checkrequired2.srf
$PBExportComments$Checks that all required columns in a DataWindow control are filled in
global type f_checkrequired2 from function_object
end type

forward prototypes
global function boolean f_checkrequired2 (datawindow adw_control)
end prototypes

global function boolean f_checkrequired2 (datawindow adw_control);integer li_colnbr = 1
long ll_row = 1
string ls_colname, ls_textname

IF adw_control.AcceptText() = -1 THEN
      adw_control.SetFocus()
      RETURN false
END IF

IF adw_control.FindRequired( primary!, ll_row, li_colnbr, ls_colname, false ) < 1 THEN
      RETURN false
END IF

IF ll_row <> 0 THEN

      // Get the text of that column's label.

      ls_textname = ls_colname + "_t.Text"
      ls_colname = adw_control.Describe(ls_textname)

      // Tell the user which column to fill in.

      Beep (1)

      MessageBox("Required Value Missing","Please enter a value for '" + ls_colname , exclamation!)

      // Make the problem column current.

      adw_control.SetColumn(li_colnbr)
      adw_control.ScrollToRow(ll_row)
      adw_control.SetFocus()
      RETURN false

END IF


RETURN true
end function
==============================================


The above function works well for all physical columns of a  datawindow.

What do I mean by non physical column
---------------------------------------------

Suppose I have made a drop down datawindow "dddw_x" with this sql select
"select colour_code, colour_name from colour"

The actual datawindow say dw_trans only have column colour_code. ( It does not have column colour_name)
What I do Is , I copy the column colour_code and rename the copied column as 'colour_name', then I associate the drop down datawindow "dddw_x" on that column. Hence

colour_code is physical
colour_name is virtual

When the above function is run , colour_code and colour_name both being null, (on both required option is on), the function will detect that colour code is required , and set the focus on column code, so that the user can enter any value.

The problem is, it is easier to enter value via colour_name , but the function will not let go to colour_name untill colour_code is filled.

What I want is, that , in such case , the user should be able to fill value by colour name also.

 

 
0
Comment
Question by:Mateen
  • 4
  • 3
8 Comments
 
LVL 18

Expert Comment

by:diasroshan
ID: 16789691
Hi,

what u can do is in open event have the following script...
dw_1.Object.color_code.Edit.Required = "no"


and just  before u call ur function to check for required values write,
dw_1.Object.color_code.Edit.Required = "yes"

so what will happen is it will b treated as a required field when the function fires and prompt if found null...


Cheers,
Rosh
0
 
LVL 14

Expert Comment

by:sandeep_patel
ID: 16795994
Hi,

why you need column color_name ?
what happens here is both physical and virtual column name is different but their dbname is same. So there is no meaning of copying the column and renaming it. Still if you want column color_name and color_code in your datawindow, go to sql and add computed column or you can change your sql like

select  trans_no , tran_date, color_code as color_code, color_code as color_name from transaction_detail ;

in your dw_trans sql syntax.

Regards,
Sandeep
0
 

Author Comment

by:Mateen
ID: 16797202
Hi sandeep

<<there is no meaning of copying the column and renaming it.>>

But I am doing this in hundreds of windows for displaying child datawindow.  I think I should say child datawindow and should not say drop down data window.

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:Mateen
ID: 16797231
Hi diaroshan

<<dw_1.Object.color_code.Edit.Required = "yes">>

I want things to be dynamic.

Do u rember

http://www.experts-exchange.com/Programming/Programming_Languages/PowerBuilder/Q_21435846.html

That was a great achievement.

I feel, this is similar a case.
0
 
LVL 18

Expert Comment

by:diasroshan
ID: 16797392
Hi,

guess u cant do this dynamically... ull have to write code in each window coz there is no way to ascertain which column u want to ignore and then validate later...

Cheers,
Rosh
0
 

Author Comment

by:Mateen
ID: 16830714
<<guess u cant do this dynamically... ull have to write code in each window coz there is no way to ascertain which column u want to ignore and then validate later...>>

Agreed.

Could we go for a workaround.

1) Findrequired should work as u suggest.
2) Before running findrequired function , I can run, for validation purpose, another user defined function, say
    wf_check_null_child_dw.


 wf_check_null_child_dw: Is it possible to create a function which would find all child datawindow in a datawindow control. IN OUR CASE, it could be made simple by finding a column name whoose dbname differs. etc.
0
 
LVL 18

Accepted Solution

by:
diasroshan earned 2000 total points
ID: 16831445
Hi,

mateen... uve got the idea urself... :)
i am not creating a function for u but giving a basic code which might give u help to try this urself...

create a function... u can pass DW to it and loop thru it to search which column is a DDDW and check if its column name differs from the dbname...
u can use the code below... just written it here... DIDNT TEST IT MYSELF... use it as a help for u...


Long     ll_count
string   ls_style,ls_colname, ls_colname2

//dw_1 is ur passed value to the function
For ll_count = 1 to Long(dw_1.object.datawindow.column.count)
     ls_style = dw_1.describe('#'+string(ll_count)+".edit.style")
     if ls_style = 'dddw' then
      ls_colname  =  dw_1.Describe('#'+string(ll_count)+".name")
      ls_colname2=  dw_1.Describe(ls_colname + ".dbName")
      point_position = pos(ls_colname2,'.')
      ls_colname=mid(ls_colname2,point_position+1) //coz dbname will b with table name

      If ls_colname <> ls_colname2 Then
                    //write ur logic here...
      End If
     End If      
Next

Cheers,
Rosh
0
 

Author Comment

by:Mateen
ID: 16831567
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
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: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses
Course of the Month20 days, 14 hours left to enroll

810 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