Edit Rename Upload Download Back to Top

Saving StORE connection configurations

It's highly useful to read in a set of Store connection configurations from a disk file and have them reset - especially when you build from scratch a lot. The following two scripts enable that.


"write them out"
fname := 'connects.txt' asFilename writeStream.
Database.ConnectionDialog.Profiles do: [:each |
	1 to: each class allInstVarNames size do: [:evar |
		| obj |
		obj := each instVarAt: evar.
		obj isNil 
			ifTrue: [fname nextPutAll: 'nil']
			ifFalse: [fname nextPutAll: obj].
		fname nextPut: $,].
	fname nextPut: Character cr].
	fname close.

"read them in"
fname := 'connects.txt' asFilename readStream.
list := OrderedCollection new.
[fname atEnd]
	whileFalse: [
		| prof str line i |
		line := fname upTo: Character cr.
		str := line readStream.
		prof := Store.ConnectionProfile new.
		i := 1.
		[str atEnd]
			whileFalse: [
				|  next |
					next := str upTo: $,.
				next = 'nil' ifTrue: [next := nil].
				prof instVarAt: i put: next.
				i := i + 1].
		list add: prof].
	fname close.
	Store.ConnectionDialog.Profiles := list.


Edit Rename Upload Download Back to Top