Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'bi 0.03
- 'Binary Data Module
- 'Blitz Basic Source Code
- 'Copyright Wednesday, November 14th 2007 - July 3rd 2013 Timothy Robert Keal
- 'requires (none)
- 'string to pointer
- Function bi_sp(value as string) as ptr
- value=ucase(value)
- dim as ptr ptr1=CreateBank(Len(value))
- dim as long offset=0
- do while offset<BankSize(ptr1)
- PokeByte ptr1,offset,bi_a(Asc(Mid(value,offset+1,1)))
- offset=offset+1
- loop
- Return ptr1
- End Function
- 'transcode ascii char
- Function bi_a(ascii as long) as long
- If ascii>=48 And ascii<=57 Then
- Return ascii-48
- ElseIf ascii>=65 And ascii<=90 Then
- Return ascii-55
- ElseIf ascii>=97 And ascii<=122 Then
- Return ascii-87
- ElseIf ascii=46 Then
- Return 36
- Else
- Return 37
- EndIf
- End Function
- 'int to float
- Function bi_if(value as long) as double
- dim as ptr temp=CreateBank(&H4)
- PokeInt temp,0,value
- dim as double ret=PeekFloat(temp,0)
- FreeBank temp
- Return ret
- End Function
- 'float to int
- Function bi_fi(value as double) as ptr
- dim as ptr temp=CreateBank(&H4)
- PokeFloat temp,0,value
- dim as ptr ret=PeekInt(temp,0)
- FreeBank temp
- Return ret
- End Function
Add Comment
Please, Sign In to add comment