[HTC One SV] :
My script is causing me some grief while trying to figure out a way to port the "keyboardtemplate".

I have been able to port everything else.

Inside the keyboardtemplate are "key" and "long" values but due to these values coming up as multilines I'm having difficulty parsing them to be read and then modified correctly. I am tackling this at every angle I can think of but it hasn't been easy.

I'm going to share my script in case someone with some scripting intelligence is able to review it and come up with a solution. Meanwhile, I don't recommend using this script until I give the ok - it is NOT finished!

#!/system/bin/sh

# Have user input both resolutions and the storage location of the ui.xml file to be ported.
# If input is invalid then loop back to the function until they get it right.
BASE_DEVICE() {
clear; echo Enter your resolution, ex. 480x800:
read BASE_RESOLUTION
B_RES_W=$(echo $BASE_RESOLUTION | egrep -o '[0-9]+x' | egrep -o '[0-9]+')
B_RES_H=$(echo $BASE_RESOLUTION | egrep -o 'x[0-9]+' | egrep -o '[0-9]+')
BASE_RESOLUTION_CHECK=$(echo $B_RES_W'x'$B_RES_H)
if [ "$BASE_RESOLUTION" == "$BASE_RESOLUTION_CHECK" ] ; then
# Your Resolution
BASEW=$(echo $B_RES_W)
BASEH=$(echo $B_RES_H)
else
echo " "
echo Please input correct layout for your resolution.
echo An example would be, 480x800.
echo " "
echo Press ANY key when ready...
read -n1 any_key
clear; BASE_DEVICE
fi
}

PORT_DEVICE() {
clear; echo Enter their resolution, ex. 720x1280:
read PORT_RESOLUTION
P_RES_W=$(echo $PORT_RESOLUTION | egrep -o '[0-9]+x' | egrep -o '[0-9]+')
P_RES_H=$(echo $PORT_RESOLUTION | egrep -o 'x[0-9]+' | egrep -o '[0-9]+')
PORT_RESOLUTION_CHECK=$(echo $P_RES_W'x'$P_RES_H)
if [ "$PORT_RESOLUTION" == "$PORT_RESOLUTION_CHECK" ] ; then
# Their Resolution
PORTW=$(echo $P_RES_W)
PORTH=$(echo $P_RES_H)
else
echo " "
echo Please input correct layout for their resolution.
echo An example would be, 720x1280.
echo " "
echo Press ANY key when ready...
read -n1 any_key
clear; PORT_DEVICE
fi
}

UI_DIRECTORY() {
clear; echo Enter directory to the ui.xml file, ex. /sdcard/TWRP:
read PORT_XML
# Check to see if directory exists
if [ -d "$PORT_XML" ] ; then
PORT_UI=$(echo $PORT_XML)
else
echo " "
echo $PORT_XML is not a directory
echo " "
echo Press ANY key when ready...
read -n1 any_key
clear; UI_DIRECTORY
fi
}

# Call on functions here for user friendliness.
# Let user know about the ui.xml file.
clear; echo Insure that the .xml file is still named, ui.xml, or this script will fail!
sleep 5
UI_DIRECTORY
BASE_DEVICE
PORT_DEVICE

# Call this function during the while loop.
CALCULATE_WIDTH() {
# Calculate old size for new size of each value.
MODW=$(awk 'BEGIN{print "'$PORTW'"/"'$SIZEW'"}')
NEWW=$(awk 'BEGIN{print "'$BASEW'"/"'$MODW'"}')
# Round fractions up and down for each value.
FINALW=$(awk 'BEGIN{print int("'$NEWW'"+0.5)}')
}

# Call this function during the while loop.
CALCULATE_HEIGHT() {
# Calculate old size for new size of each value.
MODH=$(awk 'BEGIN{print "'$PORTH'"/"'$SIZEH'"}')
NEWH=$(awk 'BEGIN{print "'$BASEH'"/"'$MODH'"}')
# Round fractions up and down for each value.
FINALH=$(awk 'BEGIN{print int("'$NEWH'"+0.5)}')
}

# Call this function in the while loop for values which needs assistance from the human mind.
DONT_KNOW_JACK() {
if [ "$HUMAN_ANSWER" == "h" -o "$HUMAN_ANSWER" == "H" ] ; then
# Need this variable to calculate.
SIZEH=$(echo $VALUE_CONFIRM)
CALCULATE_HEIGHT
echo " "
echo Porting value="'$VALUE_CONFIRM'" to value="'$FINALH'"
SED_CHANGE_WORD "$VALUE_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
else
# Need this variable to calculate.
SIZEW=$(echo $VALUE_CONFIRM)
CALCULATE_WIDTH
echo " "
echo Porting value="'$VALUE_CONFIRM'" to value="'$FINALW'"
SED_CHANGE_WORD "$VALUE_CONFIRM" "$FINALW" "$PORT_UI/$FILE"
fi
}

# Sets variables for changing requested text.
# Call this function during the while loop.
SED_CHANGE_WORD() {
# $1 - What we're changing
# $2 - To what we're changing
# $3 - File location for that
# $4 - Unique delimiter (optional)
if [[ -z "$4" ]]; then
sed -i 's/'"$1"'/'"$2"'/g' "$3"
else
sed -i 's'"$4""$1""$4""$2""$4"'g' "$3"
fi
}

# Need to write to two new files in order to modify the xml line by line properly.
# TEMPFILE is located in the while loop.
TEMPFILE=$(echo TEMPUIPORT.xml)
FILE=$(echo CONVERTUI.xml)
if [ ! -f "$PORT_UI/$FILE" ]; then
touch $PORT_UI/$FILE
else
rm -f $PORT_UI/$FILE
touch $PORT_UI/$FILE
fi

