The sample C programs and C shell scripts in the samples directory are meant to help you install or experiment with Hamilton C shell. Deliberately, they're relatively trivial. All were created assuming TABS=3.
a2e.csh |
Convert ASCII to EBCDIC using the tr utility. |
args.c |
A simple C program that prints out the *argv[] (argument) and *envp[] (environmental variable) arrays. Notice that wildcarding, variable substitutions, quoting and command substitutions are done before the C program is started. If you do a lot of wildcarding, you can create and pass very long parameter lists (up 64K characters on OS/2 or 32K on NT.) Try some of these commands:
|
average.csh |
Find the average numeric values in a list. If none of the elements are numeric, return 0. |
basename.csh |
Emulate the POSIX basename command to extract just the last component of a pathname, deleting any suffix, if specified. |
bits.csh |
A simple self-loading procedure that calculates the minimum bits required to represent the argument it's passed as a binary integer. |
blksize.c |
A simple C program that reads from Stdin, copying to Stdout, using the specified blocksize. This program can be useful to read or write tape devices that only support certain blocksizes. (Only supplied with the Windows NT version.) |
bumpdate.csh |
Print the date n number of days forward or backward from a given date. If only the bump value is given, today's date is bumped. |
c2f.csh |
A simple C shell script for converting between Celsius and Fahrenheit. |
caldate.csh |
Print the date corresponding to a given Julian day. |
calendar.csh |
A C shell script for printing out the calendar for any given month, highlighting the current date. If no date is given, this month's calendar is printed. |
cl.csh |
On NT only, run the compiler and linker for an NT program. Avoids having to fool with a make file just to compile hello, world. Works pretty much just like the cl command on DOS would. |
colors.csh |
Instructions and examples on customizing the screen colors. |
deltaday.csh |
Print the number of days separating two dates. If only one date is given, the difference between it and today's date is returned. |
dirname.csh |
Emulate the POSIX basename command to extract all but the last level of a pathname. |
dumpenv.c |
This C program writes out the environment it's passed in the form of setenv commands. If you're installing Hamilton C shell for the first time, dumpenv is a convenient way to snapshot the environmental variables you've been using with cmd.exe in a form you can append to your login.csh file. |
duplicat.csh |
Look for duplicate files anywhere in a directory tree. |
e2a.csh |
Convert EBCDIC to ASCII using the tr utility. |
easter.csh |
A C shell script that calculates when Easter will occur in any given year. If no year is given, the current year is assumed. |
f2c.csh |
A simple C shell script for converting between Fahrenheit to Celsius. |
factor.csh |
The simple factor C shell script shown in the User Guide. It's intended to show to show the use of recursion, expressions, and a self-loading procedure. |
finance.csh |
Another C shell script showing expression evaluation. This defines a number of routines for calculating financial conversion factors, e.g., from present to future value. |
fixup.csh |
Fixup source files to discard any extraneous tabs or spaces at the end of the lines, to ensure that all lines end properly with \r\n and to ensure that the timestamps can be exactly represented on a FAT or HPFS partition. |
getprio.c |
This C program (supplied with the OS/2 version) retrieves and prints its scheduling priority, demonstrating the effect of using the eval command to run a command at a higher or lower priority. Try these examples:
|
julian.csh |
Calculate the Julian day number (number of days since January 1, 4713 B.C.) for any given date. If you don't give a date, it uses today's date. |
laptop.csh |
Customize the screen colors for a laptop computer. |
makecpgm.csh |
A simple C shell script showing how a "make" function might be written in the C shell language. This one rebuilds any .exe files in the current directory that are older than the corresponding .c file or any of the .h files. |
max.csh |
Find the maximum numeric value out of a list. If none of the elements are numeric, return 0. |
mcvisa.csh |
A simple C shell script that constructs a special checksum of a credit card number to tell if the card number is plausible or not. The checksum used is designed to catch transposed or incorrect digits. Try it on the cards in your wallet. |
member.csh |
Test whether the first argument word appears somewhere in the list given by the second argument. |
min.csh |
Find the minimum numeric value out of a list. If none of the elements are numeric, return 0. |
myecho.c |
A variation on the built-in echo command that prints its *argv[] (argument) list with quotes around each word it's passed and tells the total character count. Try these examples:
|
newfiles.csh |
List all the files or directories in the current directory that do not occur in the specified directory. |
postage.csh |
Calculate the U.S. first class postage required for a given weight in ounces. |
posxpath.csh |
Convert ordinary filenames to POSIX format. (Supplied with the NT version only.) |
rcode.c |
A trivial C program that just prints, then exits with the return code value you pass it. You can use this routine to see how the status variable is set and also, how the ";", "||" and "&&" statement connectors work. Try these examples:
rcode also illustrates another aspect of return codes to consider: if you use C library stdio (as rcode.c does) and you exit with a non-zero return code, stdio thinks it was an error and discards anything in the stdio buffers. In the following example, stdio writes to the screen are unbuffered so it works; but pipes are buffered, so nothing gets written to it:
If you're writing an application that uses return codes, you should remember to explicitly flush the buffers with stdio fflush() or use the kernel calls directly. |
read.csh |
Emulate the Bourne Shell's read command, which reads a line of input, breaking it into words, which are then assigned, one-by-one, to the variables whose names are passed as arguments. |
renet.csh |
A script for attempting to reconnect any unavailable LanMgr network resources. |
sh_2_csh.csh |
A script for converting Bourne or Korn shell scripts into Hamilton C shell scripts using a set of sed scripts contained in the sh_2_csh directory. |
sizeof.csh |
A short C shell script that calculates and prints the cumulative size of any number of files or directories. |
sunrise.csh |
Calculate sunrise and sunset times given the date, latitude and longitude. |
timestmp.csh |
Extract a timestamp from a file or directory in the format needed by touch.exe. |
trapz.csh |
A C shell script that does numeric integration using the trapezoidal rule. |
ts.csh |
A C shell script that searches for occurrences of a simple string in all the files with a given extension anywhere in a directory tree. |
unixprof |
A directory of tools for profiling a source tree, tallying up all the calls to the UNIX system and library routines. |
update.csh |
Compare the frompath and topath directories, looking for differences, updating the topath directory as needed to make it an up-to-date copy. |
viopaste.c |
A short C program (supplied with the OS/2 version) to enable pasting into a Presentation Manager text window under OS/2 1.2 or 1.3. |
weekday.csh |
Print the day of the week corresponding to any given date. |
which.csh |
Figure out what will be run if a command is typed. |
white.csh |
Customize the screen colors for a bright white window. |
winerror.c |
Print the Win32 message corresponding to a given error code. (Only supplied with the Windows NT version.) |
Previous Topic
Hamilton C shell |
Free Updates |
Free Demo Software |
Win32 Training
Y2K |
Customer Testimonials |
On-line Hamilton C shell User Guide
Home |
Email |
Support |
Company Profile |
Distributors |
Links
Copyright © 1997-2001 by Hamilton Laboratories. All rights reserved.
You are visitor number
5195.
This page was last modified November 3, 2001.