GFL_SORTTYPE

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

GFL_SORTTYPE

Post by mightycpa » Thu Mar 04, 2021 3:22 am

Hi,

I'm logging in via POP3, retrieving emails in order, saving them to my folder, in order.
The GFL command says to set the GFL_SORTTYPE variable to control the order in which the files are placed into the file array. I set the variable to 3. I checked the online variable help page and noticed that variable does not appear in the list.

I do the GFL and the files are sorted descending. I set the variable to 4 and the files are still sorted descending.

I have done an ArraySort as a workaround, but setting the GFL_SORTTYPE variable doesn't seem to work properly.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Re: GFL_SORTTYPE

Post by Bob Hansen » Fri Mar 05, 2021 5:52 pm

Just curious about the sorting "field" you are looking at. Using "4" sorts by name, ascending. That is the File Name. Are you trying to sort by the Sender Name, or the Recipient Name? That would not be the Name used by the "4".

If that is what you want sorted, we may be able to help you. And how are you capturing the list of Emails? Can you show the result, providing a list of the email names, and/or a list of emails showing the Sender, Recipient, and Date? Different Email clients have different layouts.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: GFL_SORTTYPE

Post by mightycpa » Fri Mar 05, 2021 6:43 pm

Hi, actually, 3 is ascending. 4 is descending order. From the docs:
To change the sort order set the GFL_SORTTYPE variable to one of the following values
0 = No sorting (default) - returned as reported by Windows.
1 = Date ascending
2 = Date descending
3 = Name ascending
4 = Name descending
5 = Size ascending
6 = Size descending
When I pull the emails from GMail using POP3, I'm saving the files to disk, they get named MSG1.TXT, MSG2.TXT and so on. I use GFL to process each of those files. When I use GFL> they show up in reverse order, where MSG1.TXT is last. This happens whether I use 3 or 4 or leave it unspecified. I haven't tried the others.

I've added an ArraySort> to put them in the desired order, so my post ended up being a bug report.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Re: GFL_SORTTYPE

Post by Bob Hansen » Fri Mar 05, 2021 7:53 pm

Ssorry about the 3/4 mixup, my mistake.

I don't see a problem in GFL.
Here is my test list: Image
And this code works for me:

Code: Select all

Let>GFL_SORTTYPE=
GetFileList>c:\temp\temp*.txt,files
MessageModal>files
Let>GFL_SORTTYPE=0
GetFileList>c:\temp\temp*.txt,files
MessageModal>files
Let>GFL_SORTTYPE=1
GetFileList>c:\temp\temp*.txt,files
MessageModal>files
Let>GFL_SORTTYPE=2
GetFileList>c:\temp\temp*.txt,files
MessageModal>files
Let>GFL_SORTTYPE=3
GetFileList>c:\temp\temp*.txt,files
MessageModal>files
Let>GFL_SORTTYPE=4
GetFileList>c:\temp\temp*.txt,files
MessageModal>files
Let>GFL_SORTTYPE=5
GetFileList>c:\temp\temp*.txt,files
MessageModal>files
Let>GFL_SORTTYPE=6
GetFileList>c:\temp\temp*.txt,files
MessageModal>files
I suspect there may be an error in the way you are making the array.
Can you provide the list and the code you are using that gives the wrong result?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: GFL_SORTTYPE

Post by mightycpa » Fri Mar 05, 2021 10:39 pm

Don't believe me, eh? :lol:

Here's my folder:
Image

Code:

Code: Select all

//FILE PROCESSING
Let>GFL_SORTTYPE=3
//DELETE *BODY*.TXT
//ONLY THING THAT REMAINS IS MSG?.TXT
DeleteFile>C:\Users\mightycpa\Documents\email\*BODY*.TXT
//READ FOLDER TO PROCESS EACH FILE
GetFileList>C:\Users\mightycpa\Documents\email\*.*,vfiles
Separate>vfiles,;,vfile_names
//TO PUT THEM IN DESIRED ORDER
ArraySort>vfile_names
Here is the value that shows up in vfiles: vfiles:C:\Users\mightycpa\Documents\email\MSG4.txt;C:\Users\mightycpa\Documents\email\MSG3.txt;C:\Users\mightycpa\Documents\email\MSG2.txt;C:\Users\mightycpa\Documents\email\MSG1.txt

And then in the array before the sort, the first element is MSG4..txt and so on, like this:
Image

This particular machine has MS14.3.03, Windows 10 Enterprise on it. I haven't tried it on my MS15 machine yet, I'll report back if that's any different. That one is Server 2008 R2, I think.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Re: GFL_SORTTYPE

Post by Bob Hansen » Fri Mar 05, 2021 11:07 pm

Don't get rid of me that easy.
Of course I believe you. But have been unable to duplicate your problem.

Now that I see the code you are using, I think I have a much better of what you are doing. No time right now, but I have a few ideas, will try to test them out later tonight. One thing I will be doing is displaying "file" after each RegEx, because I don't see anything that replaces the original "file". My original file is also in descending order, before anything else is done. So I want to SEE it before and after I RegEx it.

Stay tuned......
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: GFL_SORTTYPE

Post by mightycpa » Fri Mar 05, 2021 11:32 pm

And I've been unable to duplicate your lack of a problem! :mrgreen:
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Re: GFL_SORTTYPE

Post by Bob Hansen » Sat Mar 06, 2021 12:37 am

OK, I have run your code and still cannot duplicate your problem.
Here is my version of your code. I added a vComma variable for your Separate command. The actual file uses commas for delimiter, you were using a semi-colon.
I already had Temp1.txt that I had used in my test, but renamed them to MSG1.txt, also making them Case Sensitive in order to duplicate your situation. So the only difference is the path that they came from.

Code: Select all

// ---------------------------
//FILE PROCESSING
Let>GFL_SORTTYPE=3
//DELETE *BODY*.TXT
//ONLY THING THAT REMAINS IS MSG?.TXT
DeleteFile>C:\Users\mightycpa\Documents\email\*BODY*.TXT
//READ FOLDER TO PROCESS EACH FILE
//GetFileList>C:\Users\mightycpa\Documents\email\*.*,vfiles
GetFileList>C:\Temp\MSG*.txt,vfiles
MessageModal>AfterGFL-3:%CRLF%%vfiles%
Let>vComma=,
Separate>vfiles,vComma,vfile_names
MessageModal>After Separate:%CRLF%%vfile_names_1%
//TO PUT THEM IN DESIRED ORDER
ArraySort>vfile_names
MessageModal>After ArraySort:%CRLF%%vfile_names_1%
I took Module shots after each process.
Result after GFL: GOOD
Image
Result after Separate command: GOOD
//Image
Result after ArraySort command: GOOD
Image
And as you can see, they are all in Order. Nothing needed to be done after the GFL command.
Image

So what happens if you run my version of your code? Did you try running my earlier version?
---Touched ya ---- You're it!
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: GFL_SORTTYPE

Post by mightycpa » Sat Mar 06, 2021 12:58 am

Yep. Every single one came out in the same order.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Re: GFL_SORTTYPE

Post by Bob Hansen » Sat Mar 06, 2021 1:30 am

So, what is the problem? You wrote:
I do the GFL and the files are sorted descending. I set the variable to 4 and the files are still sorted descending.
Is the problem that 3 is not in descending order, because they are not.
Is the problem that 4 is in descending order, because they are, as they should be.
If you change the setting from 3 to 4, you get the expected results, names in descending order.

So, what is the problem? I cannot see the setting of 3 showing the names in descending order.
And your last post agreed, they are in correct order.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: GFL_SORTTYPE

Post by mightycpa » Sat Mar 06, 2021 1:41 am

Hi Bob, I was about to write. I'm not sure that I'll be able to run that script on the other system tonight. Definitely this weekend sometime, if not tonight.

What's the problem? The problem is that GFL can't get my emails in ascending order, which is actually the order in which I receive the emails. Fixed with array sort.

Secondarily, and I didn't know this until I ran your script, none of the GFL_SORTTYPE values change the sort. Not by size, by date, name, nothing changes. It's all by name, descending. That's what I meant in my previous post, that the GFL_SORTTYPE value has no effect. For the moment, this isn't a problem, but who knows? In the future, it might be.

I suspect that value 4 doesn't really do anything either. It's just stuck on descending by name, the sort value notwithstanding.

The fact that you can sort properly leads me to believe that this is either MS version related (doubtful) and/or Windows version related. That's why I want to run the other one.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Re: GFL_SORTTYPE

Post by Bob Hansen » Sat Mar 06, 2021 5:34 am

AHA!
I think I see a possible bit of confusion. You are thinking the Sorts, don't change, and I can now see what could be the issue. We could both be correct. I noticed that al your files show the same date and time. But my files (that I say work) all have different times. Did you make a Test file named #1, and then make three copies for tests #2-#4. If that is the case, then any system will treat them all alike. My test files happened to be on my system and all had unique time stamps, so they are different. And I bet they all have the same size also. So the sorting may be erratic. My test files all have unique names, date/times, and sizes, that is why I could see the difference. When looking at the result, I was checking the date/time, and the size, not the names when using options 3-6.

My suggestion is to make four new test files. Make one, then wait 3-5 minutes between making each of the next three files. Make sure they are all different sizes also. That is always a test problem, trying to make sure you are testing for all the possibilities. Note in my code I included the Sort values of 0 and 1 to consider the possibility of a blank value. I did not just test the 3 and 4 values you were concerned about.

I think you will find it working the way you want.

Good luck.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: GFL_SORTTYPE

Post by mightycpa » Sat Mar 06, 2021 6:12 am

No, when I originally tried it, the files were different sizes and different names. It's not that. Also, because Windows also records the second that a file is created, the timestamps are indeed unique. I checked. Moreover, when I ran your scripts, I changed the names of my files to the same names that you provided, and I added some data to a couple of them. But changing the modified date may not make a difference. The command may look at the creation date. It also may look at only the date portion.

My use case will always have identical dates and nearly identical times, unless I happen to pull emails over the cusp of the hour. But even if you're right, that's no excuse for not being able to sort by name. I wouldn't have even noticed if I had tried to do it by date, because of the condition you identified. I honestly don't believe that has anything to do with it.

Anyway, that's my prediction, and it is easy enough to point to another folder and try.

DRUMROLL.....

Exact same behavior on wildly different files.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

User avatar
Grovkillen
Automation Wizard
Posts: 1023
Joined: Fri Aug 10, 2012 2:38 pm
Location: Bräcke, Sweden
Contact:

Re: GFL_SORTTYPE

Post by Grovkillen » Sat Mar 06, 2021 6:49 am

If nothing works for you, SFK is a tool I've used to cover for MS's shortcomings.

http://www.stahlworks.com/dev/index.php?tool=list

Code: Select all

SFK.exe -list -late C:\your\folder
Let>ME=%Script%

Running: 15.0.24
version history

mightycpa
Automation Wizard
Posts: 343
Joined: Mon Jan 12, 2004 4:07 pm
Location: Vienna, VA

Re: GFL_SORTTYPE

Post by mightycpa » Sat Mar 06, 2021 7:50 am

The ArraySort> worked for me. This is all just academic for now, but thanks for that suggestion.
"A facility for quotation covers the absence of original thought." - Lord Peter Wimsey

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