Hi,

I don't have AmiBroker on this computer. So, I can't test this out. 
But, see if the following article will do what you need. It is doing 
an alphabetical sort of the entire line, which means that the sort 
will effectively be on the first column.

The easiest approach would probably be to just embed the script 
directly into your AFL wrapped in scripting tags as follows:

EnableScript("vbscript");
... // Usual AFL code
<%
// script found at 
http://www.microsoft.com/technet/scriptcenter/resources/qanda/feb05/he
y0225.mspx
%>
... // Usual AFL code

Or, for code reuse, you could create a function in a separate AFL 
file and #include it wherever needed. If neither of those work out, 
you could instead have the vbscript stored in a .vbs file and choose 
to run it from AFL by calling out to wscript.

Just in case you have trouble accessing the link provided, here is 
the actual script. Change the hard coded data file path 
(C:\Scripts\Computers.txt) to wherever your data file will be. If you 
want to parameterize it to specify where the data file is or which 
column to sort on, that should be do-able with some additional work.

The behavior of the script is explained on the webpage at the link 
provided.

Mike


Const adVarChar = 200
Const MaxCharacters = 255
Const ForReading = 1
Const ForWriting = 2

Set DataList = CreateObject("ADOR.Recordset")
DataList.Fields.Append "ComputerName", adVarChar, MaxCharacters
DataList.Open

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\Scripts\Computers.txt", 
ForReading)

Do Until objFile.AtEndOfStream
    strLine = objFile.ReadLine
    DataList.AddNew
    DataList("ComputerName") = strLine
    DataList.Update
Loop

objFile.Close

DataList.Sort = "ComputerName"

DataList.MoveFirst
Do Until DataList.EOF
    strText = strText & DataList.Fields.Item("ComputerName") & vbCrLf
    DataList.MoveNext
Loop

Set objFile = objFSO.OpenTextFile("C:\Scripts\Computers.txt", 
ForWriting)

objFile.WriteLine strText
objFile.Close



Reply via email to