#	@(#)Form.task	13.1 (RC International) 91/07/25

#ident	"@(#)oamintf:edsysadm/Form.task	1.6"
################################################################################
#	Name: Form.task
#	Date July 1988
#
#	ARGS PASSED IN:
#			ARG1 -> task flag
#			ARG2 -> package description file name
#	ARGS PASSED OUT:
#			ARG1 -> task flag
#			ARG2 -> package description file name
#			F1 -> Task name
#			F2 -> Task description
#			F3 -> Task location
#			F4 -> Task help
#			F5 -> Task action file
#			F6 -> Task file(s) (comma separated)
#			LOC:NAME -> original location
################################################################################
form="Define a Task"

framemsg=`readfile $INTFBASE/form.msg`

help=OPEN TEXT $INTFBASE/Text.itemhelp $LININFO

close=`rm -f $GETINFO /tmp/${VPID}.nf 2> /dev/null`

done=OPEN FORM $EDSYSADM/Form.save $ARG1 $ARG2 $F1 $F2 $F3 $F4 $F5 $F6 $LOC:$NAME
#LOC is the same as F3 - fmli quirk required it to be called LOC for passing args.

# F1
name=Name:
lininfo=Form.task:name
nrow=1
ncol=1
frow=1
fcol=7
rows=1
columns=16
`getfld $GETINFO NAME | set -l NAME`
value=$NAME

valid=`regex -v "$F1" '^[\_a-z]{1,16}$'`

choicemsg="For Task Name use 16 or less lower case and underbar characters."
invalidmsg="Error: Task Name must be lower case and underbar characters only."

# F2
name=Description:
lininfo=descrp
nrow=2
ncol=1
frow=2
fcol=14
rows=1
columns=58
value=`getfld $GETINFO DESC`

valid=`regex -v "$F2" '^[A-Z][^\@\^\~\`\'\"]*$'`
#valid=`regex -v "$F2" '^[A-Z][\_\ A-Za-z0-9]+$'`

choicemsg="Task Description may be 58 characters or less."
invalidmsg="Capitalize 1st letter of each word. Don't use special characters."


# F3
name=Location:
lininfo=loc
nrow=3
ncol=1
frow=3
fcol=11
rows=1
columns=61
scroll=true
`getfld $GETINFO LOC | set -l LOC`
value=$LOC

valid=`regex -v "$F3" '^[m][a][i][n][\:][\_A-Za-z0-9][\_\:A-Za-z0-9]*[\_A-Za-z0-9]$' 'true' '^main$' 'true' && 
      shell " dc=\`echo \"$F3\" | awk '/::/ { exit 1 }'\` 
      "`

choicemsg="Start with 'main' and separate menu location levels with ':'."
invalidmsg="Start with 'main', use a through z & underbars. Separate levels with ':'."
# uses "a-zA-Z0-9_:", but can't end with ":", must start with "main:" and can't have "::"

# F4
name=Help file source path:
lininfo=help
nrow=4
ncol=1
frow=4
fcol=24
rows=1
columns=48
scroll=true
value=`getfld $GETINFO HELP`

valid=`valpath -n $F4;
	
	if [ $RET -eq 0 ];
	then
		run edhelp $F4;
	else
		echo true;
	fi`

choicemsg="Use absolute or relative path name and standard filename characters."
invalidmsg="Error: must contain the name of a file using standard filename characters."

# F5
name=Action:
lininfo=Form.task:action
nrow=5
ncol=1
frow=5
fcol=9
rows=1
columns=63
scroll=true
value=`getfld $GETINFO ACTION`

valid=`valpath -o "$F5"`

choicemsg="Task Action is the file that is executed when this item is selected from a menu."
invalidmsg="Error: "$F5" does not exist."

# F6
name=Task files:
lininfo=Form.task:tfiles
nrow=6
ncol=1
frow=6
fcol=13
rows=10
columns=59
scroll=true
value=`getfld $GETINFO FILES`

valid=`indicator -w; valfiles "$F6"`

choicemsg="Task Files must be separated by commas."
invalidmsg="Error: `readfile /tmp/${VPID}.nf` does not exist."

name=RESET
button=8
action=reset
