#!/bin/bash
#set -x
declare -a v_p
v_p=(error)
declare -a v_array
v_array=(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 + /)

#set +x
sub_input(){
v_end01=1;
while [ $v_end01 == 1 ]
do
case $1 in
A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|0|1|2|3|4|5|6|7|8|9|+|/)
export x=1
;;
*)
echo "Please input, like A A A A A B"
echo "The rule is like A(64^1) and B(64^0)...... in above example."
echo "There are six position"
exit   ###supplementary
;;
esac
for i in $(seq 0 63) ;
 do [ "$1" == "${v_array[$i]}" ] && v_p[0]=$i  && v_end01=0
 done;
done;

v_end02=1;
while [ $v_end02 == 1 ]
do
case $2 in
A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|0|1|2|3|4|5|6|7|8|9|+|/)
export x=1
;;
*)
echo "Please input, like A A A A A B"
echo "The rule is like A(64^1) and B(64^0)...... in above example."
echo "There are six position"
exit   ###supplementary
;;
esac
for j in $(seq 0 63) ;
 do [ "$2" == "${v_array[$j]}" ] && v_p[1]=$j  && v_end02=0
 done;
done;

v_end03=1;
while [ $v_end03 == 1 ]
do
case $3 in
A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|0|1|2|3|4|5|6|7|8|9|+|/)
export x=1
;;
*) exit   ###supplementary
;;
esac
for k in $(seq 0 63) ;
 do [ "$3" == "${v_array[$k]}" ] && v_p[2]=$k  && v_end03=0
 done;
done;

v_end04=1;
while [ $v_end04 == 1 ]
do
case $4 in
A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|0|1|2|3|4|5|6|7|8|9|+|/)
export x=1
;;
*)   ###supplementary
echo "Please input, like A A A A A B"
echo "The rule is like A(64^1) and B(64^0)...... in above example."
echo "There are six position"
exit   ###supplementary
;;
esac
for l in $(seq 0 63) ;
 do [ "$4" == "${v_array[$l]}" ] && v_p[3]=$l  && v_end04=0
 done;
done;

v_end05=1;
while [ $v_end05 == 1 ]
do
case $5 in
A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|0|1|2|3|4|5|6|7|8|9|+|/)
export x=1
;;
*)   ###supplementary
echo "Please input, like A A A A A B"
echo "The rule is like A(64^1) and B(64^0)...... in above example."
echo "There are six position"
exit   ###supplementary
;;
esac
for m in $(seq 0 63) ;
 do [ "$5" == "${v_array[$m]}" ] && v_p[4]=$m  && v_end05=0
 done;
done;

v_end06=1;
while [ $v_end06 == 1 ]
do
case $6 in
A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|0|1|2|3|4|5|6|7|8|9|+|/)
export x=1
;;
*)    ###supplementary
echo "Please input, like A A A A A B"
echo "The rule is like A(64^1) and B(64^0)...... in above example."
echo "There are six position"
exit   ###supplementary
;;
esac
for n in $(seq 0 63) ;
 do [ "$6" == "${v_array[$n]}" ] && v_p[5]=$n  && v_end06=0
 done;
done;
}

sub_input $1 $2 $3 $4 $5 $6
#set -x
#echo ${v_p[0]}
#echo ${v_p[1]}
#echo ${v_p[2]}
#echo ${v_p[3]}
#echo ${v_p[4]}
#echo ${v_p[5]}
echo "The rowid value is:"
echo "${v_p[0]}*(64^5)+${v_p[1]}*(64^4)+${v_p[2]}*(64^3)+${v_p[3]}*(64^2)+${v_p[4]}*(64^1)+${v_p[5]}*(64^0)" | bc