Guidance
指路人
g.yi.org
Guidance Forums / Reginald Rexx / Bug in SORT DOWN

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. Bug in SORT DOWN
#12491
Posted by: Michael S 2008-10-31 01:46:11
Try the following

/* */
code_sections.1 = RIGHT(100,8,'0') || 'Section 100'
code_sections.2 = RIGHT(120,8,'0') || 'Section 120'
code_sections.3 = RIGHT(80,8,'0') || 'Section 80'
code_sections.0 = 3 

SORT down code_sections. a +8

DO i = 1 TO 3
	SAY code_sections.i
END

Without the DOWN it works, with the DOWN it fails. Can't se that I'm doing anything wrong
Message2.
#12492
Posted by: Jeff Glatt 2008-10-31 03:31:35
Is this one of those "I'm trying to do a numeric sort with a string sort algorithm" things? SORT is an alphabetic sort. It doesn't sort by numeric value. To make a numeric sort work with this algorithm, all numbers must be padded out with leading zeros to be the same amount of digits (and no embedded spaces/commas)
Message3.
#12493
Posted by: Doug Arndt 2008-10-31 03:48:22
Change the code a bit, and we find that code_sections.1 has been dropped
Resulting in:
Code_sections.1 does not exist
00000120Section 120
00000100Section 100

(Hey Michael, you could just Do i = 3 to 1 .... naw, just joking)

/* */
code_sections.1 = RIGHT(100,8,'0') || 'Section 100'
code_sections.2 = RIGHT(120,8,'0') || 'Section 120'
code_sections.3 = RIGHT(80,8,'0') || 'Section 80'
code_sections.0 = 3

SORT down code_sections. a +8

DO i = 1 TO 3
 If exists("Code_sections.i") = 1 then
    SAY code_sections.i
 else
    Say 'Code_sections.'i 'does not exist'
END
Doug
Message4.
#12494
Posted by: Doug Arndt 2008-10-31 03:54:04
Jeff, just saw your post.  Michael's data is zero filled.
The problem is the sort leaves the .1 item dropped.
Expand the Do to 4 and we get:

Code_sections.1 does not exist
00000120Section 120
00000100Section 100
00000080Section 80

/* */
code_sections.1 = RIGHT(100,8,'0') || 'Section 100'
code_sections.2 = RIGHT(120,8,'0') || 'Section 120'
code_sections.3 = RIGHT(80,8,'0') || 'Section 80'
code_sections.0 = 3

SORT down code_sections. a +8

DO i = 1 TO 4
 If exists("Code_sections.i") = 1 then
    SAY code_sections.i
 else
    Say 'Code_sections.'i 'does not exist'
END
Doug
Message5. Exactly Doug
#12495
Posted by: Michael S 2008-10-31 04:42:32
All you have to do is run the script and you fail on the first item. I'm 99.9999% certain this has worked before since I only discovered it today by accident in an old application that I know I've run many a time.
Message6. Bump
#12617
Posted by: Michael S 2009-01-06 03:09:09
Forum List • Thread List • Reply • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-3-29  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0