FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Array y Bitmaps en MEMO
Posts: 498
Joined: Thu May 10, 2007 08:30 PM
Array y Bitmaps en MEMO
Posted: Thu Oct 10, 2013 02:36 PM
Hola foreros.

Tengo la constumbre de guardar Arrays en campos MEMO con ASave( aVar ), que despu茅s recupero con ARead(). A veces tambien guardo peque帽os bitmaps cargados con MEMOREAD(). El problema me surgi贸 a la hora de leer dichos campos MEMO. Para saber si guardo un array o un bitmap en formato texto he implementado estas peque帽as funciones en Borland C:

La funci贸n IsArray( cTexto ) devuelve 1 si cTexto representa una Array vacio, 2 si es un Array NO vacio y 0 en los dem谩s casos.
La funci贸n IsBmp( cTexto ) devuelve 1 si cTexto representa un Bitmap o 0 si no.
Code (fw): Select all Collapse
HB_FUNC( ISARRAY ) 聽 // IsArray( cText)
聽 聽{
聽 聽LPSTR cTxt = _parc( 1 ) ;
聽 聽int nRet = 0 ;

聽 聽if ( cTxt && cTxt[0] == 'A' && cTxt[4] == 0 ) 聽 // POSIBLE ARRAY
聽 聽 聽 {
聽 聽 聽 if ( cTxt[2] == 0 && cTxt[3] == 0 ) 聽 // ARRAY VACIO -> {}
聽 聽 聽 聽 聽{
聽 聽 聽 聽 聽nRet = 1 ;
聽 聽 聽 聽 聽}
聽 聽 聽 else if ( cTxt[7] == 0 ) 聽 聽// ARRAY CON CONTENIDO -> {1,2,...}
聽 聽 聽 聽 聽{
聽 聽 聽 聽 聽nRet = 2 ;
聽 聽 聽 聽 聽}
聽 聽 聽 }

聽 聽hb_retni( nRet ) ;
聽 聽}


Code (fw): Select all Collapse
HB_FUNC( ISBMP ) 聽 / IsBmp( cTxt )
聽 聽{
聽 聽LPSTR cTxt = _parc( 1 ) ;
聽 聽int nRet = 0 ;

   if ( cTxt && cTxt[0] == 'B' && cTxt[1] == 'M' && cTxt[9] == 0 && cTxt[14] == 40 )
聽 聽 聽 {
聽 聽 聽 nRet = 1 ;
聽 聽 聽 }

聽 聽hb_retni( nRet ) ;
聽 聽}


Es posible que alguna funci贸n confunda alg煤n tipo de datos con un array o un bitmap formato texto, pero hasta ahora esta funci贸n no se ha equivocado.

Espero os sea de utilidad.

Saludos.
Peaaaaaso de foro...

FWH 2007 - xHarbour - BCC55
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Array y Bitmaps en MEMO
Posted: Sat Oct 12, 2013 08:07 AM

Antol铆n,

gracias por compartirlo :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 498
Joined: Thu May 10, 2007 08:30 PM
Re: Array y Bitmaps en MEMO
Posted: Mon Oct 21, 2013 10:47 AM
Por cierto, si vuestro array o bitmap en formato caracter es muy largo, no es necesario mandarlo entero a su respestiva funcion (que puede enlentecer el programa) con mandar Left(xDat,25) es suficiente.

Por ejemplo:
Code (fw): Select all Collapse
IF IsArray( Left( Filed->Memo, 25 ) ) > 0
聽 聽aDat := ARead( Filed->Memo )
ENDF

Un saludo.
Peaaaaaso de foro...

FWH 2007 - xHarbour - BCC55

Continue the discussion