Advertisement
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 Timothy Robert Keal
- ;requires (none)
- ;string to pointer
- Function bi_sp(value$)
- value=Upper(value)
- Local ptr=CreateBank(Len(value))
- Local offset=0
- Repeat
- If offset>=BankSize(ptr) Then Exit
- PokeByte ptr,offset,bi_a(Asc(Mid(value,offset+1,1)))
- offset=offset+1
- Forever
- Return ptr
- End Function
- ;transcode ascii char
- Function bi_a(ascii)
- 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)
- Local temp=CreateBank($4)
- PokeInt temp,0,value
- Local ret#=PeekFloat(temp,0)
- FreeBank temp
- Return ret
- End Function
- ;float to int
- Function bi_fi(value#)
- Local temp=CreateBank($4)
- PokeFloat temp,0,value
- Local ret=PeekInt(temp,0)
- FreeBank temp
- Return ret
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement