Submenu variable problems

The problem is

I need it too go from the main menu by pressing 6, to the submenu search_proc. In the search_proc menu/section it need to accept a variable and search the processes for it and sort by PID and Process name. I'm stuck and ran out of ideas. I also cannot figure out why it keeps flashing quick and going back to the main menu.

Inside a function positional parameters are setted with new values, so your $outputfile is null:

#!/bin/sh
# Usage: ./this_script a b

f() {
  echo $1 $2
}

echo $1 $2

f x

I hope you get the idea.

I'm still confused to be honest. I need it to change to the new menu, then accept the input so i can use it for my grep command.