Hi!
Well, I see no other way than a manual count, or use of custom function (UDF) to return a number of items in a single line. For example (did not tested, though you can get an idea):
prodecure CountCartons
lparameters pcCNums
local i, lnCount, j, jLen
local array achecks(999)
alines(aa,chrtran(pcCNums,",",chr(13)))
lnCount = 0
for i = 1 to alen(aa)
if '-' $ aa[i]
jLen = val(substr(aa[i],at('-',aa[i])+1))
for j = val(aa[i]) to jLen
if achecks[j]
else
lnCount = lnCount + 1
achecks[j] = .T.
endif
endfor
else
if achecks[val(aa[i])]
else
lnCount = lnCount + 1
achecks[val(aa[i])] = .T.
endif
endif
endfor
return lnCount
You can call above function from SELECT statement or from the COUNT command to return count :
SELECT SUM(CountCartons(MyTable.CTN_NOS))
HTH.
>count the Orditems.CTN_NOS question
>
>Real Packing list case can be:
>
>
>Sample Packing list:
>
>CTN_NOS ITEM DIMENSION
>001 CM-1234-T1-M 43x46x25cm.
>001 CM-1238-T1-M
>001 CM-1467-T1-M
>002-003 CM-1477-T1-M 27x25x26cm.
>004,008,012 CM-1677-T1-M 26x24x22cm.
>005-007,009-011 CM-1678-T1-M 26x25x22cm.
>013 CM-1688-G1-M 28x29x30cm.
>
>
>
>I need to calculate the correct Carton # with calculate the Final cbm of whole shipment.
>
>In above example, repeating 001 mean same carton, user only fill one time on pklength, pkwidth, pkwidth.
>Thus, the count would be 1 only if exist Volume.
>
>001 with DIMENSION give 1 as combine carton
>001 with NO dimension give 0 as counted already
>002-003 will be subtract the value and give 2 as count.
>004,008,010 will be individual count, i.e. 3 as count
>005-007,009-011 will also give 6 as result
>013 give 1 as count because it represent one carton# only
>
>How can I count it? currently using manual count will be very poor.
>
>Second, how can I check out it is already counted and prompt user error?
>
>001-010
>008-009 <~ it will be error, duplicate carton#
>
>Thanks. :)
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.comICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs
It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.