417 Archived Topics
Remove Filter Where you ever curious what the most common letter is in a typical text file? Just another question to ask a friend. The answer is right here in this tiny code snippet. The program converts the text to all lower case letters, and then list them out alphabetically showing the … | |
The module datetime allows you to call several functions that can do computation with dates and times. How many days since my birth? How many days till Xmas? What's the date 77 days from now? The code snippet should give you a flavor, enough to explore on your own. | |
Many of the code samples on the internet are written in Turbo C. The clrscr() function litters these samples, and even to this day people want to wipe your screen. You can use system("CLS"), but that uses a DOS command. DOS commands are with us only at the whim of … | |
Quick and dirty way to change your console program colors using DOS command "Color BackgroundForeground" where Background is hex 0 = black to F = white, dito for Foreground. | |
The wxPython library allows Python to create Windows GUI programs. Here is a look at the listbox component. Click a button to load the listbox with names, select the name by clicking on it on the list, and display it in the title bar of the window frame. Another button … | |
This program uses WinApi function SetPixel() to plot math functions y = sin(x) and y = cos(x) and y = sin(x)*cos(x) along a y-axis centered on the console screen. Make sure that gdi32.lib is included in the libraries to be linked. | |
Just a simple way to separate the words contained in a sentence. As an option you can store the words in a vector. If you are not familiar with a vector, use an array instead. | |
I look at BCX-basic as a modernized qbasic. This simple code creates a Windows GUI program that plays a midi instrumental music file. To keep it simple, the file it looks for is "TheRose.mid" file. If you don't have this file, you have the option of editing the code, or … | |
Shows how to connect a button onclick event to a javascript function to change the background color of the document. Just cut and paste the code into Notepad or other editor, save as BGchanger.htm and run it on your browser. | |
Remember the Spirograph? It used geared circles to create some rather artistic geometric designs. This program uses triangles to follow in the Spirograph's foot steps. The math is rather simple, just a couple of sine and cosine functions, also the ubiquitous for loops, everything wrapped up in the using() statement. … | |
The set is an unordered collection of unique hashable elements. All the elements/items in a set are treated as keys. There are several functions that compare two sets. Right now, I will just give you a taste ... | |
The code shows you how to create a window without a titlebar that can be dragged with the mouse. Set the FormStyle property to fsStayOnTop. The form contains a small 18 button calculator. When you create the form and calculator components, try to make it tiny, it is cute that … | |
Using wxPython and the Boa Constructor, a VB/Delphi like IDE and Visual Builder, this little calculator was a breeze to make. Boa did 90% of the code generation, and I simply added code to each button click event to make the calculations work. I wish every project would go that … | |
The Simple DirectMedia Layer (SDL) library allows for manageable multimedia programming in console mode. Now you can mix graphics, animated or otherwise, with sound and make your game project more interesting. I am showing an example for Dev-C++ using math generated graphics, purloined from the NET, and give some instructions … | |
Many moons ago I wrote a Delphi program that could tell the exact character in a ListBox, as you clicked on it with a mouse. I found a little info on the NET that lets you get at least the item in a ListBox using C#. I made it work … | |
You can look at a selected file's date and time stamp and change it with this Delphi program. XP files need a little extra TLC, but it's taken care of too. | |
Swap two images as you move your mouse in and out of the image field. Uses onMouseOver, onMouseOut and a short javascript code. | |
A data stream is used to load a bitmap image and convert it to a jpeg image. The converted image is displayed and saved to a .jpg file. | |
The WinBGI package allows you to do some of the Borland BGI graphics in a specially created window form. So don't throw out the old Borland manuals, you can still use them to do some fancy graphing! Yes, you can gotoxy() again! This code was modified for Dev-C++, a real … | |
An example how to line up your decimal points in a column like output of floating point numbers. Both C and C++ versions are shown. Thanks are given to Bud Tugly, my 77 year old senior student. | |
Another application of the Python Image Library (PIL). This time we are loading an image and rotate it counterclockwise by a specified number of degrees. The image is shown rotated and then saved to the working folder. PIL handles a fair amount of image file formats easily. | |
Shows a basic way to create a form with a wallpaper image on it. Also shows how to add a transparent label to blend in with the wallpaper. Getting the label to be transparent wasn't all that commodious! The wallpaper is generated using a texture brush and bitmap image. The … | |
There are some pretty fancy things you can do with strings in Python. You can append, convert, justify, join, split, slice, and list selected files of a folder. I just give you a small sample here. | |
This is an application of the Python Image Library (PIL) and shows you how simple it is to do pixel math on an image. | |
This code gets the local time from your computer, formats the date and the time and displays the result. Does not include the bavarian time measurement of how many steins you have finished since you got up in the morning. | |
One more look at BCX basic code to show the qbasic programmers how they can modernize. This shows a function that converts an integer value to a binary string. Notice that with BCX basic you need to declare your variables. Makes the code a little easier to read too. Variable, … | |
This shows you how to create a Windows GUI program in BCX basic and embed the Media Player in the form. It will give you a fully functional player with a 30k executable size for your MP3 files. The needed header files and library files are included in the BCX … | |
New to me, but MS InternetExplorer does have COM support you can access from basic code. I had to test this out and make it work. We are using BCX basic, one of the successors to Qbasic. | |
Another look at BCX basic. Here we use COM support to manipulate Excel. In other words, from within the basic code we are entering a few numbers into the Excel spreadsheet and add them up. Of course you can do much more powerful stuff. With COM support you can also … | |
Nothing new, but something for the neophyte to ponder. Some of the functions (algorithms) used by STL containers can be applied to a normal array to do inane things like copying, displaying, finding max/min, reversing, replacing, searching, shuffling, sorting, summation. This can really simplify your code. | |
I just had to do this to see how it would look like in the code field. This small prime number generator is written in BCX basic, a mildy more modern basic than Qbasic. With BCX basic you can throw in C and assembler code and it would actually compile … | |
You probably have seen those message snakes following the cursor on a web page. Well, the javascript code is not too complex, so let's look at it ... | |
With the help of BCX I managed to create some C++ code that will allow you to send text to your printer and specify the font and other things. Play around with the options to suit your own needs. I have to admire the genius behind BCX, even though it … | |
Sooner or later a Csharp snippet had to appear. This one builds a form containing a set of buttons. A bitmap drawing area is used to draw a series of circles with random color, radius and center location. Your creation can be saved as a jpeg image file. You can … | |
Short little sound files of chicken, horses, dogs, cars, trains and other annoying things is the realm of the wave file (.wav). These are easy to play and guaranteed to confuse grandpapa. Again, we are using Windows' sound workhorse winmm.lib file. Ze function this time is PlaySound(). Here is ze … | |
Many of you know how I like to use sound to make the old computer box more interesting. The midi file packs a lot of neat instrumental music. It is very simple to play, even in a console application, using the winmm.lib file that comes with just about any Windows … | |
You can have fun and learn something too. Not too much fun though! Here we take a lighthearted look at C++ string, various ways to assign a string and substring, spell forward and reverse, find characters and substrings, append, insert, replace, remove characters, separate a sentence into words and more. | |
This Delphi procedure sends the text contained in a multiline editbox (memo in Delphi lingo) to a printer. The font and font size can be specified. | |
Just to give you an idea what Delphi can do, here is a plot of the ever popular sin(x). I have put enough information into the code comments so you can build the form. The PaintBox Paint Event takes care of the plotting. | |
This is Delphi code, just testing if there is some interest. | |
The Standard Template Library (STL) vector is tempting. The burden of dimensioning an array is removed, and there are many wonderful functions to explore. The learning curve is a little steep, it will make your head swell, but in the end it's all worthwhile. Take a look at some of … | |
Let's expand the decimal to binary converter to include, amongst others, octal and hexadecimal conversions. Also shows how to exert some input control. Simple stuff! | |
Let's say you worked in the White House and had to keep two lists, one for the friends and one for the enemies. The boss came to you and said: "The Almighty talked to me out of a burning bush last night, telling me that I shall make my enemies … | |
Another experiment with the Standard Template Library (STL). This time we are taking a look at map. Map is a Sorted Pair Associative Container (a mouthful). The pair is -- const Key, Data --, where Key has to be unique. It is Key that is sorted. In this code sample … | |
Using the C++ Standard Template Libraries (STL) can be easy, once you know how to do it. No need to putz around with doubly linked lists anymore! Here is code showing how a STL list allows you to add, insert, remove, sort, splice, merge, display, and clean-out-duplicate strings. | |
Get simple information like serial number, bytes/sector, sectors/cluster, free and total disk space of your hard drive using Windows API calls. | |
What is so easy to do in HTML gets quite involved in C. Once you learn to look past the standard GUI overhead it becomes more obvious. This example shows the effect of the mouse cursor moving across a label by changing foreground and background colors. | |
This program shows how to display a JPEG (also GIF,BMP,WMF etc.) image using some Windows Graphical User Interface C code. The program uses the uuid.lib file that comes with many C compilers. | |
This snippet shows how to draw a red circle on a Windows form. Original code via BCX, modified to compile with Dev C++. The GUI code looks a little complex. Gets simpler, once you get past the required overhead. For those who need some hand holding with the Dev C++ … | |
Use a Windows API call to add some color to your text output. A rewrite of an earlier C++ snippet for the C crowd. |
The End.