# Read the ui.xml file so we can find the proper values for a successful port.
# Pipe in echo to insure the last line 'EOF' is read and the script doesn't quit on it.
# Add 'IFS=' to insure each line read still contains it's tabs.
clear; { cat $PORT_UI/ui.xml; echo; } | while IFS= read line; do
if [ -f "$PORT_UI/$TEMPFILE" ]; then
ECHO=$(cat "$PORT_UI/$FILE")
echo "$ECHO" >> $PORT_UI/$TEMPFILE
# The script needs to be put on hold to insure it echoes accordingly and does not overlook any lines.
wait </dev/tty
else
touch $PORT_UI/$TEMPFILE
fi
echo "$line" > $PORT_UI/$FILE
# The script needs to be put on hold to insure it echoes accordingly and does not overlook any lines.
wait </dev/tty
# Search for x values.
XX() {
X=$(echo "$line" | egrep -o 'x="[0-9]+"' | egrep -o '[0-9]+')
if [ -z "$X" -o "$X" == "0" -o "$X" == "0123456789" ]; then
# Dump empty value.
echo null > /dev/null
# Call the YY function.
YY
else
# Save the value in a variable.
X_CONFIRM=$(echo $X)
# Need this variable to calculate.
SIZEW=$(echo $X_CONFIRM)
CALCULATE_WIDTH
echo Porting x="'$X_CONFIRM'" to x="'$FINALW'"
SED_CHANGE_WORD "$X_CONFIRM" "$FINALW" "$PORT_UI/$FILE"
# Call the YY function.
YY
fi
}
# Search for y values.
YY() {
Y=$(echo "$line" | egrep -o 'y="[0-9]+"' | egrep -o '[0-9]+')
if [ -z "$Y" -o "$Y" == "0" -o "$Y" == "0123456789" ]; then
# Dump empty value.
echo null > /dev/null
# Call the WWIDTH function.
WWIDTH
else
# Save the value in a variable.
Y_CONFIRM=$(echo $Y)
# Need this variable to calculate.
SIZEH=$(echo $Y_CONFIRM)
CALCULATE_HEIGHT
echo Porting y="'$Y_CONFIRM'" to y="'$FINALH'"
SED_CHANGE_WORD "$Y_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call the WWIDTH function.
WWIDTH
fi
}
# Search for width 'width=' values.
WWIDTH() {
WIDTH=$(echo "$line" | egrep -o 'width="[0-9]+"' | egrep -o '[0-9]+')
if [ -z "$WIDTH" -o "$WIDTH" == "0" -o "$WIDTH" == "0123456789" ]; then
# Dump empty values.
echo null > /dev/null
# Call the HHEIGHT function.
HHEIGHT
else
# Save the value in a variable.
WIDTH_CONFIRM=$(echo $WIDTH)
# Need this variable to calculate.
SIZEW=$(echo $WIDTH_CONFIRM)
CALCULATE_WIDTH
echo Porting width="'$WIDTH_CONFIRM'" to width="'$FINALW'"
SED_CHANGE_WORD "$WIDTH_CONFIRM" "$FINALW" "$PORT_UI/$FILE"
# Call the HHEIGHT function.
HHEIGHT
fi
}
# Search for height 'height=' values.
HHEIGHT() {
HEIGHT=$(echo "$line" | egrep -o 'height="[0-9]+"' | egrep -o '[0-9]+')
if [ -z "$HEIGHT" -o "$HEIGHT" == "0" -o "$HEIGHT" == "0123456789" ]; then
# Dump empty values.
echo null > /dev/null
# Call the HH function.
HH
else
# Save the value in a variable.
HEIGHT_CONFIRM=$(echo $HEIGHT)
# Need this variable to calculate.
SIZEH=$(echo $HEIGHT_CONFIRM)
CALCULATE_HEIGHT
echo Porting height="'$HEIGHT_CONFIRM'" to height="'$FINALH'"
SED_CHANGE_WORD "$HEIGHT_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call the HH function.
HH
fi
}
# Search for height 'h=' values.
HH() {
H=$(echo "$line" | egrep -o 'h="[0-9]+"' | egrep -o '[0-9]+')
if [ -z "$H" -o "$H" == "0" -o "$H" == "0123456789" ]; then
# Dump empty values.
echo null > /dev/null
# Call the WW function.
WW
else
# Save the value in a variable.
H_CONFIRM=$(echo $H)
# Need this variable to calculate.
SIZEH=$(echo $H_CONFIRM)
CALCULATE_HEIGHT
echo Porting h="'$H_CONFIRM'" to h="'$FINALH'"
SED_CHANGE_WORD "$H_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call the WW function.
WW
fi
}
# Search for width 'w=' values.
WW() {
W=$(echo "$line" | egrep -o 'w="[0-9]+"' | egrep -o '[0-9]+')
if [ -z "$W" -o "$W" == "0" -o "$W" == "0123456789" ]; then
# Dump empty values.
echo null > /dev/null
# Call the LLONG function.
LLONG
else
# Save the value in a variable.
W_CONFIRM=$(echo $W)
# Need this variable to calculate.
SIZEW=$(echo $W_CONFIRM)
CALCULATE_WIDTH
echo Porting w="'$W_CONFIRM'" to w="'$FINALW'"
SED_CHANGE_WORD "$W_CONFIRM" "$FINALW" "$PORT_UI/$FILE"
# Call the LLONG function.
LLONG
fi
}
# Search for Long Key 'long##=' values.
LLONG() {
LONGKEY=$(echo "$line" | egrep -o 'long[0-9]+=')
if [ -z "$LONGKEY" -o "$LONGKEY" == "0" ]; then
# Dump empty values.
echo null > /dev/null
# Call the KKEY function.
KKEY
else
L1=$(echo "$line" | egrep -o '"$LONGKEY""[0-9]+:[0-9]+:[0-9]+"' | egrep -o '[0-9]+: ' | egrep -o '[0-9]+')
L12=$(echo "$line" | egrep -o '"$LONGKEY""[0-9]+:[0-9]+:[0-9]+"' | egrep -o ':[0-9]+: ' | egrep -o '[0-9]+')
L123=$(echo "$line" | egrep -o '"$LONGKEY""[0-9]+:[0-9]+:[0-9]+"' | egrep -o ':[0-9]+ ' | egrep -o '[0-9]+')
L2=$(echo "$line" | egrep -o '"$LONGKEY""[a-z]+:[0-9]+:[0-9]+"' | egrep -o ':[0-9]+: ' | egrep -o '[0-9]+')
L23=$(echo "$line" | egrep -o '"$LONGKEY""[a-z]+:[0-9]+:[0-9]+"' | egrep -o ':[0-9]+ ' | egrep -o '[0-9]+')
L3=$(echo "$line" | egrep -o '"$LONGKEY""[0-9]+:[a-z]+:[0-9]+"' | egrep -o '[0-9]+: ' | egrep -o '[0-9]+')
L34=$(echo "$line" | egrep -o '"$LONGKEY""[0-9]+:[a-z]+:[0-9]+"' | egrep -o ':[0-9]+ ' | egrep -o '[0-9]+')
L4=$(echo "$line" | egrep -o '"$LONGKEY""[0-9]+:[0-9]+:[a-z]+"' | egrep -o '[0-9]+: ' | egrep -o '[0-9]+')
L45=$(echo "$line" | egrep -o '"$LONGKEY""[0-9]+:[0-9]+:[a-z]+"' | egrep -o ':[0-9]+: ' | egrep -o '[0-9]+')
# Save the value in a variable.
L1_CONFIRM=$(echo $L1)
L12_CONFIRM=$(echo $L12)
L123_CONFIRM=$(echo $L123)
L2_CONFIRM=$(echo $L2)
L23_CONFIRM=$(echo $L23)
L3_CONFIRM=$(echo $L3)
L34_CONFIRM=$(echo $L34)
L4_CONFIRM=$(echo $L4)
L45_CONFIRM=$(echo $L45)
# Begin calling all L functions
L1_GO
fi
}
L1_GO() {
if [ -z "$L1" -o "$L1" -lt 10 ]; then
echo null > /dev/null
# Call on L12_GO function
L12_GO
else
# Need this variable to calculate.
SIZEH=$(echo $L1_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$LONGKEY""'$L1_CONFIRM'" to "$LONGKEY""'$FINALH'"
SED_CHANGE_WORD "$L1_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call on L12_GO function.
L12_GO
fi
}
L12_GO() {
if [ -z "$L12" ]; then
echo null > /dev/null
# Call on L123_GO function.
L123_GO
else
# Need this variable to calculate.
SIZEH=$(echo $L12_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$LONGKEY""'$L12_CONFIRM'" to "$LONGKEY""'$FINALH'"
SED_CHANGE_WORD "$L12_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call on L123_GO function.
L123_GO
fi
}
L123_GO() {
if [ -z "$L123" ]; then
echo null > /dev/null
# Call on L2_GO function.
L2_GO
else
# Need this variable to calculate.
SIZEH=$(echo $L123_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$LONGKEY""'$L123_CONFIRM'" to "$LONGKEY""'$FINALH'"
SED_CHANGE_WORD "$L123_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call on L2_GO function.
L2_GO
fi
}
L2_GO() {
if [ -z "$L2" ]; then
echo null > /dev/null
# Call on L23_GO function.
L23_GO
else
# Need this variable to calculate.
SIZEH=$(echo $L2_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$LONGKEY""'$L2_CONFIRM'" to "$LONGKEY""'$FINALH'"
SED_CHANGE_WORD "$L2_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call on L23_GO function.
L23_GO
fi
}
L23_GO() {
if [ -z "$L23" ]; then
echo null > /dev/null
# Call on L3_GO function.
L3_GO
else
# Need this variable to calculate.
SIZEH=$(echo $L23_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$LONGKEY""'$L23_CONFIRM'" to "$LONGKEY""'$FINALH'"
SED_CHANGE_WORD "$L23_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call on L3_GO function.
L3_GO
fi
}
L3_GO() {
if [ -z "$L3" -o "$L3" -lt 10 ]; then
echo null > /dev/null
# Call on L34_GO function.
L34_GO
else
# Need this variable to calculate.
SIZEH=$(echo $L3_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$LONGKEY""'$L3_CONFIRM'" to "$LONGKEY""'$FINALH'"
SED_CHANGE_WORD "$L3_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call on L34_GO function.
L34_GO
fi
}
L34_GO() {
if [ -z "$L34" ]; then
echo null > /dev/null
# Call on L4_GO function.
L4_GO
else
# Need this variable to calculate.
SIZEH=$(echo $L34_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$LONGKEY""'$L34_CONFIRM'" to "$LONGKEY""'$FINALH'"
SED_CHANGE_WORD "$L34_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call on L4_GO function.
L4_GO
fi
}
L4_GO() {
if [ -z "$L4" -o "$L4" -lt 10 ]; then
echo null > /dev/null
# Call on L45_GO function.
L45_GO
else
# Need this variable to calculate.
SIZEH=$(echo $L4_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$LONGKEY""'$L4_CONFIRM'" to "$LONGKEY""'$FINALH'"
SED_CHANGE_WORD "$L4_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call on L45_GO function.
L45_GO
fi
}
L45_GO() {
if [ -z "$L45" ]; then
echo null > /dev/null
# Call the KKEY function.
KKEY
else
# Need this variable to calculate.
SIZEH=$(echo $L45_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$LONGKEY""'$L45_CONFIRM'" to "$LONGKEY""'$FINALH'"
SED_CHANGE_WORD "$L45_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call the KKEY function.
KKEY
fi
}
# Search for short Key 'key##=' values.
KKEY() {
SHORTKEY=$(echo "$line" | egrep -o 'key[0-9]+=')
if [ -z "$SHORTKEY" -o "$SHORTKEY" == "0" ]; then
# Dump empty values.
echo null > /dev/null
# Call the VVALUE function.
VVALUE
else
K1=$(echo "$line" | egrep -o '"$SHORTKEY""[0-9]+:[0-9]+:[0-9]+"' | egrep -o '[0-9]+: ' | egrep -o '[0-9]+')
K12=$(echo "$line" | egrep -o '"$SHORTKEY""[0-9]+:[0-9]+:[0-9]+"' | egrep -o ':[0-9]+: ' | egrep -o '[0-9]+')
K123=$(echo "$line" | egrep -o '"$SHORTKEY""[0-9]+:[0-9]+:[0-9]+"' | egrep -o ':[0-9]+ ' | egrep -o '[0-9]+')
K2=$(echo "$line" | egrep -o '"$SHORTKEY""[a-z]+:[0-9]+:[0-9]+"' | egrep -o ':[0-9]+: ' | egrep -o '[0-9]+')
K23=$(echo "$line" | egrep -o '"$SHORTKEY""[a-z]+:[0-9]+:[0-9]+"' | egrep -o ':[0-9]+ ' | egrep -o '[0-9]+')
K3=$(echo "$line" | egrep -o '"$SHORTKEY""[0-9]+:[a-z]+:[0-9]+"' | egrep -o '[0-9]+: ' | egrep -o '[0-9]+')
K34=$(echo "$line" | egrep -o '"$SHORTKEY""[0-9]+:[a-z]+:[0-9]+"' | egrep -o ':[0-9]+ ' | egrep -o '[0-9]+')
K4=$(echo "$line" | egrep -o '"$SHORTKEY""[0-9]+:[0-9]+:[a-z]+"' | egrep -o '[0-9]+: ' | egrep -o '[0-9]+')
K45=$(echo "$line" | egrep -o '"$SHORTKEY""[0-9]+:[0-9]+:[a-z]+"' | egrep -o ':[0-9]+: ' | egrep -o '[0-9]+')
# Save the value in a variable.
K1_CONFIRM=$(echo $K1)
K12_CONFIRM=$(echo $K12)
K123_CONFIRM=$(echo $K123)
K2_CONFIRM=$(echo $K2)
K23_CONFIRM=$(echo $K23)
K3_CONFIRM=$(echo $K3)
K34_CONFIRM=$(echo $K34)
K4_CONFIRM=$(echo $K4)
K45_CONFIRM=$(echo $K45)
# Call on K1_GO function.
K1_GO
fi
}
K1_GO() {
if [ -z "$K1" -o "$K1" -lt 10 ]; then
echo null > /dev/null
# Call on K12_GO function.
K12_GO
else
# Need this variable to calculate.
SIZEH=$(echo $K1_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$SHORTKEY""'$K1_CONFIRM'" to "$SHORTKEY""'$FINALH'"
SED_CHANGE_WORD "$K1_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call on K12_GO function.
K12_GO
fi
}
K12_GO() {
if [ -z "$K12" ]; then
echo null > /dev/null
# Call on K123_GO function.
K123_GO
else
# Need this variable to calculate.
SIZEH=$(echo $K12_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$SHORTKEY""'$K12_CONFIRM'" to "$SHORTKEY""'$FINALH'"
SED_CHANGE_WORD "$K12_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call on K123_GO function.
K123_GO
fi
}
K123_GO() {
if [ -z "$K123" ]; then
echo null > /dev/null
# Call on K2_GO function.
K2_GO
else
# Need this variable to calculate.
SIZEH=$(echo $K123_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$SHORTKEY""'$K123_CONFIRM'" to "$SHORTKEY""'$FINALH'"
SED_CHANGE_WORD "$K123_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call on K2_GO function.
K2_GO
fi
}
K2_GO() {
if [ -z "$K2" ]; then
echo null > /dev/null
# Call on K23_GO function.
K23_GO
else
# Need this variable to calculate.
SIZEH=$(echo $K2_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$SHORTKEY""'$K2_CONFIRM'" to "$SHORTKEY""'$FINALH'"
SED_CHANGE_WORD "$K2_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call on K23_GO function.
K23_GO
fi
}
K23_GO() {
if [ -z "$K23" ]; then
echo null > /dev/null
# Call on K3_GO function.
K3_GO
else
# Need this variable to calculate.
SIZEH=$(echo $K23_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$SHORTKEY""'$K23_CONFIRM'" to "$SHORTKEY""'$FINALH'"
SED_CHANGE_WORD "$K23_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call on K3_GO function.
K3_GO
fi
}
K3_GO() {
if [ -z "$K3" -o "$K3" -lt 10 ]; then
echo null > /dev/null
# Call on K34_GO function.
K34_GO
else
# Need this variable to calculate.
SIZEH=$(echo $K3_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$SHORTKEY""'$K3_CONFIRM'" to "$SHORTKEY""'$FINALH'"
SED_CHANGE_WORD "$K3_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call on K34_GO function.
K34_GO
fi
}
K34_GO() {
if [ -z "$K34" ]; then
echo null > /dev/null
# Call on K4_GO function.
K4_GO
else
# Need this variable to calculate.
SIZEH=$(echo $K34_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$SHORTKEY""'$K34_CONFIRM'" to "$SHORTKEY""'$FINALH'"
SED_CHANGE_WORD "$K34_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call on K4_GO function.
K4_GO
fi
}
K4_GO() {
if [ -z "$K4" -o "$K4" -lt 10 ]; then
echo null > /dev/null
# Call on K45_GO function.
K45_GO
else
# Need this variable to calculate.
SIZEH=$(echo $K4_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$SHORTKEY""'$K4_CONFIRM'" to "$SHORTKEY""'$FINALH'"
SED_CHANGE_WORD "$K4_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call on K45_GO function.
K45_GO
fi
}
K45_GO() {
if [ -z "$K45" ]; then
echo null > /dev/null
# Call the KKEY function.
KKEY
else
# Need this variable to calculate.
SIZEH=$(echo $K45_CONFIRM)
CALCULATE_HEIGHT
echo Porting "$SHORTKEY""'$K45_CONFIRM'" to "$SHORTKEY""'$FINALH'"
SED_CHANGE_WORD "$K45_CONFIRM" "$FINALH" "$PORT_UI/$FILE"
# Call the VVALUE function.
VVALUE
fi
}
# Search for 'value' values. These values are a special case and will require the user to decide.
VVALUE() {
VALUE=$(echo "$line" | egrep -o 'value="[0-9]+"' | egrep -o '[0-9]+';)
if [ -z "$VALUE" -o "$VALUE" == "0" -o "$VALUE" == "1" -o "$VALUE" == "0123456789" ]; then
# Dump empty values.
echo null > /dev/null
else
# Save the value in a variable.
VALUE_CONFIRM=$(echo $VALUE)
echo " "
echo The value below must be determined by the human mind!
echo " "
echo "$line"
echo Please type and enter, W for width or H for height:
read HUMAN_ANSWER </dev/tty
# Call the YOUR_MIND function.
YOUR_MIND
fi
}
YOUR_MIND() {
if [ "$HUMAN_ANSWER" == "w" -o "$HUMAN_ANSWER" == "h" -o "$HUMAN_ANSWER" == "W" -o "$HUMAM_ANSWER" == "H" ]; then
# Call the DONT_KNOW_JACK function.
DONT_KNOW_JACK
else
echo " "
echo Please enter either W for Width or H for Height!
echo Press ANY key to try again!
read -n 1 any_key </dev/tty
# Call the VVALUE function.
VVALUE
fi
}
# OUT OF ALL THE VALUES TO BE DETECTED WE WILL BEGIN ON CALLING THE XX FUNCTION!
XX
# The script needs to be put on hold to insure it echoes accordingly and does not overlook any lines.
wait </dev/tty ;
done