1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
  
     | 
    
      //genesis
/**********************************************************************
** This program is part of kinetikit and is
**           copyright (C) 1995-1997 Upinder S. Bhalla.
** It is made available under the terms of the GNU General Public License. 
** See the file COPYRIGHT for the full notice.
**********************************************************************/
// xsave.g : implements the save/restore capabilities of kkit
int dump_x = 1
function save_sim(filename, group)
	str filename
	str group
	int group_only
	if ({exists {group}} == 1)
		group_only = 1
	else
		group_only = 0
	end
	do_inform {"Saving file" @ {filename}}
	openfile {filename} "w"
	writefile {filename} "//genesis"
	writefile {filename} "// kkit Version 2 dumpfile"
	writefile {filename} " "
	writefile {filename} {"// Saved on " @ {getdate}}
	writefile {filename} " "
	writefile {filename} "include kkit"
	writefile {filename} " "
	writefile {filename} "FASTDT = "{FASTDT}
	writefile {filename} "SIMDT = "{SIMDT}
	writefile {filename} "CONTROLDT = "{CONTROLDT}
	writefile {filename} "PLOTDT = "{PLOTDT}
	// writefile {filename} "TABLEDT = "{TABLEDT}
	writefile {filename} "MAXTIME = "{MAXTIME}
	writefile {filename} "kparms"
	writefile {filename} " "
	closefile {filename}
	/* We have moved initdump to the kbegin function in ksim,
	** since we want to let each object init its own fields.
	*/
	// initdump 
	// swap in the current simulation context for dumps
	swapdump
	if (dump_x)
		if (group_only)
			simdump {filename} -path {group} \
				-path {group}/##[] \
				-path /kinetics/#[TYPE=kpool] \
				-path /kinetics/#[]/#[TYPE=kenz] \
				-path /edit/draw \
				-path /edit/draw/tree \
				-path /file/notes
		else
			simdump {filename} -path /kinetics/##[] \
				-path /psearch/##[] \
				-path /graphs/#[TYPE=xgraph] \
				-path /graphs/#[]/#[TYPE=xplot] \
				-path /moregraphs/#[TYPE=xgraph] \
				-path /moregraphs/#[]/#[TYPE=xplot] \
				-path /edit/draw \
				-path /edit/draw/tree \
				-path /file/notes
		end
	else
		if (group_only)
			simdump {filename} -path {group} \
				-path {group}/##[] \
				-path /kinetics/#[TYPE=kpool] \
				-path /kinetics/#[]/#[TYPE=kenz]
		else
			simdump {filename} -path /kinetics/##[] \
				-path /psearch/##[]
		end
	end
	// swap out the current simulation context for dumps
	swapdump
	openfile {filename} "a"
	if (dump_x)
		writefile {filename} "call /edit/draw/tree RESET"
	end
	writefile {filename} "reset"
	closefile {filename}
	do_inform {"Finished saving file " @ {filename}}
	xflushevents
	xhide /inform
	xhide /file
/* need to figure out how to dump and restore connections to graphs
** also how to overlay an old sim onto a new one
*/
end
function load_sim(filename)
	str filename
	str foo = filename
	do_inform {"Loading file " @ {foo}}
	/*
	echo {filename}
	source {filename}
	*/
	do_inform {"Finished loading file " @ {filename}}
	xflushevents
	xhide /inform
	xhide /file
end
function do_save
    str dest = {getfield /file/save value}
    save_sim {dest} __nothere
end
 
     |