July Twenty-Third 2003 From: Bob Zale, President PowerBASIC, Inc. PowerBASIC Gazette #37 - Please share with fellow programmers ============================================================= Subject: Some interesting macros... ==================================== We've accumulated some great contributions from Power Programmers. We have Macros. We have Functions. We have code you might use today. But more about that in just a minute. First, I wonder if I could ask you for a favor? Would you help us spread the word about PowerBASIC? It's easy, and it's relatively pain-free! The truth is, you're the best advertisement for PowerBASIC, and we're hoping to explore it a bit further. You know, every time we add a PowerBASIC customer, it helps us all. Every new user is an investment... with more resources, we'll create better products, deliver them sooner, and keep the pricing right for you. So how about it? Will you tell a friend about PowerBASIC? I hope so. We'll try to make it easy for you. {smile} Anyway, here's the plan... You give us a name (or a few names), and we'll send a short, informative email under your name and ours. We won't add them to our mail list, and we won't use their email again, unless they choose to sign up. Just GoTo... http://www.powerbasic.com/bin/ps.exe You'll see the text of the message and add a contact name! The message is harmless, yet informative. And just think of the compilers we could build for you if everyone brought us just one new PowerBASIC user! Now, back to the Basics... Macros... Macros... Macros... FROM: Borje Hagsten ==================== The long forgotten Nybble can be used for splitting up a BYTE variable into two 4-bit parts (compare MAKWRD/LOBYT/HIBYT, etc). Each part can hold values between 0-15. Following is a set of macros that completes PowerBASIC's equivalents for WORD and DWORD, etc. Useful when you need to store as much information as possible in a huge array, values are in the range of 0 to 15. Array capacity is doubled! MACRO mLONYB (byt) = byt MOD 16 'returns the least significant ' (low-order) part of a BYTE MACRO mHINYB (byt) = byt \ 16 'returns the most significant ' (high-order) part of a BYTE MACRO mMAKBYT(LoNyb, HiNyb) = (HiNyb * 16 + LoNyb) ' combine two 4-bit ' values (0-15) to BYTE FROM: Borje Hagsten ==================== The routine PB missed - an easy way to determine which OPTION control in a range is selected. Just give fGetOption hDlg plus Option controls id-range (minId, maxId), and selected control's id will be returned. Like with SET OPTION, it assumes id range is "continuous", 120, 121, etc. FUNCTION fGetOption (BYVAL hDlg&, BYVAL minid&, BYVAL maxid&) AS LONG FOR minid& = minid& TO maxid& IF (SendMessage(GetDlgItem(hDlg&, minid&), %BM_GETCHECK, 0, 0) _ AND %BST_CHECKED) THEN FUNCTION = minid& : EXIT FUNCTION 'return selected control's ID END IF NEXT END FUNCTION FROM: Tom Hanlin ================= My debug helper has been posted before, but it's very helpful when you need to log debugging comments as they occur. MACRO blog (s) OPEN "c:\x." FOR APPEND AS #32000 WRITE #32000, s CLOSE #32000 END MACRO FROM: Michael Mattias ====================== Some helper functions for ListViews and TreeViews. Return (zero-based) row number of currently selected item in LV FUNCTION ListView_GetSelection (BYVAL hWnd AS LONG) AS LONG FUNCTION = SendMessage(hWnd, %LVM_GETNEXTITEM, -1, %LVNI_SELECTED) END FUNCTION Set selected state of a (zero-based) row in a LV FUNCTION ListView_SetSelection (BYVAL hWnd&, BYVAL Rowno&) AS LONG ListView_SetItemState hWnd, RowNo, &hFFFFFFFF, %LVIS_SELECTED END FUNCTION Un-select all rows of a LV FUNCTION ListView_UnselectAll (BYVAL hwnd AS LONG) AS LONG ListView_SetItemState hWnd, -1, BYVAL %NULL, %LVIS_SELECTED OR %LVIS_FOCUSED END FUNCTION Get the text from a treeview item FUNCTION TV_GetItemText (BYVAL hTV AS LONG, BYVAL hItem AS LONG) AS STRING LOCAL tvi AS TVitem, szText AS ASCIIZ * 2048 tvi.hitem = hItem tvi.mask = %TVIF_TEXT tvi.pszText = VARPTR(szText) tvi.cchTextMax = SIZEOF(szText) -1 TreeView_GetItem hTv, BYVAL VARPTR(tvi) FUNCTION = szText END FUNCTION FROM: Lance Edmonds ==================== My personal favorite is a macro for right-justifying a FORMAT$ string which may contain an unknown number of commas when formatted. MACRO mMoney(d,l) = "$" + RSET$(FORMAT$(d, "#,.00"), l - 1) In use: A$ = mMoney(1234.56@@, 13) ' A$ contains "$ 1,234.56" FROM: Eric Pearson =================== Personalized PowerBASIC Syntax Using Macros effectively simulating a new PowerBASIC key-word. MACRO WHITESPACE = ANY $SPC + $TAB + $NUL + $CR + $LF sResult = TRIM$(sMyString$, WHITESPACE) These Macros require the current versions of PowerBASIC Compilers: PB/CC 3 or PB/Win 7. But don't worry, pricing is very competitive! PB/CC is our Console Compiler -- with a text mode interface to 32-bit Windows. PB 7 for Windows is oriented towards a GUI (graphical user interface) for a typical Windows "look and feel". With all of the new extensions, you won't believe how easy it is to build real GUI applications! PB/Forms is our new, state-of-the-art visual designer. It works with PowerBASIC 7 to build GUIs almost as fast as you can imagine them. More information? Sure, it's very simple. Just click to go to each or all of the PowerBASIC product pages... PB/CC 3.0: http://www.powerbasic.com/products/pbcc/ PB/WINDOWS 7.0: http://www.powerbasic.com/products/pbdll32/ PowerBASIC Forms: http://www.powerbasic.com/products/pbforms/ PowerTREE: http://www.powerbasic.com/products/powertree/ Graphics Tools: http://www.powerbasic.com/products/graftool/ SQL Tools: http://www.powerbasic.com/products/sqltools/ Console Tools: http://www.powerbasic.com/products/contools/ PB/WIN 7.0 is attractively priced at $199.00, while PB/CC 3.0 is just $169.00. Upgrades from the prior versions are just $99 and $89. PowerBASIC Forms is priced at $99. Graphics Tools Standard and Pro are $69.95 and $139.95. You can order with ease by just replying to this email. You can call us at (800) 780-7707 or (941) 408-8700, fax us at (941) 408-8820, place an electronic order on our web site (www.powerbasic.com), or even mail it in. But no matter the method you choose, please do it today and do it with confidence. Every product PowerBASIC shipped for physical delivery is offered with a money-back guarantee for a full 30 days from the transaction date. Regards, Bob Zale, President PowerBASIC Inc. =================================================================== PowerBASIC Price List ------------------------------------------------------------------- PB/CC Console Compiler 3.0 - Full Product $169.00 PB/CC Console Compiler 3.0 - Upgrade from vs 2 89.00 PB/CC Console Compiler 3.0 - Upgrade from vs 1 119.00 Add Printed Documentation 39.00 ------------------------------------------------------------------- PowerBASIC for Windows 7.0 (GUI) - Full Product $199.00 PowerBASIC for Windows 7.0 - Upgrade from ver 6 99.00 PowerBASIC for Windows 7.0 - Upgrade from prior versions 129.00 Add Printed Documentation 39.00 PowerBASIC Forms 1.5 Visual Design Tool for PB/Win 7 99.00 ------------------------------------------------------------------- PowerBASIC for DOS 3.5 - Full Product $99.00 PowerBASIC for DOS 3.5 - Upgrade from prior versions 49.00 Add Printed Documentation (2 book set) 29.00 ------------------------------------------------------------------- PowerTree BTree Manager for DOS and Windows $99.00 PB/Vision for DOS 20.00 PB/Xtra III for DOS and Windows 49.00 ------------------------------------------------------------------- Graphics Tools Standard ver 2 $69.95 Graphics Tools Professional ver 2 139.95 Console Tools Standard 49.95 Console Tools Professional 99.95 SQL Tools Standard Version 99.95 SQL Tools Professional Version 199.95 ------------------------------------------------------------------- Shipping/Handling costs: Software & Each Any Software 1 or 2 books Addl Book Email $6 N/A N/A UPS Ground/Mail US $10 $10 $6 Fedex 2-day US $16 $16 $6 Fedex 1-day US $28 $28 $6 Air Mail Canada/Mex $12 $22 $6 Air Mail Intl $16 $28 $6 Fedex Intl $34 $44 $6 Fedex International Rates are for Western Europe, Pacific Rim, Asia, and North America. Others please request a quotation. ------------------------------------------------------------------- Order online at https://www.powerbasic.com/shop/ (secure server) or just send an email with all pertinent information to sales@powerbasic.com and we'll take it from there! ------------------------------------------------------------------- Most PowerBASIC products (those without printed books) can now be delivered by electronic mail. No wait for a package to arrive... No high shipping costs... For just $6 per order, no matter how many products, we'll deliver directly to your computer. If you're outside the U.S., savings might be greater. You won't pay taxes or duties to a freight company or postal service because they aren't involved in the delivery. Check your tax code to be sure, but some countries charge no tax at all on transactions like this. It could just be your lucky day! ==================================================================== Is your PowerBASIC Gazette Electronic Edition subscription coming to you at home or work? If you don't want to miss a single issue, why not subscribe from both email addresses? Send your subscription request to email@powerbasic.com and please include your name and all email addresses you'd like to add as well as your Zip or Postal Code. If you know someone else who would enjoy this newsletter please forward a copy to them so they can subscribe. ==================================================================== All contents Copyright (c) 2003 PowerBASIC Inc All Rights Reserved. PowerBASIC is a registered trademark of PowerBASIC, Inc. PB/CC, PB/DLL, PB/Win, PowerTREE, and PowerBASIC Forms are trademarks of PowerBASIC Inc. Other names are trademarks or registered trademarks of their respective owners. ==================================================================== PowerBASIC Gazette - Electronic Edition Volume 1 - Issue 37 PowerBASIC, Inc. (800) 780-7707 Sales 1978 Tamiami Trail S. #200 (941) 408-8700 Voice Venice, FL 34293-5006 (941) 408-8820 Fax Visit www.powerbasic.com email to sales@powerbasic.com This newsletter is only sent to email addresses in our subscription list. If you have received this newsletter by mistake or no longer wish to receive it, please send a simple unsubscribe request to gazette@powerbasic.com with your name and zip/postal code. ====================================================================