#!/bin/bash
#set -x
# @(#) list handy tables of character-related information .John S. Urban, converted from NOS CCL 1991
################################################################################
trap 'echo OUCH;$0' 1 2 3 15
export LANG;LANG=en_US.UTF-8
################################################################################
OCTAL(){
cat <<\octal
OCTAL
*-------*-------*-------*-------*-------*-------*-------*-------*
|000 nul|001 soh|002 stx|003 etx|004 eot|005 enq|006 ack|007 bel|
|010 bs |011 ht |012 nl |013 vt |014 np |015 cr |016 so |017 si |
|020 dle|021 dc1|022 dc2|023 dc3|024 dc4|025 nak|026 syn|027 etb|
|030 can|031 em |032 sub|033 esc|034 fs |035 gs |036 rs |037 us |
|040 sp |041 ! |042 " |043 # |044 $ |045 % |046 & |047 ' |
|050 ( |051 ) |052 * |053 + |054 , |055 - |056 . |057 / |
|060 0 |061 1 |062 2 |063 3 |064 4 |065 5 |066 6 |067 7 |
|070 8 |071 9 |072 : |073 ; |074 < |075 = |076 > |077 ? |
|100 @ |101 A |102 B |103 C |104 D |105 E |106 F |107 G |
|110 H |111 I |112 J |113 K |114 L |115 M |116 N |117 O |
|120 P |121 Q |122 R |123 S |124 T |125 U |126 V |127 W |
|130 X |131 Y |132 Z |133 [ |134 \ |135 ] |136 ^ |137 _ |
|140 ` |141 a |142 b |143 c |144 d |145 e |146 f |147 g |
|150 h |151 i |152 j |153 k |154 l |155 m |156 n |157 o |
|160 p |161 q |162 r |163 s |164 t |165 u |166 v |167 w |
|170 x |171 y |172 z |173 { |174 | |175 } |176 ~ |177 del|
*-------*-------*-------*-------*-------*-------*-------*-------*
octal
cat <<\EOF
EOF
}
################################################################################
CPP(){
cat <<\cpp
CPP
#ifdef NAME
#undef NAME
#define NAME
--------------------------------------------------------------------------------
#undef NOT2003
#ifdef SunOS
#define NOT2003
#endif
#ifdef HPUX
#define NOT2003
#endif
#ifdef NOT2003
USE F2KCLI
#endif
--------------------------------------------------------------------------------
#if defined(PC) || defined (SOLARIS)
--------------------------------------------------------------------------------
cpp
cat <<\EOF
EOF
}
################################################################################
FORTRAN(){
cat <<\fortran
$ifdef TESTPRG90
$endif
program krackenbasic
use M_kracken, only : kracken, retrev, lget, rget, iget, sgetl
implicit none
integer,parameter :: dp=kind(0.0d0)
real(kind=dp),save :: x(10)=0.0_dp
character(len=255) :: filename
character(len=20) :: device
logical :: lval
integer :: i_myloop
integer :: ier
integer :: iflen
integer :: ival
real :: rval
character(len=:), allocatable :: mystring
! define command arguments, default values
! and crack command line
call kracken('cmd','-i 10 -r 10e3 -l .false. -f input -d x11 -help .false. -version .false.')
if(lget('cmd_help'))then
call usage()
stop 1
endif
! get values
call retrev('cmd_f',filename,iflen,ier) ! get -f FILENAME
lval = lget('cmd_l') ! get -l present?
rval = rget('cmd_r') ! get -r RVAL
ival = iget('cmd_i') ! get -i IVAL
device = sgetl('cmd_i',20) ! get -d STRING
! all done parsing; do something with the values
print *, "filename=",filename(:iflen)
print *, " i=",ival, " r=",rval, " l=",lval
print *, " d="//device
!-----------------------------------------------------------------------
MYLOOP: do I_MYLOOP=1,10 ! DO loop
cycle MYLOOP ! start next pass of loop
exit MYLOOP ! go to next statment after corresponding ENDDO
enddo MYLOOP
!-----------------------------------------------------------------------
mystring='j'
select case(mystring)
case('*')
case('/')
case default
end select
!-----------------------------------------------------------------------
CHARACTER(LEN=1) :: c
SELECT CASE (c)
CASE ('a' : 'j')
WRITE(*,*) 'One of the first ten letters'
CASE ('l' : 'p', 'u' : 'y')
WRITE(*,*) 'One of l, m, n, o, p, u, v, w, x, y'
CASE ('z', 'q' : 't')
WRITE(*,*) 'One of z, q, r, s, t'
CASE DEFAULT
WRITE(*,*) 'Other characters, which may not be letters'
END SELECT
!-----------------------------------------------------------------------
An integer signum function:
INTEGER FUNCTION SIGNUM (N)
SELECT CASE (N)
CASE (:‐1)
SIGNUM = ‐1
CASE (0)
SIGNUM = 0
CASE (1:)
SIGNUM = 1
END SELECT
END
______------------------------------------------------------------------________
function mine() result(xx) ! note when RESULT used, function name has no type
implicit none
real :: xx
write(*,*)'VALUE=',xx
end function mine
!-----------------------------------------------------------------------
A code fragment to check for balanced parentheses:
CHARACTER (80) :: LINE
...
LEVEL = 0
SCAN_LINE: DO I = 1, 80
CHECK_PARENS: SELECT CASE (LINE (I:I))
CASE (’(’)
LEVEL = LEVEL + 1
CASE (’)’)
LEVEL = LEVEL ‐ 1
IF (LEVEL < 0) THEN
PRINT *, ’UNEXPECTED RIGHT PARENTHESIS’
EXIT SCAN_LINE
END IF
CASE DEFAULT
! Ignore all other characters
END SELECT CHECK_PARENS
END DO SCAN_LINE
IF (LEVEL > 0) THEN
PRINT *, ’MISSING RIGHT PARENTHESIS’
END IF
!-----------------------------------------------------------------------
The following three fragments are equivalent:
IF (SILLY == 1) THEN
CALL THIS
ELSE
CALL THAT
END IF
SELECT CASE (SILLY == 1)
CASE (.TRUE.)
CALL THIS
CASE (.FALSE.)
CALL THAT
END SELECT
SELECT CASE (SILLY)
CASE DEFAULT
CALL THAT
CASE (1)
CALL THIS
END SELECT
!-----------------------------------------------------------------------
A code fragment showing several selections of one block:
SELECT CASE (N)
CASE (1, 3:5, 8) ! Selects 1, 3, 4, 5, 8
CALL SUB
CASE DEFAULT
CALL OTHER
END SELECT
!-----------------------------------------------------------------------------------------------------------------------------------
contains
subroutine usage()
character(len=*),parameter :: ident="@(#)usage(3f,private): prints help for example(3f)"
character(len=80),allocatable :: help_text(:)
integer :: i
!-----------------------------------------------------------------------------------------------------------------------------------
help_text=[ &
&'12345678901234567890123456789012345678901234567890123456789012345678901234567890',&
&'This is example help text for the example program ',&
&'The example program uses kracken(3f) for command line parsing. ',&
&' ',&
&' ',&
&' ',&
&' ']
!-----------------------------------------------------------------------------------------------------------------------------------
WRITE(*,'(a)')(help_text(i),i=1,size(help_text))
end subroutine usage
!-----------------------------------------------------------------------------------------------------------------------------------
end program krackenbasic
!-----------------------------------------------------------------------------------------------------------------------------------
! optional arguments
SUBROUTINE write_text(string, nskip)
CHARACTER(*), INTENT(IN) :: string ! line of text
INTEGER, INTENT(IN), OPTIONAL :: nskip ! no of lines to skip
! local storage
INTEGER :: localskip
IF(PRESENT(nskip)) then
localskip = nskip
ELSE
localskip = 0 ! default value
END IF
! rest of code to skip lines etc.
!-----------------------------------------------------------------------
SUBROUTINE SAMPLE (ARRAY)
IMPLICIT NONE
REAL :: ARRAY( : )
INTEGER :: N
N = UBOUND(ARRAY,1) ! get the size of array without having to pass it
END
!-----------------------------------------------------------------------
program testit_scope ! scope of variables in program units
implicit none
character(len=80) :: title
title='this is a test'
write(*,*)'main program A ',title
call one()
call two()
write(*,*)'main program B ',title
call one()
contains ! variables in main program are seen if not declared locally
subroutine one()
write(*,*)'*one* ',title
title='new value from one'
end subroutine one
subroutine two()
character(len=80) :: title='this is two' ! declared now local
write(*,*)'*two* ',title
end subroutine two
end program testit_scope
!-----------------------------------------------------------------------
program odd ! implied shape array
! length must be constant, but size of array and length an asterisk
character(len=*),parameter :: array(*)=[ &
'line one ', &
'line two ', &
'line three ', &
'last line ']
! same for an allocatable array
! note an allocatable array can change size and cannot be initialized in the declaration
character(len=:),allocatable :: arrayallo(:)
arrayallo=[ &
'B: line one ', &
'B: line two ', &
'B: line three ', &
'B: last line ']
write(*,'(a)')array
write(*,'(a)')arrayallo
arrayallo=[ &
'C: longer line one ', &
'C: longer last line ']
write(*,'(a)')arrayallo
end program odd
!-----------------------------------------------------------------------
fortran
}
################################################################################
HTML(){
cat <<\html
PROCEDURE
OTHER COMMONLY USED OPTIONS:
class="centered"
align="bottom" align="center" align="left"
border="0"
style="border-width:0"
style="position:absolute;left:0;top:0"
unordered list
unordered list
.nf
.nf
html
}
################################################################################
SHELL(){
cat <<\shell
================================================================================
# select editor:
# use $FCEDIT, then $EDITOR, then $VISUAL, then vi
# $FCEDIT - edit mode for bash(1) and korn(1) shell
# $EDITOR - common variable used for this purpose (tcsh,...)
# $VISUAL - common variable used for this purpose (tcsh,...)
EDIT=${FCEDIT:-${EDITOR:-${VISUAL:-vi}}}
#######################################
if [ -f /usr/bin/file ]
then
:
fi
#######################################
case "$NAME" in
one|1) echo one ;;
two|2|T*[2-4]|three|four) echo $NAME ;;
*) echo unknown ;;
esac
#######################################
================================================================================
Many times, scripters will use external commands like basename, dirname and
tr because they don't realize they can instead use ksh and bash builtins.
An added bonus is the builtins are faster and require less system resources
because no sub-process is spawned.
basename replacement:
---------------------
$ fullfile="/some/dir/file.txt"
# replaced: file=$(basename $fullfile)
$ file=${fullfile##*/}
$ echo $file
file.txt
dirname replacement:
--------------------
$ fullfile="/some/dir/file.txt"
# replaced: dir=$(dirname $fullfile)
$ dir=${fullfile%/*}
$ echo $dir
/some/dir
tr replacements:
----------------
$ word="MiXeD"
# replaced: word=$(echo $word | tr [A-Z] [a-z])
$ typeset -l word
$ echo $word
mixed
# replaced: word=$(echo $word | tr [a-z] [A-Z])
$ typeset -u word
$ echo $word
MIXED
The following "sed" line "normalizes" this input replacing each
sequence of two or more whitespace characters with exactly one
character:
sed 's/ [ ][ ]*//g'
Substitute the five characters "" with a "real" TAB character
================================================================================
================================================================================
shell
}
################################################################################
LINUX(){
cat <<\linux
Linux -- The choice of a GNU generation
UNIX is user friendly. It's just selective about who its friends are.
As far as we know, our computer has never had an undetected error.
linux
}
################################################################################
CTRL(){
cat <<\ctrl
CONTROL KEY PRESSES
ASCII HEX VALUES, ANSI NAMES, AND COMMON KEY STROKES
TO PRODUCE THE ASCII CONTROL CHARACTERS:
00 (NUL) ctrl ? NULL 10 (DLE) ctrl P DATA LINK ESCAPE
01 (SOH) ctrl A START OF HEADING 11 (DC1) ctrl Q DEVICE CONTROL 1
02 (STX) ctrl B START OF TEXT 12 (DC2) ctrl R DEVICE CONTROL 2
03 (ETX) ctrl C END OF TEXT 13 (DC3) ctrl S DEVICE CONTROL 3
04 (EOT) ctrl D END OF TRANSMISSION 14 (DC4) ctrl T DEVICE CONTROL 4
05 (ENQ) ctrl E ENQUIRY 15 (NAK) ctrl U NEGATIVE ACKNOWLEDGE
06 (ACK) ctrl F ACKNOWLEDGE 16 (SYN) ctrl V SYNCHRONOUS IDLE
07 (BEL) ctrl G BELL 17 (ETB) ctrl W END OF TRANSMISSION BLOCK
08 (BS) ctrl H BACKSPACE 18 (CAN) ctrl X CANCEL
09 (HT) ctrl I HORIZONTAL TABULATION 19 (EM) ctrl Y END OF MEDIUM
0A (LF) ctrl J LINE FEED 1A (SUB) ctrl Z SUBSTITUTE
0B (VT) ctrl K VERTICAL TABULATION 1B (ESC) ctrl [ ESCAPE
0C (FF) ctrl L FORM FEED or NEW PAGE 1C (FS) ctrl @ FILE SEPARATOR
0D (CR) ctrl M CARRIAGE RETURN 1D (GS) ctrl ] GROUP SEPARATOR
0E (SO) ctrl N SHIFT OUT 1E (RS) ctrl = RECORD SEPARATOR
0F (SI) ctrl O SHIFT IN 1F (US) ctrl _ UNIT SEPARATOR
ALTERNATE -- the same as above except
00 (NUL) ctrl @ NULL
1C (FS) ctrl \ FILE SEPARATOR
1E (RS) ctrl ^ RECORD SEPARATOR
7F (DEL) ctrl ? DELETE
Many terminals have separate return, backspace, horizontal tab, and escape keys.
ctrl
}
################################################################################
SEMAPHORE(){
cat <<\semaphore
ALPHA FOXTROT KILO PAPA UNIFORM ZULU
BRAVO GOLF LIMA QUEBEC VICTOR
CHARLIE HOTEL MIKE ROMEO WHISKEY
DELTA INDIA NOVEMBER SIERRA XRAY
ECHO JULIET OSCAR TANGO YANKEE
semaphore
}
################################################################################
SEMAPHORE_SPELL(){
echo "$*"
echo ''
for LETTER in `echo $* |tr '[A-Z ]' '[a-z\a]'|sed -e 's/./& /g'`
do
printf ' '
case "$LETTER" in
a)printf ALPHA;;
f)printf FOXTROT;;
k)printf KILO;;
p)printf PAPA;;
u)printf UNIFORM;;
z)printf ZULU;;
b)printf BRAVO;;
g)printf GOLF;;
l)printf LIMA;;
q)printf QUEBEC;;
v)printf VICTOR;;
c)printf CHARLIE;;
h)printf HOTEL;;
m)printf MIKE;;
r)printf ROMEO;;
w)printf WHISKEY;;
d)printf DELTA;;
i)printf INDIA;;
n)printf NOVEMBER;;
s)printf SIERRA;;
x)printf XRAY;;
e)printf ECHO;;
j)printf JULIET;;
o)printf OSCAR;;
t)printf TANGO;;
y)printf YANKEE;;
*)printf "$LETTER";;
esac
printf '\n'
done
echo " "
}
################################################################################
HEXADECIMAL(){
cat <<\hx
HEXADECIMAL
*-------*-------*-------*-------*-------*-------*-------*-------*
| 00 nul| 01 soh| 02 stx| 03 etx| 04 eot| 05 enq| 06 ack| 07 bel|
| 08 bs | 09 ht | 0a nl | 0b vt | 0c np | 0d cr | 0e so | 0f si |
| 10 dle| 11 dc1| 12 dc2| 13 dc3| 14 dc4| 15 nak| 16 syn| 17 etb|
| 18 can| 19 em | 1a sub| 1b esc| 1c fs | 1d gs | 1e rs | 1f us |
| 20 sp | 21 ! | 22 " | 23 # | 24 $ | 25 % | 26 & | 27 ' |
| 28 ( | 29 ) | 2a * | 2b + | 2c , | 2d - | 2e . | 2f / |
| 30 0 | 31 1 | 32 2 | 33 3 | 34 4 | 35 5 | 36 6 | 37 7 |
| 38 8 | 39 9 | 3a : | 3b ; | 3c < | 3d = | 3e > | 3f ? |
| 40 @ | 41 A | 42 B | 43 C | 44 D | 45 E | 46 F | 47 G |
| 48 H | 49 I | 4a J | 4b K | 4c L | 4d M | 4e N | 4f O |
| 50 P | 51 Q | 52 R | 53 S | 54 T | 55 U | 56 V | 57 W |
| 58 X | 59 Y | 5a Z | 5b [ | 5c \ | 5d ] | 5e ^ | 5f _ |
| 60 ` | 61 a | 62 b | 63 c | 64 d | 65 e | 66 f | 67 g |
| 68 h | 69 i | 6a j | 6b k | 6c l | 6d m | 6e n | 6f o |
| 70 p | 71 q | 72 r | 73 s | 74 t | 75 u | 76 v | 77 w |
| 78 x | 79 y | 7a z | 7b { | 7c | | 7d } | 7e ~ | 7f del|
*-------*-------*-------*-------*-------*-------*-------*-------*
hx
}
################################################################################
DECIMAL(){
cat <<\decimal
DECIMAL
*-------*-------*-------*-------*-------*-------*-------*-------*
| 00 nul| 01 soh| 02 stx| 03 etx| 04 eot| 05 enq| 06 ack| 07 bel|
| 08 bs | 09 ht | 10 nl | 11 vt | 12 np | 13 cr | 14 so | 15 si |
| 16 dle| 17 dc1| 18 dc2| 19 dc3| 20 dc4| 21 nak| 22 syn| 23 etb|
| 24 can| 25 em | 26 sub| 27 esc| 28 fs | 29 gs | 30 rs | 31 us |
| 32 sp | 33 ! | 34 " | 35 # | 36 $ | 37 % | 38 & | 39 ' |
| 40 ( | 41 ) | 42 * | 43 + | 44 , | 45 - | 46 . | 47 / |
| 48 0 | 49 1 | 50 2 | 51 3 | 52 4 | 53 5 | 54 6 | 55 7 |
| 56 8 | 57 9 | 58 : | 59 ; | 60 < | 61 = | 62 > | 63 ? |
| 64 @ | 65 A | 66 B | 67 C | 68 D | 69 E | 70 F | 71 G |
| 72 H | 73 I | 74 J | 75 K | 76 L | 77 M | 78 N | 79 O |
| 80 P | 81 Q | 82 R | 83 S | 84 T | 85 U | 86 V | 87 W |
| 88 X | 89 Y | 90 Z | 91 [ | 92 \ | 93 ] | 94 ^ | 95 _ |
| 96 ` | 97 a | 98 b | 99 c |100 d |101 e |102 f |103 g |
|104 h |105 i |106 j |107 k |108 l |109 m |110 n |111 o |
|112 p |113 q |114 r |115 s |116 t |117 u |118 v |119 w |
|120 x |121 y |122 z |123 { |124 | |125 } |126 ~ |127 del|
*-------*-------*-------*-------*-------*-------*-------*-------*
decimal
}
################################################################################
PHONE(){
cat <<\phone
PHONE
*---------*---------*---------*
| 1 | 2 ABC | 3 DEF |
| 4 GHI | 5 JKL | 6 MNO |
| 7 PRS | 8 TUV | 9 WXY |
| * | 0 | # |
*---------*---------*---------*
phone
}
################################################################################
C(){
C_CODE
OPERATORS
}
################################################################################
C_CODE(){
cat <<\c
Oct Dec Hex Char
-----------------------
000 0 00 NUL '\0' Null
007 7 07 BEL '\a' Bell
010 8 08 BS '\b' Backspace
011 9 09 HT '\t' Horizontal Tab
012 10 0A LF '\n' Line Feed
013 11 0B VT '\v' Vertical Tab
014 12 0C FF '\f' Form Feed
015 13 0D CR '\r' Carriage Return
134 92 5C \ '\\' Backslash
------------------------------------------------------------------------------------------
#include
main(){
int i;
int intvalue;
/* FOR ------------------ */
for(i=0;i<256;i++){
/* decimal, hexadecimal, octal, character */
fprintf(stdout,"%d %x %o %c \n",i,i,i,i);
}
/* SWITCH ------------------ */
switch (intvalue) {
case -1: ; fprintf(stderr,"value of %d\n",intvalue) ; break;
case 0: ; break;
case 1: ; break;
case 'c': ; break;
default:
}
/* IF --------------------- */
if (expression) {
Block of statements;
} else if (expression) {
Block of statements;
} else {
Block of statements;
}
---------------------
}
------------------------------------------------------------------------------------------
c
}
################################################################################
PHONENUMS(){
# convert string to uppercase and put a space between each character
LETTERS=`echo "$@"|tr '[a-z] ' '[A-Z]%'|sed -e's%.%& %g'`
ANSWER=''
for NAME in $LETTERS
do
case "$NAME"
in
A|B|C) ANSWER=${ANSWER}2 ;;
D|E|F) ANSWER=${ANSWER}3 ;;
G|H|I) ANSWER=${ANSWER}4 ;;
J|K|L) ANSWER=${ANSWER}5 ;;
M|N|O) ANSWER=${ANSWER}6 ;;
P|R|S) ANSWER=${ANSWER}7 ;;
T|U|V) ANSWER=${ANSWER}8 ;;
W|X|Y) ANSWER=${ANSWER}9 ;;
[0-9]|'#'|'*') ANSWER=${ANSWER}$NAME ;;
Q|Z) ANSWER=${ANSWER}? ;;
*) ANSWER=${ANSWER}? ;;
esac
done
echo "$@"
echo "$ANSWER"
# *---------*---------*---------*
# | 1 | 2 ABC | 3 DEF |
# | 4 GHI | 5 JKL | 6 MNO |
# | 7 PRS | 8 TUV | 9 WXY |
# | * | 0 | # |
# *---------*---------*---------*
}
################################################################################
LOG(){
cat <<\EOF
The following formulae express relations on which much of the use of
logarithms is based:
log(ab) = log(a) + log(b)
log(a/b) = log(a) - log(b)
log(a**n) = n * log(a)
log(a**(-n))= log(a) / n
A change of base can be accomplished using
log_to_base_a(X) = log_to_base_b(X)/log_to_base_b(A)
For example (Using FORTRAN notation where log(x) means natural log):
log10(x) == log(x)/log(10)
log(x) == log10(x)/log10(e)
where e = exp(1) = 2.7183....
EOF
}
################################################################################
CONSTANT(){
cat <<\EOF
________________________________________________________________________________
pi 3.14159265358979323846264338327950288419716939937510...
π 3.14159265358979323846264338327950288419716939937510...
e 2.7182818284590452353602874...
________________________________________________________________________________
The golden ratio : (1+sqrt(5))/2.
1.61803398874989484820458683436563811772030917980576286213544862270526046281890...
________________________________________________________________________________
EOF
}
################################################################################
QUADRATIC(){
cat <<\EOF
Any quadratic equation may be reduced to the form
a*x**2 + b*x +c = 0
Then
x = (-b +- sqrt(b**2 - 4*a*c))/ (2*a)
If
b**2 - 4*a*c > 0 the roots are real and unequal
= 0 the roots are real and equal
< 0 the roots are imaginary and unequal
is a perfect square roots are rational and unequal
EOF
}
################################################################################
NULL(){
cat <<\EOF
EOF
}
################################################################################
MAKEFILE(){
cat <<\EOF
#===============================================================================
# Makefile - Generated May 21, 1996
# John S. Urban
#@(#) Makefile for BANNER block letter generator
#===============================================================================
SHELL=/bin/sh
PUTMAN=/usr/local/man
AR=ar
ARFLAGS=rv
PUTBIN=/usr/users/urbanjs/V6/bin/OSF1/
INSTALL=/usr/users/urbanjs/V6/lib/OSF1/
#===============================================================================
all: $(PUTBIN)/banner
#===============================================================================
$(PUTBIN)/banner: banner.c
ccall ${@F}.c
#===============================================================================
man: $(PUTMAN)/man1/banner.1 $(PUTMAN)/man1/banner.1
$(PUTMAN)/man1/banner.1: banner.1
cp banner.1 $(PUTMAN)/man1/banner.1
chmod a+xr $(PUTMAN)/man1/banner.1
#===============================================================================
include ../makefiles/INSTALL.mk
# build main program NSAPLOT
all: directory
-banner BANNER; cd BANNER; $(MAKE) INSTALL="$(INSTALL)" PUTBIN=$(PUTBIN)
-banner NSAPLOT; cd NSAPLOT; $(MAKE) INSTALL="$(INSTALL)" PUTBIN=$(PUTBIN)
-banner XEDIT; cd XEDIT; $(MAKE) -e INSTALL="$(INSTALL)" PUTBIN=$(PUTBIN)
#===============================================================================
# run thru a special print queue that numbers lines, prints comments in blue,
# and creates an alphabetized and sequential index and starts new routines at
# top of page
print:
lp -dlaser -oBSDJ'[[cmdpipe=fcode,dest=nsblue]] `find $(PUTBIN)/../.. -name flint.f`
# lpr -Plaser -J'[[cmdpipe=fcode,dest=nsblue]] 'find $(PUTBIN)/../.. -name flint.f`
#===============================================================================
# ensure directory executables are to be placed in exists
directory:
@echo PUTBIN=$(PUTBIN)
@echo INSTALL=$(INSTALL)
@echo PUTMAN=$(PUTMAN)
# @echo $? @ $# @ $< @ $* @ $@
# @echo ${?F} @ ${FF} @ ${
077 63 3F ?
100 64 40 @
101 65 41 A
102 66 42 B
103 67 43 C
104 68 44 D
105 69 45 E
106 70 46 F
107 71 47 G
110 72 48 H
111 73 49 I
112 74 4A J
113 75 4B K
114 76 4C L
115 77 4D M
116 78 4E N
117 79 4F O
120 80 50 P
121 81 51 Q
122 82 52 R
123 83 53 S
124 84 54 T
125 85 55 U
126 86 56 V
127 87 57 W
130 88 58 X
131 89 59 Y
132 90 5A Z
133 91 5B [
134 92 5C \ '\\'
135 93 5D ]
136 94 5E ^
137 95 5F _
140 96 60 `
141 97 61 a
142 98 62 b
143 99 63 c
144 100 64 d
145 101 65 e
146 102 66 f
147 103 67 g
150 104 68 h
151 105 69 i
152 106 6A j
153 107 6B k
154 108 6C l
155 109 6D m
156 110 6E n
157 111 6F o
160 112 70 p
161 113 71 q
162 114 72 r
163 115 73 s
164 116 74 t
165 117 75 u
166 118 76 v
167 119 77 w
170 120 78 x
171 121 79 y
172 122 7A z
173 123 7B {
174 124 7C |
175 125 7D }
176 126 7E ~
177 127 7F DEL
A
}
################################################################################
OPERATORS(){
cat <<\EOF
OPERATOR PRECEDENCE SUMMARY
-----------------------------------------------------------------------
Operator Description Associativity
-----------------------------------------------------------------------
() Function call Left to Right
[] Array element reference
-> Pointer to Structure member reference
. Structure member reference
-----------------------------------------------------------------------
- Unary minus Right to Left
+ Unary plus
++ Increment
-- Decrement
! Logical negation
~ One's complement
* Pointer reference (indirection)
& Address
sizeof Size of an object
(type) Type cast (conversion)
-----------------------------------------------------------------------
* Multiplication Left to Right
/ Division
% Modulus
-----------------------------------------------------------------------
+ Addition Left to Right
- Subtraction
-----------------------------------------------------------------------
<< Left Shift Left to Right
>> Right Shift
-----------------------------------------------------------------------
< Less than Left to Right
<= Less than or equal to
> Greater than
>= Greater than or equal to
-----------------------------------------------------------------------
== Equality Left to Right
!= Inequality
-----------------------------------------------------------------------
& Bitwise AND Left to Right
-----------------------------------------------------------------------
^ Bitwise XOR Left to Right
-----------------------------------------------------------------------
| Bitwise OR Left to Right
-----------------------------------------------------------------------
&& Logical AND Left to Right
-----------------------------------------------------------------------
|| Logical OR Left to Right
-----------------------------------------------------------------------
?: Conditional Right to Left
-----------------------------------------------------------------------
=
*= /= %=
+= -= &= Assignment Operators Right to Left
^= |=
<<= =>>
-----------------------------------------------------------------------
, Comma Operator Left to Right
-----------------------------------------------------------------------
1
ARITHMETIC OPERATORS
--------------------
Operator Action
- Subtraction
+ Addition
* Multiplication
/ Division
% Modulus Division
-- Decrement
++ Increment
--------------------
RELATIONAL OPERATORS
Operator Action
> Greater Than
>= Greater than or Equal
< Less Than
<= Less than or equal
== Equal
!= Not equal
---------------------
LOGICAL OPERATORS
Operator Action
&& AND
|| OR
! NOT
---------------------
BITWISE OPERATORS
Operator Action
& AND
| OR
^ Exclusive OR (XOR)
~ One's complement
>> Shift right
<< Shift left
---------------------
ASSIGNMENT OPERATORS
Operator Action Equivalence
= Assign
*= x*=2 ......... (x = x * 2)
/= a /= b + c ......... a= a / (b + c)
%= a %= b .........
+= .........
-=
&=
^=
|=
<<=
=>>
---------------------
EOF
}
################################################################################
PAUSE(){
echo Enter [RETURN] to continue
read line
}
################################################################################
ALL(){
#show all tables
CPP;PAUSE
CTRL;PAUSE
DECIMAL;PAUSE
HEXADECIMAL;PAUSE
HTML;PAUSE
LINUX;PAUSE
OCTAL;PAUSE
FORTRAN;PAUSE
MAKEFILE;PAUSE
PHONE;PAUSE
C;PAUSE
OPERATORS;PAUSE
HEXHINTS;PAUSE
GREEK;PAUSE
LOG;PAUSE
CONSTANT;PAUSE
SHELL;PAUSE
QUADRATIC;PAUSE
SI_UNITS;PAUSE
}
################################################################################
USAGE=" $0 [-c ][-d ][-f ][-h ][-w][-H][-p ][-C][-o][-O] [-P string]
Display useful tables
a ASCII: decimal, hexadecimal, octal, C code,
A ALL
b bash shell:
c control: keyboard sequences used to generate most control characters
C code: \N syntax for C programs
d decimal:
f fortran: Fortran hints
G Greek Alphabet Names
h hexadecimal:
H hints on manually converting between bases
i cpp directives (#if/#else/#endif...)
k constants
l logarithmic rules
L Linux phrases
M Makefile
o octal:
O Operators for C code
p phone:
P phone numbers: given a word, spell it out in numbers on a phone pad
q quadratric rules
s semaphore:
S spell out in semaphore:
U SI Unit prefixes
w web(html):
"
################################################################################
errflg=0
while getopts ACGHLMOP:S:Uabcdfhiklopqsuw O
do
case $O in
A) ALL ;;
a) DHO ;;
b) SHELL ;;
C) C ;;
c) CTRL ;;
d) DECIMAL ;;
f) FORTRAN ;;
G) GREEK;;
H) HEXHINTS ;;
h) HEXADECIMAL ;;
i) CPP ;;
k) CONSTANT ;;
L) LINUX;;
l) LOG;;
M) MAKEFILE;;
O) OPERATORS ;;
o) OCTAL ;;
P)
if [ "$OPTARG" = '' ]
then
printf 'enter string :'
set $NAME
read STRING
PHONENUMS $STRING
else
PHONENUMS "$OPTARG"
fi
;;
p) PHONE ;;
S) SEMAPHORE_SPELL "$OPTARG" ;;
s) SEMAPHORE ;;
U) SI_UNITS ;;
q) QUADRATIC ;;
\? | u) errflg=1;;
w) HTML ;;
esac
done
shift `expr $OPTIND - 1`
################################################################################
# if error flag set or an unprocessed word was encountered show usage and quit
if [ $errflg -ne 0 -o $# -ne 0 ]
then
echo "$USAGE" >&2
exit 2
elif [ $OPTIND -ne 1 ]
then
# parameters were present and all of them were processed
exit 0
fi
################################################################################
# command with no parameters was entered
#############################################
NULL=
select NAME in \
'ALL' \
'C' \
'SHELL' \
'CONSTANT' \
'CTRL' \
'DECIMAL' \
'DHO' \
'FORTRAN' \
'GREEK' \
'HEXADECIMAL' \
'HEXHINTS' \
'HTML' \
'LOG' \
'MAKEFILE' \
'OCTAL' \
'CPP' \
'OPERATORS' \
'PHONE' \
'PHONENUMS "$OPTARG"' \
'QUADRATIC' \
'SI_UNITS' \
'SEMAPHORE' \
'SEMAPHORE_SPELL "$OPTARG"' \
quit \
$NULL
do
#echo "1: REPLY [$REPLY] NAME [$NAME]"
NAME=${NAME:-$REPLY}
#echo "2: REPLY [$REPLY] NAME [$NAME]"
#--------------------------------------------
case "$NAME" in
#--------------------------------------------
help) HELP ;;
#--------------------------------------------
quit|q|.) break ;;
#--------------------------------------------
'PHONENUMS "$OPTARG"'|\
'SEMAPHORE_SPELL "$OPTARG"')
(
printf 'enter string :'
set $NAME
read STRING
$1 $STRING
)
;;
#--------------------------------------------
'ALL'|\
'C'|\
'CONSTANT'|\
'CTRL'|\
'DECIMAL'|\
'DHO'|\
'FORTRAN'|\
'GREEK'|\
'HEXADECIMAL'|\
'HEXHINTS'|\
'HTML'|\
'LOG'|\
'MAKEFILE'|\
'OCTAL'|\
'CPP'|\
'PHONE'|\
'QUADRATIC'|\
'SI_UNITS'|\
'SEMAPHORE'|\
'SHELL'|\
'OPERATORS')
(
exec 2>&1