Folder Names into Listbox in alphabet orders

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
hoangvo81
Pro Scripter
Posts: 69
Joined: Tue Feb 07, 2012 8:02 pm

Folder Names into Listbox in alphabet orders

Post by hoangvo81 » Mon Dec 16, 2013 4:52 pm

Hi,

Just a snippet, since it dawns to me today when i was trying to organize the folder list into a listbox in alphabet orders.


GetFileList> , function returns the folder in descending orders where we want it in asc order.

Code: Select all

Let>GLF_Type=1
let>FoldersList=
GetFileList>c:\temp\*.*,fldList,crlf
separate>fldList,crlf,fldrs
let>k=%fldrs_count%+1
repeat>k
sub>k,1
extractFileName>fldrs_%k%,tmp
concat>FoldersList,%tmp%%crlf%
until>k=1

trim>FoldersList,FoldersList
setDialogProperty>dialog1,msListBox,Text,%FoldersList%


if you can think of a better way to do this without having to open up command and generating an output file and reading from that output file.
I would like to do all the items using Macroscheduler and not have to call addition programs.

Thanks,

Hoang

User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Post by Rain » Mon Dec 16, 2013 5:19 pm

Have you tried setting "Sorted" to true under ListBox properties?

Here is an example:

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 358
  Top = 74
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 151
  ClientWidth = 278
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 8
    Top = 16
    Width = 31
    Height = 13
    Caption = 'Sorted'
  end
  object Label2: TLabel
    Left = 136
    Top = 16
    Width = 43
    Height = 13
    Caption = 'Unsorted'
  end
  object MSListBox1: tMSListBox
    Left = 8
    Top = 32
    Width = 121
    Height = 97
    ItemHeight = 13
    Sorted = True
    TabOrder = 8
    SelectedIndex = -1
  end
  object MSListBox2: tMSListBox
    Left = 136
    Top = 32
    Width = 121
    Height = 97
    ItemHeight = 13
    TabOrder = 9
    SelectedIndex = -1
  end
end
EndDialog>Dialog1


LabelToVar>Alphabet_Data,AlphabetRes,1,0,{"*/"}
SetDialogProperty>Dialog1,MSListBox1,Text,AlphabetRes
SetDialogProperty>Dialog1,MSListBox2,Text,AlphabetRes

Show>Dialog1,


/*
Alphabet_Data:
Z
Y
X
W
V
U
T
S
R
Q
P
O
N
M
L
K
J
I
H
G
F
E
D
C
B
A
*/


hoangvo81
Pro Scripter
Posts: 69
Joined: Tue Feb 07, 2012 8:02 pm

Post by hoangvo81 » Mon Dec 16, 2013 6:33 pm

Beautiful,

but it will still be a problem as we have to extract the file name from the GetFileList otherwise it will give us the full path.

none the less, did not know there was a sorted property for the listbox and will use it in the future when i do need to do so for different set of data.


Thanks

User avatar
JRL
Automation Wizard
Posts: 3501
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Dec 17, 2013 5:56 pm

but it will still be a problem as we have to extract the file name from the GetFileList otherwise it will give us the full path.
Easy to fix with StringReplace>.

Code: Select all

GetFileList>%Temp_dir%*.*,vList,crlf

StringReplace>vList,%Temp_Dir%,,vList

MDL>vList

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts