How-it-works file for !dName
----------------------------

version 0.1
-----------

The original role for this program was to batch rename a series of sprites
into something more meaningful than Sprite1, Sprite2 etc.

The setup was quite simple: one writable icon (icon 0) containing the text to be changed - 'Sprite' in this case - and one writable icon (icon 1) with the new text.

This could all be handled by a few lines in DEF FNuser_loaddata.
The first step was to get the directory path and the leafname for a file dropped on the main window and store them in two strings. This is done by lines 1060 and 1070

The next step was to get the text in the two writable icons (lines 1100 and 1110) into two strings (change$ and to$) and then search filename$ for the text in change$. This is done by line 1120, which records the position in filename$ of change$ in a variable posit% (e.g. in the filename 'Sprite1', the string 'it' is at position 4, so posit%=4). If the change$ text isn't present then posit%=0. Line 1140 ensures that if this is the case nothing further is done with the file.

Chances are the length of the filename will be altered by a change in the text, so this has to be accounted for. Line 1130 records the length of the original filename (filename$) as well as the length of change$.

Lines 1150 and 1160 record any text lying before or after the change$ text for future reference. Line 1170 then sandwiches the to$ text between these two, to give the new filename, stored in newname$.

The actual renaming is done by line 1180 using the directory path stored earlier and the new filename. path$ is the original path passed to Dr Wimp when the file was dropped.

version 0.2
-----------

With version 1 renaming worked, but text couldn't be added onto the end of a group of files if they had a different ending, which Sprite1, Sprite2 etc. obviously do. This functionality is most useful for adding a PC style ending. e.g. Sprite1/gif

This process is actually simpler than what is done by version 1 and only takes 3 lines (1211-1221). 

The only complication comes from making the decision to rename or add-on. The approach taken was to use radio icons to select a change (icon 4) or an add-on (icon 5) to the filename, before dragging the files onto the window.

This required an addition to PROCuser_mouseclick (lines 460-500), which just sets radio%=1 if icon 4 (change) is selected and radio%=2 if icon 5 (add on) is selected. A simple change to FNuser_loaddata at lines 1080, 1090 and 1210 then directs the action taken when a file or files is dropped onto the main window. The default selection is 'change', set by line 330. This is very similar to the MyApp tutorial in the Dr Wimp manual.