Code: Select all
Let>inputfile=d:\names.txt
Let>outputfile=d:\names_sorted.txt
ReadFile>inputfile,NamesList
Separate>NamesList,%CRLF%,Names
Let>Max=Names_Count
GoSub>Bubble_Sort
//Write resultant list to a new file
IfFileExists>outputfile
DeleteFile>outputfile
Endif
Let>i=1
Repeat>i
Let>thisname=Names_%i%
WriteLn>outputfile,k,thisname
Let>i=i+1
Until>i=Max
Run>Notepad.exe %outputfile%
//Sorts Files_x array
//Set Max to number of elements
SRT>Bubble_Sort
Let>has_swapped=0
let>i=1
Repeat>i
Let>next=i+1
//change sign on next line to change direction of sort
if>Names_%i%>Names_%next%
Let>store=Names_%i%
Let>Names_%i%=Names_%next%
Let>Names_%next%=%store%
Let>has_swapped=1
endif
Let>i=i+1
Until>i=Max
If>has_swapped=1
GoSub>Bubble_Sort
Endif
End>Bubble_Sort
When I step through the code in the debugger it appears that the If statement below is being ignored. Even when "has_swapped"=1 the Bubble_Sort subroutine does not get called again.
If>has_swapped=1
GoSub>Bubble_Sort
Endif
I have made sure that there are no trailing spaces in my code but I still can't get this example to run on my system. I am running Macroscheduler 7.4 Pro under Windows XP. All my other scripts are working fine.
I would appreciate any thoughts on what I can do to get this routine to work
[/code]