FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour searching a text into an array
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

searching a text into an array

Posted: Sat Jun 04, 2016 05: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 March-April 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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM

Re: searching a text into an array

Posted: Sat Jun 04, 2016 05: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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: searching a text into an array

Posted: Sat Jun 04, 2016 10:28 PM

text

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM

Re: searching a text into an array

Posted: 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 (fw): Select all Collapse
 //AScan( aTags, {|a| a == cText } } )  // not

if !Empty( Ascan( aTags, cText ) )
   MsgInfo("Exist")
else
   Add( aTags, cText )
endif
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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: searching a text into an array

Posted: Sun Jun 05, 2016 08: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 March-April 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
Posts: 1054
Joined: Sun Oct 09, 2005 10:41 PM

Re: searching a text into an array

Posted: Mon Jun 06, 2016 02:22 PM
Prueba esto:

Code (fw): Select all Collapse
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
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM

Re: searching a text into an array

Posted: Mon Jun 06, 2016 03: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 March-April 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

Continue the discussion