searching a text into an array

searching a text into an array

Postby Silvio.Falconi » Sat Jun 04, 2016 5:19 pm

I must control if a text is allready on an array and I use the function a scan
but I have an error

sample :
cText := alltrim(cu->last) the text to found on array

IF AScan( aTags, {|a| (a[1]) == cText } ) <--- where is the error
Msginfo("allready exist into list")
Endif
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7034
Joined: Thu Oct 18, 2012 7:17 pm

Re: searching a text into an array

Postby cnavarro » Sat Jun 04, 2016 5:35 pm

What error?
What format is the array, each element in another array?
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: searching a text into an array

Postby Silvio.Falconi » Sat Jun 04, 2016 10:28 pm

text
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7034
Joined: Thu Oct 18, 2012 7:17 pm

Re: searching a text into an array

Postby cnavarro » Sat Jun 04, 2016 11:13 pm

Silvio.Falconi wrote:I must control if a text is allready on an array and I use the function a scan
but I have an error

sample :
cText := alltrim(cu->last) the text to found on array

IF AScan( aTags, {|a| (a[1]) == cText } ) <--- where is the error
Msginfo("allready exist into list")
Endif


Silvio
If each element not is an array

Code: Select all  Expand view


 //AScan( aTags, {|a| a == cText } } )  // not

if !Empty( Ascan( aTags, cText ) )
   MsgInfo("Exist")
else
   Add( aTags, cText )
endif
 
Last edited by cnavarro on Sun Jun 05, 2016 10:19 am, edited 1 time in total.
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6541
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: searching a text into an array

Postby Silvio.Falconi » Sun Jun 05, 2016 8:57 am

on control (ttags) I have an array

aTagstemp:= oControl;getItems() // this give me an array with all elements of array of the control
ctext:="silvio" // new element text to insert on this array

If AScan( aTagsTemp, {|a| a == cText } ) =1 <--- not run ok
Msginfo("it is allready exist on list")
else
oControl:AddItem( ctext )
Endif
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7034
Joined: Thu Oct 18, 2012 7:17 pm

Re: searching a text into an array

Postby Willi Quintana » Mon Jun 06, 2016 2:22 pm

Prueba esto:

Code: Select all  Expand view

nPos := 0
nPos := AScan( aTagsTemp, {|a| a == cText } )
If nPos > 0
 Msginfo("it is allready exist on list in  " + STR(nPos,2,0) +  " position")
 else
 oControl:AddItem( ctext )
Endif
 
User avatar
Willi Quintana
 
Posts: 1019
Joined: Sun Oct 09, 2005 10:41 pm
Location: Cusco - Perú

Re: searching a text into an array

Postby Silvio.Falconi » Mon Jun 06, 2016 3:57 pm

sORRY i RESOLVED BECAUSE THERE WAS AN ERROR ON CLASS
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7034
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 104 guests