#!/opt0/tcl/bin/sytcl
#
#
if {[llength $argv] == 0} {
	echo "Usage:  fakeforms <data_file_name>"
	exit 1
}
#
set infile [lindex $argv 0]
#
loadlibindex /opt0/tcl/lib/ucosybtk/ucosyb.tlib
#
global debugs
set debugs {}
#
global sybmsg
global server
global dbpipe1
set uname sa
set pass NOYB
set base MetaBase
set server MyServer
#
set dbpipe1 [sybOpen $base $uname $pass $server]
#
set sqt info.dbo.forms
#
for_file line $infile {

	lassign [split $line ~] fid fname ftype level item area wtype tbln fldn wname labx laby labs labf labt laba entx enty ents entf enta cmd next prev help dflt cmd2 echo

#	old exec fids are meaningless
#	and so are prev, next, echo (look at the NULLs in the insert)

	case $wtype in {
	{RB CB PS BT} {
		set tbln ""
	}
	}

	if {$labx == ""} {set labx NULL}
	if {$laby == ""} {set laby NULL}
	if {$labs == ""} {set labs NULL}
	if {$entx == ""} {set entx NULL}
	if {$enty == ""} {set enty NULL}
	if {$ents == ""} {set ents NULL}

	set sqlcmd "insert into info.dbo.forms values (-1,'$fname','$ftype',$level,$item,'$area','$wtype','$tbln','$fldn','$wname',$labx,$laby,$labs,'$labf','$labt','$laba',$entx,$enty,$ents,'$entf','$enta','$cmd',NULL,NULL,'$help','$dflt','$cmd2',NULL)"
#	echo "sqlcmd:\n$sqlcmd"
	doSQL 1
	echo "stored record $fname level $level $wtype $wname"

}

# end of proc
