Well this is a start? I’ve been programming four many years, first on a Digital Equipment PDP-40 and a slew of other D.E.C. machines all running some version of Unix from Bell Labs. Well through IMSAI 8080/Z80H CP/M, MP/M right to IBM-PC’s and now ATX machines.

 When I went to college they asked me what foreign language I wanted to take and I told them English as C was my first language. They just did not appreciate it at all. Go figure. To continue further they insisted and I asked about FORTRAN and they stated it wasn’t a foreign language. I questioned that and asked if they knew FORTRAN and they stated no, so it is a definite language hence it was foreign to them. Again they did not appreciatethe candidness of the discussion. I never did take a foreign language. I tried a couple, but neither Russian or Spanish worked well for my mind. Perhaps if I would have written an algorithm to change from English to xxx whatever it might have worked. Then there is the different masculine and preposition placements that mess me up.

 Ok to continue? Well I will anyway. The first object I’ll introduce the typical word-count program I used in Unix and wrote my own version for a C language class in college. It is typical except that it is a bit obfuscated in the code, but fairly self explanatory. I used the ternary if statements to do this one. I feel the revelance of this program would be either to compile in Linux or perhaps someone might be desperate enough to rewrite it in Java.

/* 

wcp8.c – Word Count Plus using Ternary

by: Ben Miller W4QED previous call in 1991 was WB8LGH

date: 22-Feb-91

history: 960727 altered for unix machines.

Usage: wc < inputfilename.ext > (outputfilename.ext || device)

*/

#include <stdio.h>

#include <ctype.h>

#include <fcntl.h>

#define LOWER(a) (a >= ‘a’ && a <= ‘z’)

#define ALPHA(a) ((a >= ‘A’ && a <= ‘Z’) || LOWER(a))

#define SPACE(a) ((a >= 0x09 && a <= 0x0d) || a == ‘ ‘)

#define VOWEL(a) (a==’a’||a==’e’||a==’i’||a==’o’||a==’u’||\

a==’A’||a==’E’||a==’I’||a==’O’||a==’U’)

#define DIGIT(a) (a >= ‘0’ && a <= ‘9’)

#define LF(a) (a == 0x0a)

char *version = “Version 02.01.08”; /* Current version, Major, Minor */

char *release_date = “(c) 27-July-96”; /* release date */

char *TITLE = “Word count Ternary”; /* name of Program */

main(int argc,char *argv[])

{

int wc;

long a,v,cn,l,w,u,d,s,ln,cs; /* counters */

char ch; /* input character */

char c; /* same input character forced lower case */

FILE * fp, * fopen();

/* set everything to zero */

a=v=cn=l=u=d=s=ln=cs=w=0;

wc = 0;

fprintf(stderr,”\n\n%*c%s”,(80-strlen(TITLE))/2,’ ‘,TITLE);

fprintf(stderr,”\n%*c%s”,(80-strlen(version))/2,’ ‘,version);

fprintf(stderr,”\n%*cCopyright %s\n\n”,(80-strlen(release_date))/2-5

,’ ‘,release_date);

/* setmode(fileno(stdin),O_BINARY); */ /* force read of entire file */

fp=fopen(argv[1],”rb”);

while ((ch = getchar()) != EOF) { /* now get the characters from file */

/* compound ternary statements, whew it works */

SPACE(ch)?s++,(wc>=1)?w++:0,LF(ch)?ln++:0,(wc=0):ALPHA(ch)?a++,wc++,\

LOWER(ch)?l++:u++,VOWEL(ch)?v++:cn++:DIGIT(ch)?d++:cs++;

}

fprintf(stdout,”\n%*cType%*cCount\n%*calpha%*c%10ld\n%*clower-case%*c%10ld”

“\n%*cupper-case%*c%10ld\n%*cconsonants%*c%10ld”

“\n%*cvowels%*c%10ld\n%*cwhite-space%*c%10ld”,

6,’ ‘,30,’ ‘,6,’ ‘,24,’ ‘,a,6,’ ‘,19,’ ‘,l, /* show results */

6,’ ‘,19,’ ‘,u,6,’ ‘,19,’ ‘,cn,6,’ ‘,23,’ ‘,v,6,’ ‘,18,’ ‘,s);

fprintf(stdout,”\n%*cdigits%*c%10ld\n%*clines%*c%10ld\n%*cwords%*c%10ld”

“\n%*cmiscellaneous%*c%10ld\n%*ctotal characters%*c%10ld\n\n”,

6,’ ‘,23,’ ‘,d,6,’ ‘,24,’ ‘,ln,6,’ ‘,24,’ ‘,w,

6,’ ‘,16,’ ‘,cs,6,’ ‘,13,’ ‘,(a + s + d + cs));

fflush(stdout); /* flush buffer */

}

/*

end of code

*/

 

 If anyone has any questions about the program, just let me know and I’ll try to answer it here or privately. I’m sure there will be more. If you have a topic that you want some thoughts on, let me know. I’ll research it and then write something about it. I prefer to stay away from politics, but if pushed I’ll respond.

 Within the last year or so I’ve written a program that takes a preplaned trip and set an optimal (mine was 35 miles) from the course and makes a lists that can be downloaded to my Kenwood TS-700A or TH-D7ag radios. I later took this idea and wrote a program to get the location of criminals, in particulary child molesters and plot their distance from a centain location or route that a child may take to school, parks or where ever they may travel. You of course have to lay out the plot, but it will check on what ever distance you may choose to check on be it feet or miles. I’m disabled so there is not job to blame my lack of attendance, but since I am ill I may not always get right back to this.  My concentration is not what is required to program full time. I wonder how many copyright infrigments I’ve made so far. Unix, Linux and IBM are all trademarks or copyrights to someone or some organization.

Benny D. Miller Jr. ARS W4QED

 

Quod erat demonstrandum!

That which was to be demonstrated!

Advertisements