navienginebsp/tools/testreference/lauterbach/configdialog.cmm
changeset 0 5de814552237
equal deleted inserted replaced
-1:000000000000 0:5de814552237
       
     1 //
       
     2 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 // All rights reserved.
       
     4 // This component and the accompanying materials are made available
       
     5 // under the terms of "Eclipse Public License v1.0"
       
     6 // which accompanies this distribution, and is available
       
     7 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 //
       
     9 // Initial Contributors:
       
    10 // Nokia Corporation - initial contribution.
       
    11 //
       
    12 // Contributors:
       
    13 //
       
    14 // Description:  
       
    15 //
       
    16 //////////////////////////////////////////////////////////////////////////////
       
    17 //
       
    18 // This script will display a dialog box to the user that is the central point
       
    19 // for configuring the path of the ROM image that is to be loaded onto the
       
    20 // different boards supported by the Symbian T32 scripts.  It is also used to
       
    21 // select the current target board.  Once this has been done, all operations
       
    22 // such as attaching, loading etc. will be performed on that board, according
       
    23 // to the settings saved by this script.
       
    24 //
       
    25 //////////////////////////////////////////////////////////////////////////////
       
    26 
       
    27 //
       
    28 // 1) load current environment into temporary variables
       
    29 //        if environment not set, take defaults
       
    30 // 2) initialise dialog with current environment
       
    31 //        ... dialog runs at this point ...
       
    32 // 3) when dialog exits, update current environment
       
    33 //
       
    34 
       
    35 ; Declare the global variables used by the system and read the current config into them
       
    36 do globals.cmm
       
    37 
       
    38 GLOBAL &platformList
       
    39 GLOBAL &ConfigDialogOpen
       
    40 &ConfigDialogOpen="false"
       
    41 
       
    42 // I'm saving this as a global for now so that I can change the default extension for testing...
       
    43 GLOBAL &defaultExt
       
    44 &defaultExt="*.bin;*.img"
       
    45 
       
    46 &currentConfigFile="currentconfig.cmm"
       
    47 
       
    48 global &dialogMode
       
    49 
       
    50 gosub LoadPlatformFromFile "currentconfig.cmm"
       
    51 
       
    52 // Stop command prevents script from exiting before user has pressed anything...
       
    53 stop
       
    54 
       
    55 enddo
       
    56 
       
    57 //=============================================================================
       
    58 // Dialog Box Definition
       
    59 //=============================================================================
       
    60 OpenDialog:
       
    61 
       
    62 	gosub GeneratePlatformList
       
    63 	//print "Setting platform list to " "&platformList"
       
    64 	do sourcepaths.cmm
       
    65 
       
    66 	dialog
       
    67 (&
       
    68 		header "Current Configuration"
       
    69 
       
    70 //*****************************Definition***************************************
       
    71 
       
    72 		//---------- Platform ----------
       
    73 		pos 1. 0. 9.
       
    74 		text "Target Board"
       
    75 		pos 1. 1. 25. 1.
       
    76 PLATFORM: PULLDOWN "&platformList" "gosub LoadPlatformFromFile"
       
    77 
       
    78 		//---------- Platform Defaults Box ----------
       
    79 		pos 27. 0. 17. 3.
       
    80 		box "Target Board Defaults"
       
    81 
       
    82 			//---------- Defaults Button ----------
       
    83 			pos 28. 1. 7. 1.
       
    84 			BUTTON "Reload"
       
    85 			(
       
    86 				gosub LoadPlatformFromFile
       
    87 			)
       
    88 
       
    89 			//---------- Save As Defaults Button ----------
       
    90 			pos 36. 1. 7. 1.
       
    91 			BUTTON "Save"
       
    92 			(
       
    93 				gosub SavePlatform
       
    94 			)
       
    95 
       
    96 
       
    97 		//---------- Custom Config Box ----------
       
    98 		pos 45. 0. 19. 3.
       
    99 		box "Custom Config"
       
   100 
       
   101 			//---------- Load Button ----------
       
   102 			pos 46. 1. 8. 1.
       
   103 			BUTTON "Load..."
       
   104 			(
       
   105 				dialog.file "*.cmm"
       
   106 				entry &fileName
       
   107 
       
   108 				if "&fileName"!=""
       
   109 					(
       
   110 					gosub LoadPlatformFromFile &fileName
       
   111 					)
       
   112 			)
       
   113 
       
   114 			//---------- Save Button ----------
       
   115 			pos 55. 1. 8. 1.
       
   116 			BUTTON "Save As..."
       
   117 			(
       
   118 				dialog.filew "*.cmm"
       
   119 				entry &fileName
       
   120 				if ("&fileName"!="")
       
   121 				(
       
   122 					gosub SavePlatformToFile &fileName
       
   123 				)
       
   124 			)
       
   125 
       
   126 		//---------- Source Paths and Autoload Module ----------
       
   127 		pos 0. 2. 75. 4.
       
   128 		box "Source Paths and Autoload Module"
       
   129 
       
   130 		//---------- Source Paths ----------
       
   131 		pos 1. 3. 12. 1.
       
   132 		text "Source Paths"
       
   133 		pos 20. 3. 7. 1.
       
   134 LIST_SOURCEPATHS: BUTTON "List" "gosub ListSourcePaths"
       
   135 		pos 28. 3. 7.
       
   136 EDIT_SOURCEPATHS:	BUTTON "Edit" "gosub EditSourcePath"
       
   137 		pos 36. 3. 7. 1.
       
   138 RELOAD_SOURCEPATHS: BUTTON "Reload" "gosub ReloadSourcePaths"
       
   139 		pos 44. 3. 7
       
   140 DEFAULT_SOURCEPATHS: BUTTON "Default" "gosub DefaultSourcePaths"
       
   141 		pos 52. 3. 7
       
   142 SAVE_SOURCEPATHS: BUTTON "Save" "gosub SaveSourcePaths"
       
   143 
       
   144 		//---------- Autoload Module ----------
       
   145 		pos 1. 4. 15.
       
   146 		text "Autoload Module"
       
   147 		pos 20. 4. 54. 1.
       
   148 AUTOLOAD_MODULE: EDIT "" ""
       
   149 
       
   150 		//-------- RAM Image -------
       
   151 		pos 0. 6. 90. 10.
       
   152 		box "RAM Images"
       
   153 		pos 1. 7. 15. 1.
       
   154 		text "Load Address 1"
       
   155 		pos 20. 7. 20. 1.
       
   156 RAMADDR1:        EDIT "" ""
       
   157 		pos 1. 8. 15. 1.
       
   158 		text "Filename 1"
       
   159 		pos 20. 8. 65. 1.
       
   160 RAMIMAGE1:        EDIT "" ""
       
   161 		pos 86. 8. 3.
       
   162 		BUTTON "..."
       
   163 		(
       
   164 			gosub GetImageFromUser RAMIMAGE1
       
   165 		)
       
   166 
       
   167 		pos 1. 9. 15. 1.
       
   168 		text "Load Address 2"
       
   169 		pos 20. 9. 20. 1.
       
   170 RAMADDR2:        EDIT "" ""
       
   171 		pos 1. 10. 15. 1.
       
   172 		text "Filename 2"
       
   173 		pos 20. 10. 65. 1.
       
   174 RAMIMAGE2:        EDIT "" ""
       
   175 		pos 86. 10. 3.
       
   176 		BUTTON "..."
       
   177 		(
       
   178 			gosub GetImageFromUser RAMIMAGE2
       
   179 		)
       
   180 
       
   181 		pos 1. 11. 15. 1.
       
   182 		text "Load Address 3"
       
   183 		pos 20. 11. 20. 1.
       
   184 RAMADDR3:        EDIT "" ""
       
   185 		pos 1. 12. 15. 1.
       
   186 		text "Filename 3"
       
   187 		pos 20. 12. 65. 1.
       
   188 RAMIMAGE3:        EDIT "" ""
       
   189 		pos 86. 12. 3.
       
   190 		BUTTON "..."
       
   191 		(
       
   192 			gosub GetImageFromUser RAMIMAGE3
       
   193 		)
       
   194 
       
   195 		pos 1. 13. 15. 1.
       
   196 		text "Load Address 4"
       
   197 		pos 20. 13. 20. 1.
       
   198 RAMADDR4:        EDIT "" ""
       
   199 		pos 1. 14. 15. 1.
       
   200 		text "Filename 4"
       
   201 		pos 20. 14. 65. 1.
       
   202 RAMIMAGE4:        EDIT "" ""
       
   203 		pos 86. 14. 3.
       
   204 		BUTTON "..."
       
   205 		(
       
   206 			gosub GetImageFromUser RAMIMAGE4
       
   207 		)
       
   208 
       
   209 		//-------- NOR Flash Image -------
       
   210 		pos 0. 15. 90. 5.
       
   211 		box "NOR Flash Image"
       
   212 		pos 1. 16. 15. 1.
       
   213 		text "Load Address"
       
   214 		pos 20. 16. 20. 1.
       
   215 FLASHADDR:        EDIT "" ""
       
   216 		pos 1. 17. 15. 1.
       
   217 		text "Filename"
       
   218 		pos 20. 17. 65. 1.
       
   219 FLASHIMAGE:        EDIT "" ""
       
   220 		pos 86. 17. 3.
       
   221 GETFLASHIMAGE:		BUTTON "..."
       
   222 		(
       
   223 			gosub GetImageFromUser FLASHIMAGE
       
   224 		)
       
   225 		pos 1. 18. 19. 1.
       
   226 		text "Warning Dialogs"
       
   227 		pos 20. 18. 10. 1.
       
   228 FLASHWRITEPROTECT:	CHECKBOX "Flash Write"
       
   229 		(
       
   230 			print "Write Prot: &FlashWriteProtect"
       
   231 		)
       
   232 		pos 35. 18. 10. 1.
       
   233 FLASHERASEPROTECT:	CHECKBOX "Flash Erase"
       
   234 		(
       
   235 			print "Erase Prot: &FlashEraseProtect"
       
   236 		)
       
   237 
       
   238 
       
   239 		//---------- Bottom Row of Buttons ----------
       
   240 		//---------- OK Button ----------
       
   241 		pos 1. 20. 6.
       
   242 		DEFBUTTON "OK"
       
   243 		(
       
   244 			gosub CloseDialog save
       
   245 			continue
       
   246 		)
       
   247 
       
   248 		//---------- Cancel Button ----------
       
   249 		pos 8. 20. 10.
       
   250 		BUTTON "Cancel"
       
   251 		(
       
   252 			; Reload the current config from disk
       
   253 			do currentconfig.cmm
       
   254 
       
   255 			; Close the dialog and reset the symbolics sourcepath
       
   256 			gosub CloseDialog
       
   257 			continue
       
   258 		)
       
   259 
       
   260 		//---------- Advanced/Basic Button ----------
       
   261 		pos 65. 20. 11.
       
   262 ADV_BASIC: BUTTON "Toggle Advanced" "gosub ToggleDialogMode"
       
   263 )
       
   264 
       
   265 	; Set a flag to indicate that the dialig is open, seeing that there doesn't seem to be
       
   266 	; a way of querying T32 about it
       
   267 	&ConfigDialogOpen="true"
       
   268 
       
   269 	; Initialise any dialog controls that were not filled in automatically when creating the
       
   270 	; dialog and enable or disable the advanced ones as appropriate
       
   271 	gosub SetupDialogDefaults
       
   272 
       
   273 	RETURN
       
   274 
       
   275 //==============================================================================
       
   276 LoadPlatformFromFile:
       
   277 	ENTRY &fileName
       
   278 	LOCAL &platform
       
   279 
       
   280 	; Load the platform configuration from the filename passed in, if any
       
   281 	if "&fileName"!=""
       
   282 		(
       
   283 		if os.file(&fileName)
       
   284 			(
       
   285 			do &fileName
       
   286 			)
       
   287 		)
       
   288 	else
       
   289 		(
       
   290 		; Otherwise see what the currently selected platform is in the platforms drop down and load its configuration
       
   291 		&platform=dialog.string(PLATFORM)
       
   292 		if os.file(&PlatformsDir\&platform\&UserConfigCmm)
       
   293 			(
       
   294 			do &PlatformsDir\&platform\&UserConfigCmm
       
   295 			)
       
   296 		else
       
   297 			(
       
   298 			print "No platform specific user config defined; using blank defaults"
       
   299 			&Platform="&platform"
       
   300 			&RamImage=""
       
   301 			&RamAddr="0"
       
   302 			&RamImage1=""
       
   303 			&RamAddr1="0"
       
   304 			&RamImage2=""
       
   305 			&RamAddr2="0"
       
   306 			&RamImage3=""
       
   307 			&RamAddr3="0"
       
   308 			&RamImage4=""
       
   309 			&RamAddr4="0"
       
   310 			)
       
   311 		)
       
   312 
       
   313 	; And re-open the dialog so that it displays the newly loaded configuration
       
   314 	gosub CloseDialog
       
   315 	gosub OpenDialog
       
   316 
       
   317 	return
       
   318 
       
   319 //==============================================================================
       
   320 SetAdvancedDialogOptions:
       
   321 
       
   322 	dialog.enable LIST_SOURCEPATHS
       
   323 	dialog.enable EDIT_SOURCEPATHS
       
   324 	dialog.enable RELOAD_SOURCEPATHS
       
   325 	dialog.enable DEFAULT_SOURCEPATHS
       
   326 	dialog.enable SAVE_SOURCEPATHS
       
   327 	dialog.enable AUTOLOAD_MODULE
       
   328 	dialog.enable RAMADDR1
       
   329 	dialog.enable RAMADDR2
       
   330 	dialog.enable RAMADDR3
       
   331 	dialog.enable RAMADDR4
       
   332 	dialog.enable FLASHADDR
       
   333 	dialog.enable FLASHIMAGE
       
   334 	dialog.enable GETFLASHIMAGE
       
   335 	dialog.enable FLASHWRITEPROTECT
       
   336 	dialog.enable FLASHERASEPROTECT
       
   337 	&dialogMode="advanced"
       
   338 
       
   339 	return
       
   340 
       
   341 //==============================================================================
       
   342 SetBasicDialogOptions:
       
   343 
       
   344 	dialog.disable LIST_SOURCEPATHS
       
   345 	dialog.disable EDIT_SOURCEPATHS
       
   346 	dialog.disable RELOAD_SOURCEPATHS
       
   347 	dialog.disable DEFAULT_SOURCEPATHS
       
   348 	dialog.disable SAVE_SOURCEPATHS
       
   349 	dialog.disable AUTOLOAD_MODULE
       
   350 	dialog.disable RAMADDR1
       
   351 	dialog.disable RAMADDR2
       
   352 	dialog.disable RAMADDR3
       
   353 	dialog.disable RAMADDR4
       
   354 	dialog.disable FLASHADDR
       
   355 	dialog.disable FLASHIMAGE
       
   356 	dialog.disable GETFLASHIMAGE
       
   357 	dialog.disable FLASHWRITEPROTECT
       
   358 	dialog.disable FLASHERASEPROTECT
       
   359 	&dialogMode="basic"
       
   360 
       
   361 	return
       
   362 
       
   363 /==============================================================================
       
   364 ToggleDialogMode:
       
   365 
       
   366 	if ("&dialogMode"=="advanced")
       
   367 		(
       
   368 		gosub SetBasicDialogOptions
       
   369 		)
       
   370 	else
       
   371 		(
       
   372 		gosub SetAdvancedDialogOptions
       
   373 		)
       
   374 
       
   375 	return
       
   376 
       
   377 //==============================================================================
       
   378 CloseDialog:
       
   379 	ENTRY &save
       
   380 
       
   381 	if ("&save"=="save")
       
   382 		(
       
   383 		; Read the dialog controls that might have changed and save the configuration to disk
       
   384 		gosub ReadDialog
       
   385 		gosub SavePlatformToFile "&currentConfigFile"
       
   386 		do PrintConfig.cmm
       
   387 		)
       
   388 
       
   389 	; This function can be called safely even if the dialog is not open.  To allow this we must
       
   390 	; manually keep track of whether the dialog is open, as T32 will give an error if you try to
       
   391 	; close a dialog that is not open
       
   392 	if "&ConfigDialogOpen"!="false"
       
   393 		(
       
   394 		&ConfigDialogOpen="false"
       
   395 		dialog.end
       
   396 		)
       
   397 
       
   398 	return
       
   399 
       
   400 //==============================================================================
       
   401 SetupDialogDefaults:
       
   402 
       
   403 	; Display or hide the advanced controls according to the user's preference
       
   404 	if ("&dialogMode"=="advanced")
       
   405 		(
       
   406 		gosub SetAdvancedDialogOptions
       
   407 		)
       
   408 	else
       
   409 		(
       
   410 		gosub SetBasicDialogOptions
       
   411 		)
       
   412 
       
   413 	; And initialise any not yet initialised controls to their default
       
   414 	dialog.set PLATFORM				"&Platform"
       
   415 	dialog.set AUTOLOAD_MODULE		"&AutoloadModule"
       
   416 	dialog.set RAMADDR1				"&RamAddr1"
       
   417 	dialog.set RAMIMAGE1			"&RamImage1"
       
   418 	dialog.set RAMADDR2				"&RamAddr2"
       
   419 	dialog.set RAMIMAGE2			"&RamImage2"
       
   420 	dialog.set RAMADDR3				"&RamAddr3"
       
   421 	dialog.set RAMIMAGE3			"&RamImage3"
       
   422 	dialog.set RAMADDR4				"&RamAddr4"
       
   423 	dialog.set RAMIMAGE4			"&RamImage4"
       
   424 	dialog.set FLASHADDR			"&FlashAddr"
       
   425 	dialog.set FLASHIMAGE			"&FlashImage"
       
   426 	dialog.set FLASHERASEPROTECT	"&FlashEraseProtect"
       
   427 	dialog.set FLASHWRITEPROTECT	"&FlashWriteProtect"
       
   428 	
       
   429 
       
   430 	return
       
   431 
       
   432 //==============================================================================
       
   433 ReadDialog:
       
   434 
       
   435 	// Read dialog box config into global environment variables
       
   436 	&Platform=dialog.string(PLATFORM)
       
   437 	&AutoloadModule=dialog.string(AUTOLOAD_MODULE)
       
   438 	&RamImage1=dialog.string(RAMIMAGE1)
       
   439 	&RamAddr1=dialog.string(RAMADDR1)
       
   440 	&RamImage2=dialog.string(RAMIMAGE2)
       
   441 	&RamAddr2=dialog.string(RAMADDR2)
       
   442 	&RamImage3=dialog.string(RAMIMAGE3)
       
   443 	&RamAddr3=dialog.string(RAMADDR3)
       
   444 	&RamImage4=dialog.string(RAMIMAGE4)
       
   445 	&RamAddr4=dialog.string(RAMADDR4)
       
   446 	&FlashAddr=dialog.string(FLASHADDR)
       
   447 	&FlashImage=dialog.string(FLASHIMAGE)
       
   448 
       
   449 	if "&RamImage"==""
       
   450 	(
       
   451 		&RamImage="&RamImage1"
       
   452 		&RamAddr="&RamAddr1"
       
   453 	)
       
   454 	&FlashEraseProtect=dialog.boolean(FLASHERASEPROTECT)
       
   455 	if dialog.boolean(FLASHERASEPROTECT)==(0==0)
       
   456 	(
       
   457 		&FlashEraseProtect="ON"
       
   458 	)
       
   459 	else
       
   460 	(
       
   461 		&FlashEraseProtect="OFF"
       
   462 	)
       
   463 
       
   464 	&FlashWriteProtect=dialog.boolean(FLASHWRITEPROTECT)
       
   465 	if dialog.boolean(FLASHWRITEPROTECT)==(0==0)
       
   466 	(
       
   467 		&FlashWriteProtect="ON"
       
   468 	)
       
   469 	else
       
   470 	(
       
   471 		&FlashWriteProtect="OFF"
       
   472 	)
       
   473 
       
   474 	; Make sure that target addresses have been specified and if not, use a sensible default that will
       
   475 	; work on at least some platforms
       
   476 	if ("&RamAddr1"=="")
       
   477 	(
       
   478 		&RamAddr1="0x80000000"
       
   479 	)
       
   480 
       
   481 	if ("&RamAddr2"=="")
       
   482 	(
       
   483 		&RamAddr2="0x80000000"
       
   484 	)
       
   485 
       
   486 	if ("&RamAddr3"=="")
       
   487 	(
       
   488 		&RamAddr3="0x80000000"
       
   489 	)
       
   490 
       
   491 	if ("&RamAddr4"=="")
       
   492 	(
       
   493 		&RamAddr4="0x80000000"
       
   494 	)
       
   495 
       
   496 	if ("&FlashAddr"=="")
       
   497 	(
       
   498 		&FlashAddr="0"
       
   499 	)
       
   500 
       
   501 	return
       
   502 
       
   503 //==============================================================================
       
   504 SavePlatformToFile:
       
   505 	ENTRY &filename
       
   506 
       
   507 	gosub ReadDialog
       
   508 
       
   509 	// Open the config file for writing
       
   510 	open #1 &filename /Create
       
   511 
       
   512 	// Write the config to the file in script format for loading later
       
   513 	write #1 "&"+"Platform="+'"'+"&Platform"+'"'
       
   514 	write #1 "&"+"AutoloadModule="+'"'+"&AutoloadModule"+'"'
       
   515 	write #1 "&"+"RamAddr="+'"'+"&RamAddr"+'"'
       
   516 	write #1 "&"+"RamImage="+'"'+"&RamImage"+'"'
       
   517 	write #1 "&"+"RamAddr1="+'"'+"&RamAddr1"+'"'
       
   518 	write #1 "&"+"RamImage1="+'"'+"&RamImage1"+'"'
       
   519 	write #1 "&"+"RamAddr2="+'"'+"&RamAddr2"+'"'
       
   520 	write #1 "&"+"RamImage2="+'"'+"&RamImage2"+'"'
       
   521 	write #1 "&"+"RamAddr3="+'"'+"&RamAddr3"+'"'
       
   522 	write #1 "&"+"RamImage3="+'"'+"&RamImage3"+'"'
       
   523 	write #1 "&"+"RamAddr4="+'"'+"&RamAddr4"+'"'
       
   524 	write #1 "&"+"RamImage4="+'"'+"&RamImage4"+'"'
       
   525 	write #1 "&"+"FlashAddr="+'"'+"&FlashAddr"+'"'
       
   526 	write #1 "&"+"FlashImage="+'"'+"&FlashImage"+'"'
       
   527 	write #1 "&"+"FlashWriteProtect="+'"'+"&FlashWriteProtect"+'"'
       
   528 	write #1 "&"+"FlashEraseProtect="+'"'+"&FlashEraseProtect"+'"'
       
   529 
       
   530 	// All done, so close the file
       
   531 	close #1
       
   532 
       
   533 	// Do any tidyup
       
   534 	// type &filename
       
   535 
       
   536 	RETURN
       
   537 
       
   538 
       
   539 //==============================================================================
       
   540 SavePlatform:
       
   541 
       
   542 	//gosub PrintSeperator
       
   543 	//print "saving platform "+dialog.string(PLATFORM)
       
   544 
       
   545 	// Open the config file for writing
       
   546 	&filename="&PlatformsDir\"+dialog.string(PLATFORM)+"\&UserConfigCmm"
       
   547 
       
   548 	print "Saving platform to &filename"
       
   549 	gosub SavePlatformToFile &filename
       
   550 	RETURN
       
   551 
       
   552 
       
   553 
       
   554 
       
   555 
       
   556 
       
   557 //////////////////////////////////////////////////////////////////////////////
       
   558 //
       
   559 // GeneratePlatformList
       
   560 //
       
   561 // Generate the list of platforms from a directory listing of the platforms
       
   562 // script dir.
       
   563 //
       
   564 //////////////////////////////////////////////////////////////////////////////
       
   565 GeneratePlatformList:
       
   566 	LOCAL &data
       
   567 	LOCAL &dirList
       
   568 	LOCAL &blanks
       
   569 
       
   570 	&filename="&TMPDIR\platformList.txt"
       
   571 	prt.file &filename
       
   572 	winprint.dir &PlatformsDir
       
   573 
       
   574 	&blanks=0
       
   575 	open #1 &filename /Read
       
   576 
       
   577 	// discard first line as it is the header & directory name
       
   578 	READ #1 %line &data
       
   579 
       
   580 	// read the file line at a time, process it and add directory entries to the list of supported platforms
       
   581 	RePeaT
       
   582 	(
       
   583 		READ #1 %line &data
       
   584 
       
   585 		; Okay, this is because there isn't a way of the read returning EOF
       
   586 		; the easiest solution is to count the number of blank lines and if
       
   587 		; it crosses a threshold assume that the end was reached.
       
   588 		if "&data"==""
       
   589 			(
       
   590 			&blanks=&blanks+1
       
   591 			if &blanks>10
       
   592 				(
       
   593 				goto endloop
       
   594 				)
       
   595 			)
       
   596 
       
   597 		// Remove all dots
       
   598 		gosub ReplaceAll "&data" "." ""
       
   599 		entry &tmp
       
   600 		&data=&tmp
       
   601 
       
   602 		// Replace multiple spaces with one space
       
   603 		gosub ReplaceAll "&data" "  " " "
       
   604 		entry &tmp
       
   605 		&data=&tmp
       
   606 
       
   607 		// Remove leading spaces
       
   608 		gosub RemoveLeadingChars "&data" " "
       
   609 		entry &tmp
       
   610 		&data=&tmp
       
   611 
       
   612 		// Replace all spaces with a comma
       
   613 		gosub ReplaceAll "&data" " " ","
       
   614 		entry &tmp
       
   615 		&data=&tmp
       
   616 
       
   617 		if ("&dirList"=="")
       
   618 		(
       
   619 			&dirList="&data"
       
   620 		)
       
   621 		else
       
   622 		(
       
   623 			&dirList="&dirList,&data"
       
   624 		)
       
   625 	)
       
   626 endloop: CLOSE #1
       
   627 
       
   628 	&platformList="&dirList"
       
   629 
       
   630 	RETURN
       
   631 
       
   632 
       
   633 
       
   634 
       
   635 
       
   636 
       
   637 //////////////////////////////////////////////////////////////////////////////
       
   638 //
       
   639 //
       
   640 //
       
   641 //////////////////////////////////////////////////////////////////////////////
       
   642 RemoveLeadingChars:
       
   643 	LOCAL &inStr &removeStr &pos1 &pos2 &outStr
       
   644 	ENTRY &inStr &removeStr
       
   645 
       
   646 //	print "REMOVE: &inStr &removeStr"
       
   647 
       
   648 	&pos1=string.scan(&inStr,&removeStr,0)
       
   649 //	print "pos1=&pos1"
       
   650 
       
   651 	if (&pos1==0)
       
   652 	(
       
   653 //		print "found!!!!!!!!"
       
   654 
       
   655 		&len1=string.len(&inStr)
       
   656 		&len2=string.len(&removeStr)
       
   657 
       
   658 //		print "len1=&len1"
       
   659 //		print "len2=&len2"
       
   660 
       
   661 		&start=string.mid("&inStr",0,&pos1+1)
       
   662 		&end=string.mid("&inStr",&pos1+&len2+1,&len1)
       
   663 
       
   664 //		print "start : &start"
       
   665 //		print "end   : &end"
       
   666 
       
   667 		&outStr="&start&end"
       
   668 //		print "outStr: &outStr"
       
   669 	)
       
   670 	else
       
   671 	(
       
   672 		&outStr="&inStr"
       
   673 
       
   674 	)
       
   675 	return &outStr
       
   676 
       
   677 
       
   678 //////////////////////////////////////////////////////////////////////////////
       
   679 //
       
   680 // ReplaceAll
       
   681 //
       
   682 // Repeatedly call ReplaceInString to replace all occurrences of a given
       
   683 // string (removeStr) with the new string (removeStr).
       
   684 //
       
   685 // Parameters:
       
   686 //	&inStr		    original string where replacements should be made
       
   687 //  &removeStr      string to remove
       
   688 //  &replaceStr     string to add in replacement for &removeStr
       
   689 //
       
   690 // Returns:
       
   691 //  string, in quotes.  These quotes have to be stripped off to make the
       
   692 //  returned string useful.
       
   693 //
       
   694 // Example usage:
       
   695 //
       
   696 //      &spaceStr="1 2 3 4 5 6 7 8 9"
       
   697 //	    gosub ReplaceAll "&spaceStr" " " ","
       
   698 //	    entry &retStr              // this string has extra quotes
       
   699 //	    &commaStr=&retStr          // this strips the extra quotes from the string
       
   700 //
       
   701 // The expected output will be:
       
   702 //    "1,2,3,4,5,6,7,8,9"
       
   703 //
       
   704 //////////////////////////////////////////////////////////////////////////////
       
   705 ReplaceAll:
       
   706 	ENTRY &inStr &removeStr &replaceStr
       
   707 
       
   708 	LOCAL &ret
       
   709 
       
   710 	repeat
       
   711 	(
       
   712 		gosub ReplaceInString &inStr &removeStr &replaceStr
       
   713 		entry &ret
       
   714 
       
   715 		if (&inStr==&ret)
       
   716 		(
       
   717 			goto allreplaced
       
   718 		)
       
   719 		&inStr="&ret"
       
   720 	)
       
   721 allreplaced:
       
   722 	return &inStr
       
   723 
       
   724 
       
   725 //////////////////////////////////////////////////////////////////////////////
       
   726 //
       
   727 // ReplaceInString
       
   728 //
       
   729 // Within a given string (inStr), replace a single instance of a
       
   730 // string (removeStr) with a new string (replaceStr).
       
   731 //
       
   732 // Parameters:
       
   733 //	&inStr		    original string where replacements should be made
       
   734 //  &removeStr      string to remove
       
   735 //  &replaceStr     string to add in replacement for &removeStr
       
   736 //
       
   737 // Returns:
       
   738 //  string, in quotes.  These quotes have to be stripped off to make the
       
   739 //  returned string useful.
       
   740 //
       
   741 // Example usage:
       
   742 //      &spaceStr="1 2 3 4 5 6 7 8 9"
       
   743 //		gosub ReplaceInString &spaceStr " " ","
       
   744 //		entry &ret
       
   745 //		&commaStr=&ret
       
   746 //
       
   747 // The expected output will be:
       
   748 //    "1,2 3 4 5 6 7 8 9"
       
   749 //
       
   750 //////////////////////////////////////////////////////////////////////////////
       
   751 ReplaceInString:
       
   752 	LOCAL &inStr &removeStr &pos1 &pos2 &outStr
       
   753 	ENTRY &inStr &removeStr &replaceStr
       
   754 
       
   755 	&pos1=string.scan(&inStr,&removeStr,0)
       
   756 
       
   757 	if (&pos1==-1)
       
   758 	(
       
   759 		&outStr="&inStr"
       
   760 	)
       
   761 	else
       
   762 	(
       
   763 		&len1=string.len(&inStr)
       
   764 		&len2=string.len(&removeStr)
       
   765 
       
   766 		&start=string.mid("&inStr",0,&pos1+1)
       
   767 		&middle=string.mid("&inStr",&pos1+1,&pos1+1+&len2)
       
   768 		&end=string.mid("&inStr",&pos1+&len2+1,&len1)
       
   769 
       
   770 		&outStr="&start"+&replaceStr+"&end"
       
   771 	)
       
   772 	return &outStr
       
   773 
       
   774 
       
   775 //==============================================================================
       
   776 GetImageFromUser:
       
   777 	ENTRY &dialogElement
       
   778 
       
   779 	LOCAL &tmpRamImg
       
   780 	LOCAL &tmp1
       
   781 	LOCAL &tmpfile
       
   782 
       
   783 	&tmpRamImg=dialog.string(&dialogElement)
       
   784 
       
   785 	&tmp1=os.file.path("&tmpRamImg")+"\"+"&defaultExt"
       
   786 
       
   787 	dialog.file "&tmp1"
       
   788 	entry &tmpfile
       
   789 	if ("&tmpfile"!="")
       
   790 	(
       
   791 		&tmpRamImg="&tmpfile"
       
   792 
       
   793 		dialog.set &dialogElement "&tmpRamImg"
       
   794 	)
       
   795 	return
       
   796 
       
   797 //==============================================================================
       
   798 ListSourcePaths:
       
   799 	symbol.sourcepath.list
       
   800 	return
       
   801 
       
   802 //==============================================================================
       
   803 ReloadSourcePaths:
       
   804 	do sourcepaths.cmm
       
   805 	return
       
   806 
       
   807 //==============================================================================
       
   808 EditSourcePath:
       
   809 
       
   810 	if os.file("&PlatformsDir\&Platform\customsourcepaths.cmm")
       
   811 		(
       
   812 		print "Editing custom source paths"
       
   813 		)
       
   814 	else
       
   815 		(
       
   816 		if os.file("&PlatformsDir\&Platform\defaultsourcepaths.cmm")
       
   817 			(
       
   818 			print "No custom source paths defined for this platform. Creating from default source paths."
       
   819 			copy &PlatformsDir\&Platform\defaultsourcepaths.cmm &PlatformsDir\&Platform\customsourcepaths.cmm
       
   820 
       
   821 			// without this delay, the user gets prompted to reload the file
       
   822 			wait 0.5s
       
   823 			)
       
   824 		)
       
   825 	edit &PlatformsDir\&Platform\customsourcepaths.cmm
       
   826 	return
       
   827 
       
   828 //==============================================================================
       
   829 DefaultSourcePaths:
       
   830 	if os.file("&PlatformsDir\&Platform\customsourcepaths.cmm")
       
   831 		(
       
   832 		print "Removing custom source paths"
       
   833 		del &PlatformsDir\&Platform\customsourcepaths.cmm
       
   834 		)
       
   835 	else
       
   836 		(
       
   837 		print "Already using default source paths, nothing to do..."
       
   838 		)
       
   839 	return
       
   840 
       
   841 //==============================================================================
       
   842 SaveSourcePaths:
       
   843 	print "Saving custom source paths to file &PlatformsDir\&Platform\customsourcepaths.cmm"
       
   844 	store &PlatformsDir\&Platform\customsourcepaths.cmm SPATH
       
   845 	return
       
   846