Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 10477
  • Last Modified:

Function Find in DATAWINDOW

sorry, my inglish is very poor. I Speak Spanish

Well

The problem is :

I have a DataWindow with any columns,  second column is the name and I want
find any name in the DataWindow.  I put the Single Line Edit and the Modify
Event Write this :

// Key_Pressed Script for sle_busca_nombre

long found_row, ll_largo

ll_largo = Len(sle_busca_nombre.text)

if Len(sle_busca_nombre.text) > 0 then       // Do case-insensitive search
      dw_1.SelectRow(0, FALSE)             // case-Sensitive search
      found_row = dw_1.Find("Pos(nombre_y_a, ~"" + sle_busca_nombre.text +
" )> 0 ~"", 1, 99999)

      // found_row = dw_1.Find("left(Lower(#2),ll_largo)= ~"" +
Lower(sle_busca_nombre.text) + "~"", 1, 99999)
     // found_row = dw_1.Find("Lower(#2) =~"" + Lower(sle_find.text) + "~"",
1, 99999)

     if found_row > 0 then
           dw_1.SetRow (found_row)
           dw_1.ScrollToRow(found_row)
           dw_1.SetRedraw(TRUE)
           dw_1.Show ()
     else // Filter function did not find any matching row
           Beep(3)
     end if

else  // Filter length is 0, so unhighlight former selected row
     dw_1.SelectRow(il_row, FALSE)
end if

il_row = found_row    // Remember number of highlighted row

**********************************************************

I try the find with other way (see comment line)  but the power send error
message when I'm use the Left o Pos function,  I like write part of the name and seek the name complet or the
firt name and so on.   THANKS for all.

0
pepe
Asked:
pepe
  • 10
  • 3
1 Solution
 
BhattiCommented:
Try with simple script:

string ls_searchstr
long ll_row

//sle (singleLineEdit control is text control you need not to write .text)

ls_searchstr = "Pos(nombre_y_a,  + sle_busca_nombre +  " )> 0"

ll_row  = dw_1.Find(ls_searchstr, 1, dw_1.RowCount())

Do the same with second Find function where you use the left and lower functions.

May be text.text is the error

Try it and please let me know.






0
 
BhattiCommented:
Sorry pepe,

I just thought another a wrote only the SingleLineedit name and the .text.
You need it to write .text  for the text inside the sle.

ls_searchstr = "Pos(nombre_y_a,  + sle_busca_nombre.text +  " )> 0"

other remain the same.
0
 
pepeAuthor Commented:
I wrote your code in the Single Line Edit Event (Modify) and Display the Error message in runtime (expecting String expression)

****************** Your code *********************
string ls_searchstr
long ll_row

//sle (singleLineEdit control is text control you need not to write .text)

ls_searchstr = "Pos(nombre_y_a,"  + sle_busca_nombre.text +  " )> 0"

ll_row  = dw_1.Find(ls_searchstr, 1, dw_1.RowCount())

if ll_row > 0 then
     dw_1.SetRow (ll_row)
     dw_1.ScrollToRow(ll_row)
     dw_1.SetRedraw(TRUE)

     dw_1.Show ()
     
else     // Filter function did not find any matching row
     Beep(3)
end if

*********************************
Is possible to be necessary a quote(")in this sentence [ls_searchstr = "Pos(nombre_y_a,  + sle_busca_nombre.text +  " )> 0" ]   Before the first plus ?
The correct  sentence is this ? [ls_searchstr = "Pos(nombre_y_a,"  + sle_busca_nombre.text +  " )> 0" ]
0
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!

 
BhattiCommented:
Hi pepe,

Sorry I did not checked the string:

I think it is so, this is the right syntex and you will get no error message.

look carefully and write in your script like this.

string ls_searchstring

ls_searchstring = "Pos(nombre_y_a,  ' "  + sle_busca_nombre.text    +  " ' "  + " ) > 0 "

ll_row  = dw_1.Find(ls_searchstr, 1, dw_1.RowCount())

if ll_row > 0 then
   dw_1.SetRow (ll_row)
   dw_1.ScrollToRow(ll_row)
   dw_1.SetRedraw(TRUE)
   dw_1.Show ()
                     
else     // Filter function did not find any matching row
    Beep(3)
 end if

I checked and it working. Please let me know THANKS
0
 
BhattiCommented:
Hallo Pepe,

Can you tell me that ls_searchstring working good and have no more error message.

THANKS
0
 
BhattiCommented:
I send you with change ls_string on 09.08.2001 07:35 AM PST.

ls_searchstring = "Pos(nombre_y_a,  ' "  + sle_busca_nombre.text    +  " ' "  + " ) > 0 "

Is it working good. Please let me know.

THANKS
0
 
pepeAuthor Commented:
Bhatti:
        Very very much, the function it's working ok. Thanks for your time.  keep in touch.

Regards,

Francisco Jose
0
 
BhattiCommented:
Hallo Francisco,

can you please grade this question?
What about Access Database Date Format Insert?


Bhatti
0
 
pepeAuthor Commented:
Bhatti :
          how are you ?  I'm try to insert in the Database Access but no more.  I'm puting the sentence so you give me :

******************************
DateTime  ldtm_hoy

ldtm_hoy = DateTime ( Today (), Now() )

INSERT INTO cuenta_corriente ( cuenta_corriente.fecha_inicio )
                        VALUES ( :ldtm_hoy ) ;

******************************
And the error message occurs.  I see when i save the Script, the PowerBuilder conecting to Database and the display error [SqlState]ODBC........

IF YOU KNOW ANY IDEA, PLEASE SAY ME.

Now I put the time in field type String and Date in field DateTime.

THANKS,  Francisco
0
 
BhattiCommented:
Sometimes datetime format is also with microseconds and I think you can also check by debuging the apllication (this script) and see the variable ldtm_hoy (format) and look also the format in the table.

******************************
  DateTime  ldtm_hoy

  ldtm_hoy = DateTime ( Today (), Now() )

  INSERT INTO cuenta_corriente ( fecha_inicio )
  VALUES ( :ldtm_hoy ) ;

******************************

How working the ODBC connection for other variables.
I think there must be format error or ODBC connection to Access error.

I was busy in changing some request in my project and got no time to write you. Write you tomarrow.
0
 
BhattiCommented:
Hallo Francisco,

Writing you the as answer that working ok as you wrote.


string ls_searchstring
long ll_row

ls_searchstring = "Pos(nombre_y_a,  ' "  + sle_busca_nombre.text    +  " ' "  + " ) > 0 "

ll_row  = dw_1.Find(ls_searchstr, 1, dw_1.RowCount())

if ll_row > 0 then
   dw_1.SetRow (ll_row)
   dw_1.ScrollToRow(ll_row)
   dw_1.SetRedraw(TRUE)
   dw_1.Show ()
                                         
else     // Filter function did not find any matching row
   Beep(3)
end if

I think it is working good as you wrote me that function is working ok.
0
 
BhattiCommented:
Hallo Francisco,


Can you please friendly grad my answer. THANKS


Bhatti
0
 
BhattiCommented:
Hi Francisco,

Merry Christmas and a happy new year !!!


Best regards


Bhatti
0
 
SpideyModCommented:
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 10
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now