> Le 6 mars 2017 à 21:18, truegold via 4D_Tech <[email protected]> a écrit :
>
> Hi Arnaud,
>
> Funny, I just got asked about this on Friday.
>
> I would also be interested to know the bets way to handle older (I think
> they’re all from v12) Query files.
I just translated some comments, and, again, I never ended the job. HTH…
//chercher_blob2arrays (->tableRech;->blobRequete) -> error
//fills 5 arrays with a blob from a search document
C_TEXT($0) //error
C_POINTER($1;$table_p) //->table to query
C_POINTER($2) //->blob query
C_BLOB($requete_x)
C_LONGINT($i)
C_LONGINT($reqNbreLignes_l)
C_LONGINT($numChamp_l)
C_LONGINT($numTable_l)
C_LONGINT($blobReqOffset_l)
C_LONGINT($offsetLigneRequete_l)
C_TEXT($error_t)
C_TIME($hRef)
C_TEXT($valeur_t)
//_
$error_t:=""
Case of
: (Count parameters<2)
$error_t:="2 params"
: (Not(Ptr_isTable ($1)))
$error_t:="$1 ->table"
: (Not(Ptr_isBlob ($2)))
$error_t:="$1 ->blob"
Else
$error_t:=""
$table_p:=$1
$requete_x:=$2->
//v11 or before ?
If ($requete_x{0}=39) | ($requete_x{1}=15) //270F
$infoVersion_l:=11
$blobReqOffset_l:=2
$ligneReqLongueur_l:=270
Else
$infoVersion_l:=6
$blobReqOffset_l:=0
$ligneReqLongueur_l:=96
End if
$reqNbreLignes_l:=BLOB to integer($requete_x;Macintosh byte
ordering;$blobReqOffset_l)
If (False) //for debug
COPY BLOB($requete_x;$subBlob_x;$blobReqOffset_l;0;BLOB
size($requete_x)-4)
$txt:=xBlobEnOctets
($subBlob_x;"\t";$ligneReqLongueur_l)
SET TEXT TO PASTEBOARD($txt)
End if
//lecture des lignes de requête et copie en tableaux
For ($i;1;$reqNbreLignes_l)
//FIXER TAILLE BLOB($reqLigne_x;$ligneReqLongueur_l;0)
//extraction ligne $i
$start_l:=$blobReqOffset_l+(($i-1)*$ligneReqLongueur_l)
COPY
BLOB($requete_x;$reqLigne_x;$start_l;0;$ligneReqLongueur_l)
$offsetLigneRequete_l:=0
//field num - byte 0-1
$numChamp_l:=BLOB to integer($reqLigne_x;Macintosh byte
ordering;$offsetLigneRequete_l)
//table num - byte 2-3
$numTable_l:=BLOB to integer($reqLigne_x;Macintosh byte
ordering;$offsetLigneRequete_l)
If ($numTable_l=0) //possible car 4D ne stocke pas
forcément la table si differente de celle de la recherche
$numTable_l:=Table($table_p)
End if
//comparison - byte 4
$codeComparateur_l:=$reqLigne_x{4}
//field type - byte 6
$type_l:=$reqLigne_x{6}
//value depending on firld type - byte 8, except alpha
$offsetLigneRequete_l:=8 //for most types
Case of
: ($type_l=Is alpha field) | ($type_l=Is text)
| ($type_l=Is string var)
$lLongueurChaine:=$reqLigne_x{10}
$offsetLigneRequete_l:=11
$valeur_t:=BLOB to text($reqLigne_x;Mac
text without length;$offsetLigneRequete_l;$lLongueurChaine)
: ($type_l=Is integer)
$offsetLigneRequete_l:=8
$valeur_t:=String(BLOB to
integer($reqLigne_x;Macintosh byte ordering;$offsetLigneRequete_l))
: ($type_l=Is longint)
$valeur_t:=String(BLOB to
longint($reqLigne_x;Macintosh byte ordering;$offsetLigneRequete_l))
: ($type_l=Is date)
$lJour:=BLOB to
integer($reqLigne_x;Macintosh byte ordering;$offsetLigneRequete_l)
$lMois:=BLOB to
integer($reqLigne_x;Macintosh byte ordering;$offsetLigneRequete_l)
$lAn:=BLOB to
integer($reqLigne_x;Macintosh byte ordering;$offsetLigneRequete_l)
$valeur_t:=String(Add to
date(!00-00-00!;$lAn;$lMois;$lJour))
: ($type_l=Is time)
$valeur_t:=String(Time(Time string(BLOB
to longint($reqLigne_x;Macintosh byte ordering;$offsetLigneRequete_l))))
: ($type_l=Is Boolean) // (0 false/1 true)
$valeur_t:=String(Num(BLOB to
integer($reqLigne_x;Macintosh byte ordering;$offsetLigneRequete_l)=1))
: ($type_l=Is real)
$valeur_t:=String(BLOB to
real($reqLigne_x;Macintosh byte ordering;$offsetLigneRequete_l))
Else
$valeur_t:=""
TRACE //unexpected field type
End case
//conjonction - byte 266 (and/or/except, more than
one line)
If ($infoVersion_l=11)
$conjonction_l:=$reqLigne_x{266}
Else
TRACE //offset before v11 not verified
$conjonction_l:=$reqLigne_x{94}
End if
If (True) //#NI ctrl field type in request # field
type in structure
$typeDiff_b:=True
Case of
: (Not(Is table number
valid($numTable_l)))
: (Not(Is field number
valid($numTable_l;$numChamp_l)))
:
(Type(Field($numTable_l;$numChamp_l)->)#$type_l)
Else
$typeDiff_b:=False
End case
End if
APPEND TO ARRAY(DR_Table_al;$numTable_l)
APPEND TO ARRAY(DR_Champ_al;$numChamp_l)
APPEND TO ARRAY(DR_Comparaison_al;$codeComparateur_l)
APPEND TO ARRAY(DR_Valeur_at;$valeur_t)
APPEND TO ARRAY(DR_Conjonction_al;$conjonction_l)
End for
End case
$0:=$error_t
//_
--
Arnaud de Montard
--
Arnaud de Montard
**********************************************************************
4D Internet Users Group (4D iNUG)
FAQ: http://lists.4d.com/faqnug.html
Archive: http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub: mailto:[email protected]
**********************************************************************