--------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: D3200000 Date: 02/29/96 From: FRANK COX Time: 03:19pm \/To: WHOEVER CARES (Read 4 times) Subj: 7 bit fields A while ago, I posted a question here about using 7 bit and single-bit data fields with PowerBasic. I didn't really get much of a response here, but I also posted my question on the PowerBasic tech support BBS, and got a reply from Mr. John McTaggart. Here it is, for the information of anyone else who's interested: BEGIN QUOTE If you use 7 bits, your available numbers are 0 through 127. The 8th bit has a value of 128. A routine to encode with Decimal numbers: DIM NameCode AS BYTE DIM CustomerCode AS BYTE . . NameCode = [whatever number you came up with 0 - 127] IF Answer$ = "Yes" THEN CustomerCode = NameCode ELSE CustomerCode = NameCode + 128 END IF And another routine to decode with Decimal numbers: IF CustomerCode > 127 THEN NameCode = CustomerCode - 128 Answer$ = "Yes" ELSE NameCode = CustomerCode Answer$ = "No" END IF Just a Quick & Dirty answer to your question, but it should work. (Refer# 2440) To: FRANK COX From: JOHN MCTAGGART Subj: 7 bit fields, 1 bit field Read: NO Status: PUBLIC MESSAGE Conf: Main Board (0) Read Type: MAIL FOR YOU (A) (+) FC>Does anyone have a routine for creating a file containing 7 bit fields, FC>and one bit fields? Example follows: FC>Davey Jones Yes FC>Susie Smith No FC>Fred Waters Yes FC>Joe Schmoe Yes FC>Now, all of the names could be represented with 7-bit ASCII, and the FC>yes/no answers with a single bit, 0 or 1. Now, if I wanted to store FC>this in a file using 7 bit ASCII for the names, and a single bit for FC>each yes/no answer, how would I go about doing this? One way to do this would be to just toggle the first, or second bit of the first letter of the name on and off. Since all the capital and lower case letters fall between 64 and 127, and all those particular bytes have identical first and second bits (01) you could just toggle the first bit to 1 for yes, 0 for no. Example... Davey Jones would be avey Jones for yes, or just Davey Jones for no D = 0100 0011 (after toggling first bit to 1) = 1100 0011 or - Susie Smith would be usie Smith for yes, or just Susie Smith for no S = 0101 0011 (after toggling first bit to 1) = 1101 0011 or When you retrieve the name, you can just test the first letter with something like bit test and toggle it back to where it was. Of course, you could also subtract 128 from it and get the same result. Now, if you really wanta get tricky, you could put up to 4 seperate tests in those 2 bits. All you need to represent a letter of the alphabet is the right 6 bits, so you could conceivably code in a scheme to allow for other things like, are they ugly, are they married, whatever. Example.... 00 - Ugly, Not married 01 - Ugly, Married 10 - Not Ugly, Not Married < 11 - Not Ugly, Married | | For Susie Smith it would be ... | | S = 0101 0011 (toggle to Not ugly, not married) (10)01 0011 or usie Smith After you check the 2 bits you can easily reset it to 01 by toggling the bits to 0 and 1 by use BIT RESET and BIT SET. You can also encode messages (whatever) in those spare 2 bits if you keep it strictly between (64-127). Just remember that it takes 3 pairs of 2 to represent a letter (assuming all letters start with 01) Now, if you want to assure net transmission (low ascii) then you can use a 0 bit for the first bit, the next 6 bits hold the letter, and the last holds the yes/no bit. It would take a pretty good algorithm to do this quickly, but I'd image you could use shift left and right for this ... something like this. To encode: Shift left 1 < Shifts the 6 right bits into the middle Toggle bit 0 to 0 Toggle bit 7 to 1 or 0 for yes/no To Decode: Test bit 7 to see what's up yes/no Shift right 1 < shift the middle 6 to the right (original position) Reset bit 0 to 0 and bit 1 to 1 Well, I hope you find this useful and that it didn't confuse you more. Date: 12-05-95 (16:01) Number: 2451 of 2452 (Refer# 25) To: FRANK COX From: JOHN MCTAGGART Subj: Bits Read: NO Status: PUBLIC MESSAGE Conf: Main Board (0) Read Type: MAIL FOR YOU (A) (+) Frank, here is a little program to demonstate what I was talking about in the other message. Hope it helps... Defint A-Z Declare Function BinFmt$(Integer,Integer) Type Video Char As Byte Attr As Byte End Type Dim Cell As Shared Video Ptr Cell = &HB800?? * 65536?? Color 15,1 : Cls Dim Var As Integer Var = 65 Locate 2,10: Print " This will take care of all letters A-Z and a-z..." Locate 4,10: Print " The following is for the letter A " Locate 6,10: Print " " ; Binfmt$(Var,8) ; " << - before manipulating bits" Locate 7,10: Print " ^^^^^^ << - the 6 necessary letter bits" Shift Left Var, 1 'Shift it all left 1 Locate 9,10: Print " " ; Binfmt$(Var,8) ; " bits shifted left 1 ( Shift Left Locate 10,10: Print " ^^^^^^ << - 6 letter bits are now in the middle of the Bit Reset Var, 7 '< Set bit 7 (left bit) to 0 Locate 12,10: Print " " ; Binfmt$(Var,8) Locate 13,10: Print " ^ << - reset bit 7 to 0 if low ascii needed ( Bit Reset Bit Set Var,0 '< Set bit 0 (right bit) to 1 Locate 15,10: Print " " ; Binfmt$(Var,8) Locate 16,10: Print " ^ set bit 0 to 1 for yes, 0 for no ( Bit Set Var Locate 19,10: Print " Legend: bits are cyan on blue - PB keywords are red on Locate 20,10: Print " The 0 and 1 bit are yellow, and ( Var )iables a Locate 22,10: Print " Of course there is more than one way to do anything." For U = 0 to 1999 'Do the whole screen, not efficient, but easy! Do '--This will color single characters Select Case @Cell.Char 'See what the characters are Case 32,0 'If (space, nul) Then Exit Do 'We're done, exit loop Case 48,49 '0 and 1 use yellow @Cell.Attr = 30 ' Case Else 'Else Word$ = Word$ + Chr$(@Cell.Char) 'Build the word End Select 'Doesn't check for punctuation Incr Cell, 2 'Bump the cell forward Loop '--This will color the selected words Select Case Word$ 'Check the word found D = Len(Word$) 'Yes, get its length Decr Cell, 2 * D 'Backup 2 * Len Case "Shift","Set","Reset","Bit","Left","red" ColorWord D, 28 Case "bits","cyan" ColorWord D, 27 Case "Var" ColorWord D, 26 Case Else End Select ' Word$="" 'erase it Incr Cell, 2 'And increment the cell count Next U End Sub ColorWord(L As Integer, Attr As Byte) Dim Inc As Local Integer For Inc = 1 to L @Cell.Attr = Attr Incr Cell, 2 Next Inc End Sub Function BinFmt$(value%,size%) BinFmt$ = RIGHT$("00000000"+BIN$(value%),size%) End Function END QUOTE --- Msgedsq 2.2e * Origin: THE BIG ELECTRIC CAT Melville Sask *SDS* *PDN* (1:140/53) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: D3200001 Date: 02/29/96 From: FRANK COX Time: 03:23pm \/To: WHOEVER CARES (THE SEQUEL) (Read 4 times) Subj: 7 bit fields Anyway, the previous message is interesting and I thought folks here may find it useful. However, it still didn't exactly address my original question. Well, maybe it did. However, "I'm not sure that you understand that what I said was not what I meant." (I can't remember who said that....) Anyway... What I would like to be able to do is to establish some sort of a "sliding offset" to store and retrieve 7 bit data (and single bit data) on disk. Such that the first 7 bits of the file would be the first character, the next 7 bits would be the next character, the next single bit would be a yes/no or whatever, and so forth and so on. However, as I stated earlier, I just can't seem to get my mind around this problem. --- Msgedsq 2.2e * Origin: THE BIG ELECTRIC CAT Melville Sask *SDS* *PDN* (1:140/53) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: D3200002 Date: 03/01/96 From: ERIC SCHONNING Time: 7:03:am \/To: SAM PAULSON (Read 4 times) Subj: Re: PB equivalent for MOD? SP> What is the PowerBASIC equivilent of QuickBasic's MOD keyword for SP> finding the remainder after dividing a number? PB does support the MOD function, same as QB. I think the confusion may be is that its not mentioned anywhere in the manuals or help files, for whatever reason I don't know. I know one time I went looking for it and never found it. But it does work try it. SP> P.S. I'd appreciate replies to my previous 3 messages, too, if someon SP> could take the time to do that. What were your other 3 messages about? eric --- QM v1.00 * Origin: Creekside Manor (805) 484-8016 CdCom Support BBS (1:206/2512.0) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: D3200003 Date: 03/01/96 From: ERIC SCHONNING Time: 7:08:am \/To: EVERYONE (Read 4 times) Subj: pb/dll & vb 4.0 Has anyone else recieved their copy of pb/dll yet? And also using VB 4.0? We have been trying to make .dll files to use with vb 4.0 and it keeps on saying (VB) that it cannot locate the .dll file. We have started from scratch 3 different times now to make sure its not just us. I'm about ready to go find the VB 3 disks and install that again to see if it even works with that or not. We can make .exe files just fine though. I'm going to give it another shot today with some examples PB had in a document d/l'd off the bbs and if this doesn't work then I'll know for sure. Just wondering how others are doing with this. eric --- QM v1.00 * Origin: Creekside Manor (805) 484-8016 CdCom Support BBS (1:206/2512.0) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: D3200004 Date: 03/01/96 From: SID LEE Time: 11:25am \/To: SAM PAULSON (Read 4 times) Subj: PB equivalent for MOD? -=> Quoting Sam Paulson to All <=- SP> What is the PowerBASIC equivilent of QuickBasic's MOD keyword for SP> finding the remainder after dividing a number? MOD is the same in PB. "5 MOD 2 = 1" and "9 MOD 10 = 9" ;-) Pb also has the "\" operator which does integer division, That is "23\8 = 2" -- Regards -- --- Blue Wave/Max v2.12 * Origin: RASCAL BBS [Calgary, Alberta - (403)686-2550] (1:134/122) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: D3300000 Date: 02/26/96 From: STAN HELTON Time: 06:49am \/To: BRIAN MCLAUGHLIN (Read 4 times) Subj: Re: Compiler quirk? Brian Mclaughlin was speaking to All about Compiler quirk? BM> The quirk is in the colon that separates the IF statement from BM> the LET statement (test% = 999). I would expect the compiler to BM> treat this code as equivalent to this... Brian, that's the way I've always expected the single line IF/THEN to operate. In the oolldd GW days, this was the closest thing you could get to a block IF statement. The PB32 compiler incorporates the GW syntax. Stan Helton ... He who would trade freedom for security deserves neither. - Franklin ___ Blue Wave/QWK v2.12 --- PCBoard (R) v15.22/10 * Origin: (1:373/10) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: D3400000 Date: 03/02/96 From: DAVID ROPER Time: 06:59pm \/To: LAWRENCE GORDON (Read 4 times) Subj: POWERBASIC FOR OS/2 LS> We have DOS support, We have Windows support, NOW, where's the support LS> for OS/2, PowerBasic Inc. and Mr. Zale, promised us??? LG>I'm sure there are many that are asking the same question, Lou. LG>The "tragedy" in this for PB is that no one, to my knowledge, has released a >32-bit BASIC compiler for OS/2 and PB could grab an entire market just by being >there first. I'd use it in a minute even if it was only text-based. Very >frustrating. LG>I, however, will continue to support PB, although I am, like many other >people, also looking at Windows-based compilers as alternatives. Me, too. I was excited about the OS/2 version back before WARP, but when MickeySoft came out with their WIN95, the hospital where I work went screaming over to WIndows apps and now, Visual Basic seems to be the way to go. I still do as much in PB32 as I can. I haven't gone to VB yet. I'm fighting. But I'm losing the war. I think Os/2 is dead except for banks and such where true MTasking is king. Just wanted to say all this out loud. Sorry if I offended anyone. Peace. _____oOOo_/00\_oOOo_____ david.roper@mms.raleigh.nc.us 1996 \__/ 201 WINDING BROOK Dr, GARNER NC 27529 --- FLAME v1.1 * Origin: Full Internet Access $15.00, (919) 779-6674 or MMS.NET (1:151/102) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: D3500000 Date: 03/04/96 From: JAMES GOLDBLOOM Time: 06:59am \/To: DAN KUNAPRAYOON (Read 4 times) Subj: Re: Using Asm Code DK-> Can you explain libraries to me? I've mainly been using QBasic DK-> during my whole programming hobby, and although I sorta get what They are collections of code. These collections can be organized into catagories and introduced easily into your own routines to take out the chore of reinventing the wheel each time you want to create new software. Just like in C and other compiled programs you have the ability to compartmentalize your code, so that certain functions do certain things, totally independanty of other functions (if necessary), think of libraries as a collection of those functions. -James (SysOp/AD Message System) --- QuickBBS 2.80 GoldBase (Zeta-1) * Origin: AD Message BBS/10th Year Online! (703)241-1826 (1:109/611@FIDONET) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: D3500001 Date: 03/03/96 From: SAM PAULSON Time: 10:44pm \/To: ERIC SCHONNING (Read 4 times) Subj: Re: PB equivalent for MOD? ES> SP> What is the PowerBASIC equivilent of QuickBasic's MOD keyword for ES> SP> finding the remainder after dividing a number? ES> ES> PB does support the MOD function, same as QB. I think the confusion may ES> be is that its not mentioned anywhere in the manuals or help files, for ES> whatever reason I don't know. I know one time I went looking for it and ES> never found it. But it does work try it. You're right, I was confused because I couldn't find it in the online help. I did try it after the first response I got and it worked fine. ES> SP> P.S. I'd appreciate replies to my previous 3 messages, too, if ES> SP> someone could take the time to do that. ES> What were your other 3 messages about? Well, there are a couple of things about the ASCII chart TSR that I'd still like to know about, like... 1) How do you know what number to use in the line "x& = SETMEM(-700000)" to release the unused memory? Another example in the online help says -500000. 2) In the line "POPUP KEY CHR$(8,30,247)", what does the 247 mean? Thanks, Sam Paulson paulson@freenet.msp.mn.us --- FMail 1.0g * Origin: Behind THE DOOR Forest Lake MN (612)982-0507 (1:282/4019) --------------- FIDO MESSAGE AREA==> TOPIC: 214 POWER BASIC Ref: D3500002 Date: 03/03/96 From: ALAN FOWLER Time: 10:03am \/To: MARTIN ELLIOTT (Read 4 times) Subj: PoerBASIC in Australia Martin, You have posted a number of messages asking about PowerBASIC in Australia. I have been using PowerBASIC for 7 or 8 years now, and wouldn't swap it for anything else. Therre are only two registered dealers in Australia, I'll have to dig through my notes and try and find the addressess, I bought my first copy (Ver 2.01) in Australia, but have bought all subsequent upgrades direct from PowerBASIC Inc in USA. I can let you have a demo disk of PowerBASIC Ver 3 which will show you the power of the language, and would be happy to talk to you at any time to give you some idea of the things PB can do, and the things it cannot. I'm retired, and you can reach me at (03)-9857-7128 during the day or evening. If I am not available, please leave a message on the answering machine, and I will call back. I have no financial interest in PowerBASIC, so I won't be tryiong to force it down your throat. If you lose the number, look under Dial Help in PC Update. I haven't had a chance to log onto the Melb PC UG BBS until a few days ago, or I would have replied sooner. regards, Alan. --- * Origin: Melbourne PC User Group BBS (3:632/309)