'From VisualWorks® NonCommercial, Release 5i.4 of August 9, 2001 on June 7, 2002 at 6:34:44 pm'! !CormasNS.Kernel.Converter2001To2002 class methodsFor: 'convertTo2002'! convertSTFileTo2002: fileName | contents upgradeDictionary index stream oldVersion oldVersionFileName firstPart secundPart | "fileName : = chemin complet du fichier." "1- on copie le fichier model.st en model2001.st" oldVersion := fileName directory construct: ((fileName tail tokensBasedOn: $.) first, '2001', fileName extension). oldVersion asFilename exists ifTrue: [Dialog warn: (UserMessage defaultString: 'Conversion already performed !! Just import it !!' key: #alreadyConverted). ^nil]. Dialog warn: (UserMessage defaultString: 'The previous version of your model will be renamed ' key: #previousVersion). oldVersionFileName := Dialog requestFileName: (UserMessage defaultString: 'Your previous version will be renamed as : ' key: #previousVersion) default: oldVersion version: #new. oldVersionFileName isEmpty ifTrue: [^nil]. "Sauvegarde du fichier avec son oldVersionFileName" fileName asFilename copyTo: oldVersionFileName asFilename. "2- on lit le contenu du fichier qu'on stock dans contents" contents := fileName asFilename readStream contents "asText". "3- On cree un dico des termes a REMPLACER. a completer en fonction de tous les changements de noms de methodes et de classes" "attention a ne pas oublier le blanc en fin de string du nouveau nom sous 2002. ex: upgradeDictionary at: 'ancien' put: 'nouveau ' " upgradeDictionary := Dictionary new. upgradeDictionary at: 'SpatialEntity_Element' put: 'SpatialEntityElement'; at: 'SpatialEntity_Aggregate' put: 'SpatialEntityAggregate'; at: 'SpatialEntity_Set_notConnex' put: 'SpatialEntityNotConnex'; at: 'SpatialEntity_CA' put: 'SpatialEntityCell'; at: 'SpatialEntity_Partition' put: 'SpatialEntityAggregate'; at: 'initCharts' put: 'initData'; at: 'initLocalCharts' put: 'initData'; at: 'initGlobalCharts' put: 'initData'; at: 'updateCharts:' put: 'updateData:'; at: 'updateLocalCharts:' put: 'updateData:'; at: 'updateGlobalCharts:' put: 'updateData:'; at: 'aggregate:' put: 'setAggregatesFrom:'; at: 'estObserve:' put: 'isObserved: '; at: 'estObserve' put: 'isObserved'; at: 'space' put: 'spaaaceModel'; "Attention a la boucle infernale !!" at: 'spaaaceModel' put: 'spaceModel'; at: 'colonne' put: 'column'; at: 'ligne' put: 'line'; at: 'connexitePatch' put: 'nbNeighbours'; at: 'Cormas_Model' put: 'CormasModel'; at: 'componentsE ' put: 'elementaryComponents '. upgradeDictionary keysAndValuesDo: [:k :v | index := contents findString: k startingAt: 1. [index ~= 0] whileTrue: [" !!!!!! 'changeFrom: index to: (index + k size) with:' v et k doivent etre de la meme taille" firstPart := contents copyFrom: 1 to: (index - 1). secundPart := contents copyFrom: (index + k size) to: (contents size). contents := firstPart, v, secundPart. index := contents findString: k startingAt: index]]. "4- Sauvegarde du fichier fileName.st avec les nouveaux termes" stream := fileName asFilename writeStream. stream nextPutAll: contents. stream close.! !