Array y Bitmaps en MEMO

Post Reply
antolin
Posts: 498
Joined: Thu May 10, 2007 8:30 pm
Location: Sevilla

Array y Bitmaps en MEMO

Post by antolin »

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: Select all | Expand


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: Select all | Expand

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
User avatar
Antonio Linares
Site Admin
Posts: 42660
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Has thanked: 69 times
Been thanked: 96 times
Contact:

Re: Array y Bitmaps en MEMO

Post by Antonio Linares »

Antolín,

gracias por compartirlo :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
antolin
Posts: 498
Joined: Thu May 10, 2007 8:30 pm
Location: Sevilla

Re: Array y Bitmaps en MEMO

Post by antolin »

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: Select all | Expand

IF IsArray( Left( Filed->Memo, 25 ) ) > 0
   aDat := ARead( Filed->Memo )
ENDF

Un saludo.
Peaaaaaso de foro...
FWH 2007 - xHarbour - BCC55
Post Reply