BBS: Inland Empire Archive Date: 03-13-93 (22:59) Number: 299 From: JOHN GALLAS Refer#: NONE To: CALVIN FRENCH Recvd: NO Subj: Badly Needed! Bin2string Conf: (2) Quik_Bas

CF>relatively FAST decimal 2 binary function, as well as a binary 2 CF>decimal function to go with it. The binary function needs to be CF>put in a string ($), so that I can deal with it. I'm not just CF>'too lazy' to write it, the fact is that I don't think I could A while ago someone posted a program to do all kinds of convertions, bin2int, bin2hex, int2bin, etc. Unfortunatly, I don't have the authors name who wrote this little beauty -- (If you're reading this Mr Author, can you please reply so I can put your name with the file?) -- I hope it helps!DEFINTA-ZDECLAREFUNCTIONBin2Hex$ (Bin$)DECLAREFUNCTIONBin2Int% (Bin$)DECLAREFUNCTIONHex2Bin$ (Hcs$)DECLAREFUNCTIONHex2Int% (Hcs$)DECLAREFUNCTIONInt2Bin$ (Dec%)DECLAREFUNCTIONInt2Hex$ (Dec%)DEFSNGA-ZFUNCTIONBin2Hex$ (Bin$) Bin2Hex$ = Int2Hex$(Bin2Int%(Bin$))ENDFUNCTIONFUNCTIONBin2Int% (Bin$)FORy = LEN(Bin$)TO1STEP-1IFMID$(Bin$, y, 1) = "1"THENax% = ax% + (2 ^ z) z = z + 1NEXTBin2Int% = ax%ENDFUNCTIONFUNCTIONHex2Bin$ (Hcs$) Hcs$ = UCASE$(Hcs$) lc = LEN(Hcs$)FORx = 1TOlcSELECTCASEMID$(Hcs$, x, 1)CASE"0" Out$ = Out$ + "0000"CASE"1" Out$ = Out$ + "0001"CASE"2" Out$ = Out$ + "0010"CASE"3" Out$ = Out$ + "0011"CASE"4" Out$ = Out$ + "0100"CASE"5" Out$ = Out$ + "0101"CASE"6" Out$ = Out$ + "0110"CASE"7" Out$ = Out$ + "0111"CASE"8" Out$ = Out$ + "1000"CASE"9" Out$ = Out$ + "1001"CASE"A" Out$ = Out$ + "1010"CASE"B" Out$ = Out$ + "1011"CASE"C" Out$ = Out$ + "1100"CASE"D" Out$ = Out$ + "1101"CASE"E" Out$ = Out$ + "1110"CASE"F" Out$ = Out$ + "1111"ENDSELECTNEXTHex2Bin$ = Out$ENDFUNCTIONFUNCTIONHex2Int% (Hcs$) Hcs$ = UCASE$(Hcs$) Hex2Int% = Bin2Int%(Hex2Bin$(Hcs$))ENDFUNCTIONFUNCTIONInt2Bin$ (Dec%) tdec% = Dec%DOWHILEtdec% > 0IFtdec% / 2 = tdec% \ 2THENBin$ = "0" + Bin$ELSEIFtdec% / 2 <> tdec% \ 2THENBin$ = "1" + Bin$ENDIFtdec% = tdec% \ 2LOOPInt2Bin$ = Bin$ENDFUNCTIONFUNCTIONInt2Hex$ (Dec%) Int2Hex$ = HEX$(Dec%)ENDFUNCTION* OLX 2.1 TD * *'M ST*P*D - I'd like to buy a vowel Pat, an 'O' --- Maximus 2.01wb * Origin: Command Line BBS =Mpls. MN= V.32bis [612-788-6685] (1:282/2007)

Echo Basic Postings

**Books at Amazon:**

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET