PowerBASIC Gazette CyberEdition #10 =================================== Who's Afraid Of A DLL? ---------------------- By Eric Pearson When I first started moving from DOS to Windows programming, the term "DLL" was pretty intimidating. But as I learned more about them, and what they could do for my programs, the mystery -- and the fear -- started to fade. Now they've become an absolutely indispensable part of my Windows programming toolbox, and they should be part of yours. Just saying that DLL stands for "Dynamic Link Library" isn't very helpful. That last word -- LIBRARY -- is by far the most important. Important Point #1: A DLL is simply a file that contains one or more pre-compiled functions. I was familiar with pre-compiling my own PB/DOS functions into Unit files, but DLLs take the "library" concept a couple of steps further. A couple of very POWERFUL steps! Important Point #2: DLLs are the fastest, most compact, and most efficient form of Windows library file. The Microsoft Windows operating system itself is based almost entirely on DLLs! In fact, Windows 98 and 2000 rely on more "system DLLs" than ever before. If you want raw, high-efficiency computing power, you're probably wasting your time with ActiveX, OLE, COM, OCX and all of those other three-letter acronyms. They all rely on DLL technology "under the hood", so they'll never be more efficient than using DLLs directly. Important Point #3: Your PowerBASIC PB/CC and PB/DLL programs can use DLLs that have been created by any almost Windows compiler, just as if they had been compiled by PowerBASIC. That means that thousands and thousands of sophisticated, thoroughly field-tested functions are available right now, for use in your PowerBASIC apps. Important Point #4: If you use PowerBASIC to create a DLL, virtually any computer language can use it. The DLLs that you create with PB/DLL can be used by Visual Basic, C++, Delphi, and on and on. DLLs are the one standard that virtually everybody supports! And many PROGRAMS can use DLLs too, to provide "extension" functions. Important Point #5: There's nothing magic -- or difficult -- about using a function in a DLL. You simply use the PowerBASIC DECLARE statement to tell the compiler that a certain function is located in a certain DLL file. Then you can use the function almost as if was part of the PowerBASIC language itself. If you put the DECLARE statements in an #INCLUDE file, it's almost like using a file that contains the source code for the functions! Important Point #6: DLLs save disk space, reduce load times, and reduce download times. The first two words of "Dynamic Link Library" describe another very powerful aspect of DLLs. Your program "links" to them at runtime, not at compile time. While it is running, an EXE file sees a DLL as if it was part of the EXE, even though it is a separate file. That means that if you have a DLL that contains some multi-purpose functions, many different programs can use one copy of the DLL file. That can result in significantly smaller programs, which is especially important if you want people to download your programs from the internet. Important Point #7: DLLs are memory-efficient. If two or more different programs are using a certain DLL, only ONE copy of the DLL is actually stored in memory. Each program will have its own set of DLL variables, and those do take up a small amount of memory, but the DLL itself will only be loaded once. Important Point #8: DLLs can provide powerful new "variable scope" options. You're probably familiar PowerBASIC's GLOBAL, LOCAL, and STATIC variables. GLOBAL variables are visible to every SUB and FUNCTION in your program, while LOCAL and STATIC variables are only visible to individual SUBs and FUNCTIONs. Well, DLLs add an entirely new level of variable scoping to your programs. The variables in a DLL are completely isolated from your program, so the GLOBAL variables in a DLL are really isolated "module level" variables that can't be seen by any other parts of your program. Important Point #9: Managing DLL files doesn't have to be a nightmare! We've all heard about DLLs being incorrectly replaced by older versions, and programs that failed because the wrong version of a DLL was installed. Virtually 100% of those problems can be eliminated if you simply store your program's DLLs in your program's own directory. If you put them in the "Window System" directory (as many programs do) you're asking for trouble. But the FIRST place that Windows looks for DLLs is in a program's default directory, so if you put them there, you'll avoid all of those headaches. Important Point #10 is that there are LOTS of other important points! Once you start using them, you'll see that DLLs provide many different, subtle advantages. The more you use DLLs the more advantages you'll find. And the more Powerful your PowerBASIC programs will become! ----------------------------- And now a brief word from our sponsor... Eric Pearson is the President of Perfect Sync, Inc. Perfect Sync provides DLL-based development tools to PowerBASIC programmers, including SQL Tools, Graphics Tools, Console Tools, and Console Tools Plus Graphics. For more information about how DLL-based development tools can add even more Power to your PowerBASIC programs, visit http://perfectsync.com/DevelopmentTools.htm. ================================================================ Of course, the other hot news in town is PB/CC 2 and PB/DLL 6! Our most important upgrades ever... Of course, PB/CC is our Console Compiler -- with a text mode interface to 32-bit Windows. PB/DLL is oriented towards a graphical user interface, and with DDT, you won't believe how easy it is to build GUI applications! PB/DLL 6 includes DDT: ====================== * DDT: Dynamic Dialog Tools(tm)... With DDT, you'll build complete GUI applications easier than ever. Don't struggle with form designers. Don't fight with resource scripts. Don't get lost in a sea of API calls! With PB/DLL's DDT, a few simple Basic Statements will build a complete Graphical User Interface! * DIALOG NEW creates an empty dialog box. CONTROL ADD places buttons, icons, frames, bitmaps, combo boxes, labels, list boxes, text/edit boxes, even custom controls and more. Add menus. Then display it with DIALOG SHOW. It really is just that easy! Perhaps best of all, DDT is dynamic. Change dialogs and controls "on-the-fly"! Alter the size, position, and style at will. With DDT, we put the Power in your hands. That's precisely where it belongs! PB/CC 2 includes Console & Standard I/O: ======================================== * Do even more with the Console... In PB/CC, you'll resize the console window with a single statement: Make it tiny -- 10 lines by 10 columns? -- Make it Huge, even larger than the physical screen! Change the console caption to a name of your choice, or use CONSNAME$() to retrieve the current title. Have you ever wished for a 32-bit DOS-Style compiler? One with the straightforward DOS interface but megabytes and megabytes of memory? It's here. The PowerBASIC Console Compiler for Windows. With PB/CC, it's a whole new Windows! Text mode applications for Win95/98 and WinNT. The Console is a text mode interface connected right to the heart of 32-bit Windows. With a console application, there's no fluff, no animated puppets, just intense computing power. Port existing Basic code from DOS to Windows today! PB/CC supports PRINT, LOCATE, LINE INPUT, INKEY$, COLOR, CLS, INSTAT, SCREEN, and LPRINT. All of the standard text mode functions. Then we added more: CURSOR, INSHIFT, PAGE, PCOPY, WAITKEY$ and WAITSTAT. A complete set of mouse handlers. SCROLL any region of the screen in any direction. Change the size of the console (make it 10 lines by 10 columns, or make it huge!). You can even set or retrieve the console title. Did you say Internet? Create CGI apps for your web server! It's the perfect tool. PB/CC offers Standard Input & Ouput for easy communication. Standalone executables as small as 10K. Whether your program looks up names, or calculates a mortgage, it can take data from a web form, process it as needed, then deliver the results right to the browser of a distant end user. Both New Compilers offer: ========================= * Client/Server Network Communications... TCP/UDP support is built right in. Communicate with a TCP server on the Internet or your own local intranet. Send an email message in just a few lines of code. Download a web page or file in seconds. You'll even receive source code to a complete HTTP server! Use it today to put your own web pages on the Internet. * High-speed Serial Communications... If you need to communicate with another computer, modem, or serial device, here's your instant solution. A complete COMM package for binary or text mode. Easily service multiple ports with total control of data flow, buffers, and parameters. * Regular Expressions... Search and replace with the most powerful string engine you'll find. Of course, it's lightning fast, and this complete implementation even supports 99 tag fields. Search for words with multiple spellings (like color and colour). Extract internet addresses, reformat financial amounts, and more, with just a simple search and replace mask. * Huge File Support... Forget about the old 2 gigabyte file barrier. With PowerBASIC, that's ancient history. Subject to operating system support, you'll create and access files up to 4 terabytes in size. That's 4096 gigabytes! * Advanced String Handling... The new string functionality is awesome. ASC(), INSTR(), MID$(), and PARSE$() accept negative position parameters, to work right-to-left from the string end. PARSE$(x$,y$,-1) returns the last parsed field in x$, -2 gets the second-to-last. The string function MID$("abcde",-3,2) returns "cd", and the statement MID$("abcde",-3) = "12" yields the new value "ab12e". BIN$(), HEX$(), and OCT$() offer an optional digit mask, so that BIN$(1,4) returns "0001". EXTRACT$() supports an optional start position, REMAIN$() complements it by returning the remaining portion, following the delimeter. MCASE$() capitalizes the first letter of each word, while STRINSERT$(), STRDELETE$() and STRREVERSE$() insert, delete, or resequence characters in a string. * String Equates... Just like numeric constants, now there are strings as well. Set $KillerApp = "PB/DLL", or anything else you need. We've even pre-defined a number of them for you, like $NUL, $TAB, $EOF, $ESC and more. * DiskFree and DiskSize... How large is that disk drive? And how much free space is left? These functions give you answers. It's a snap! * Faster than ever... Our developers spent countless hours "counting cpu cycles" and optimizing code. As always, the results will astound you. How about compile speeds of One Million Lines Per Minute? You won't wait around for this compiler! Execution speed? It doesn't get any better. Array Sort/Scan run up to 35% faster, and overall, PowerBASIC leaves the others in a cloud of dust. Perhaps it's time for some "C Snobbery" in reverse! * One Floppy per App... with room to spare! We're heating up the War on Bloatware. Create an application with a complete, sophisticated, graphical user interface. Use many forms, lots of controls, TCP communication, and huge data file handlers. You'll need no run-time modules, no DLL's, nothing but a single fast, tight, executable. Deliver a Win32 app (even many Win32 apps) on 1 floppy disk! Of course, there's even more... SLEEP to pause, RESET to clear a user-type, variable or array, and ERRAPI to get the Win32 error code. A new FILEATTR(), FILECOPY, FILENAME$(), GET/PUT ABS, and LSET/RSET ABS. You'll get local labels, a simplified PBMain(), $REGISTER options per function, and REDIM with statics and globals. Native multi-threading, MMX support, matrix operations, register variables, and unsigned integers. There are code and data pointers, a built-in assembler, ASCIIZ strings, unions, and 64-bit quad integers. Extended precision floats, multiple currency variables, array sort, scan, insert, delete, and the fastest, tightest code in the industry! But that's just what you've come to expect from PowerBASIC... We respectfully offer "Craftsmanship in Code". With these new compilers, you'll have everything you need to build complete, robust applications for 32-bit Windows! And if you still work with Win3.1, the 16-bit version of PB/DLL is now included with PB/DLL 6.0 absolutely free! You know, there's never been a better time to be a BASIC programmer. It's your golden opportunity to join PowerBASIC and share the excitement! PB/DLL 6.0 is attractively priced at $189.00, while PB/CC 2.0 is just $159.00. If you own a previous 32-bit version of each product, you qualify for a substantial discount to just $99.00 and $79.00 respectively. If not, a special bundle price is available to those who order both (a $50.00 discount on the second compiler!). Orders will be fulfilled in the sequence they're received, so please don't wait. You can order by replying to this email right now. You can call us today at (888) 659-8000 or (941) 473-7300, fax it to (941) 681-3100, place an e/order on our web site (www.powerbasic.com), or even mail it in. But whatever method you choose, please do it today and do it with confidence. Every product PowerBASIC ships is offered with a money-back guarantee for a full 30 days from the transaction date. Regards, Robert S. Zale, President ==================================================================== Order online at https://www.powerbasic.com/shop/ or just send an email with all pertinent information to sales@powerbasic.com 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 of this type. 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. Did you know that there is also a paper edition of the PowerBASIC Gazette? That's right, you can get a newsletter with articles detailing all of the products available from PowerBASIC, Inc. Full of useful code tidbits, book reviews and more. Why not get your free subscription today? Send your name and postal address to sales@powerbasic.com If you know someone else who would enjoy this newsletter please forward a copy to them so they can subscribe. ==================================================================== All contents Copyright (c) 1999-2009 PowerBASIC, Inc. All Rights Reserved. PowerBASIC is a registered trademark of PowerBASIC, Inc. PB/CC, PB/DLL, and PowerTREE are trademarks of PowerBASIC, Inc. All other brand names are trademarks or registered trademarks of their respective owners. ==================================================================== PowerBASIC Gazette - Electronic Edition Volume 1 - Issue 10 PowerBASIC, Inc. (888) 659-8000 Sales 2061 Englewood Road (941) 473-7300 Voice Englewood, FL 34223 (941) 681-3100 Fax Visit us on the World Wide Web at http://www.powerbasic.com Email Sales: 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 support@powerbasic.com with your name and zip/postal code. This newsletter is best viewed with a fixed-width font. ====================================================================