Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need to decode this into VFP
Message
De
15/12/2009 20:54:10
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
Divers
Thread ID:
01439276
Message ID:
01439281
Vues:
124
>I would like to translate this code into foxpro, or find a better way. I have been working on it for some time now and have hit a wall. Any ideas?
>
>
>Function Decode_LoopData (Value As String) As Integer
>
>    'Decode raw data bytes from "loop" command to numeric value
>' NOTE
>' Low bit is left char in value
>' High bit is right char in value
>
>If Len(Value) = 1 Then
>     Decode_LoopData = Val("&H" + Hex$(Asc(Value)))
>ElseIf Len(Value) = 2 Then
>    temp% = Asc(Left$((Value), 1))
>    If temp% < 16 Then
>	Decode_LoopData = Val("&H" + Hex$(Asc(Right$(Value, 1))) + "0" + Hex$(temp%))
>    Else
>	Decode_LoopData = Val("&H" + Hex$(Asc(Right$(Value, 1))) + Hex$(temp%))
>    End If
>    
>End If  
>
>
Rough first shot:
Function (Decode_LoopData as string) 
   do case
      case len(value)=1
            lnResult=asc(value)
      case len(value)=2
         temp=asc(value)
         if temp<16
            lnResult=temp*16
         else
            lnResult=asc(value)*256+asc(substr(value,2))
         endif
      otherwise
         lnResult=null
endcase
return lnResult
The code was unnecessarily complicated - conversion to hex serves no purpose at all.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform