Lines, items, repeat loops, > not always what you think

David Burgun dburgun at dsl.pipex.com
Tue Oct 18 10:14:14 EDT 2005


Hi,

I found this ages ago and there was some discussion of the correct 
action that RunRev should take on this list. For instance:

In a List Field, the following:

aaaaaaaaaaa cr
bbbbbbbbb cr
ccccccccccc

Will return a number of lines count of 3 and you cannot select past line 3.

However, this:

aaaaaaaaaaa cr
bbbbbbbbb cr
ccccccccccc cr

Will also return a number of lines count of 3, BUT you can select 
line 4 with the mouse, which just returns an empty string.

The problem I reckon is in the term "delimiter", instead it should 
use a "terminator", that way a item would always "terminate" with a 
"delimiter". The problem seems to be in the consistant use of the 
term "delimiter", sometimes it's used as  an "initiator" and 
sometimes a "delimiter" but most of the time what is really wanted is 
a "terminator".

Just my .5 cents worth!

All the Best
Dave

>Cautionary note:  I have gone to a different method of controlling repeat
>loops now that I am working with database tables.
>
>(Please note the handlers I have included below to see this 'anomaly' in
>action.)
>
>In Xtalk, the number of lines or items depends on the delimiter AND if the
>last line/item has anything in it.   Due to this inconsistency, I am now
>using a function ... delimCount()+1  as follows
>
>put fld colorList into temp  --a list of 12 colors
>repeat with x = 1 to delimCount(temp,return) +1
>    answer  line x of temp - which will now do all 12 lines, even if the last
>one is empty
>end repeat
>  I am often looking for missing values in database tables, and if the last
>column of a row, or the last line of a column is blank, it will be skipped
>and my maintenance will be faulty.
>
>Anyone have a better solution?
>
>Jim Ault
>Las Vegas
>
>------------------ copy code and call procedure  'countAfterSort'
>
>on countAfterSort
>     --Example of the anomaly for items and lines
>     --all we are doing here is sorting the same container
>     --note the message box after handler completes
>
>     put "1,7,9,4,,,,6,2,5,8,3" into temp
>     put the number of items in temp & " items in > " & temp
>     sort items in temp
>     put  the number of items in temp & " items in > " & temp into ans
>     answer "Their are " & ans
>     put msg & return & ans
>     sort items in temp descending numeric
>     put  the number of items in temp & " items in > " & temp into ans
>     answer "Their are " & ans
>     put msg & return & ans
>     sort items in temp ascending numeric
>     put  the number of items in temp & " items in > " & temp into ans
>     answer "Their are " & ans
>     put msg & return & ans
>    
>     put "The string ALWAYS contained " & delimCount(temp,",") & \
>         " commas but not always that many items" into ans
>     answer ans
>     put msg & return & ans
>     answer "Read the message box"
>    
>end countAfterSort
>
>function delimCount strr, del
>     put 0 into hits
>     repeat with x = 1 to number of characters in strr
>         if char x of strr is del then add 1 to hits --found a delimiter
>     end repeat
>     return hits
>end delimCount
>--------------------------------------- end code
>_______________________________________________
>use-revolution mailing list
>use-revolution at lists.runrev.com
>Please visit this url to subscribe, unsubscribe and manage your 
>subscription preferences:
>http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the Use-livecode mailing list