Value conversion
Posted: Mon Sep 29, 2008 9:29 pm
I have some code (coverted from another language to convert from long ints to strings and back again (also floats) ), in the other language the value comes through perfectly but in PB the 0 values get stripped is there any way to stop it from doing that.
Heres the code:
Heres the code:
Code: Select all
;-------------------------------------------------------------------------------------------------------------------
Procedure.f StrToFloat( Value.s )
;converts a string (4 bytes ) to float
Static ReturnValue.f = 0
PokeS( *ConversionBuffer, Value, 4 )
ReturnValue = PeekF( *ConversionBuffer )
FreeMemory( *ConversionBuffer )
ProcedureReturn ReturnValue
EndProcedure
;-------------------------------------------------------------------------------------------------------------------
Procedure.s FloatToStr( Value.f )
;converts a float to a string
PokeF( *ConversionBuffer, Value )
ProcedureReturn PeekS( *ConversionBuffer, 4 )
EndProcedure
;-------------------------------------------------------------------------------------------------------------------
Procedure.l StrToInt( Value.s )
;converts from String (4 byte) to Long
PokeS( *ConversionBuffer, Value, 4 )
ProcedureReturn PeekL( *ConversionBuffer )
EndProcedure
;-------------------------------------------------------------------------------------------------------------------
Procedure.s IntToStr( Value.l )
;converts from Long to String
PokeL( *ConversionBuffer, Value )
ProcedureReturn PeekS( *ConversionBuffer, 4 )
EndProcedure