How a Case Statment works in DS
Moderators: chulett, rschirm, roy
How a Case Statment works in DS
Im haveing some problems understanding how a case statment works in DS. If i have a HUGE case statemnt meaing I have case after case after case, when a record proves true does it stop processing that record were it proves true or does it continure on through the case statment and reassighn it, thus having the final anser = to the last part of the case statment that it was true for?
In a SQL server case statment once a record is proven true it stops processing that record at that point and goes to the next record. It seems that in DS it takes the row all the way through the case statment and thus reasighning the values. Is this true?
Jim
In a SQL server case statment once a record is proven true it stops processing that record at that point and goes to the next record. It seems that in DS it takes the row all the way through the case statment and thus reasighning the values. Is this true?
Jim
Sure I need help....But who dosent?
No.
The construct exits on the first @TRUE evaluation. So, a last CASE statement of @TRUE always evaluates to @TRUE.
Plus this logic into a function and play with it. It should demonstrate a CASE construct reasonably well.
Code: Select all
BEGIN CASE
CASE X=1
Ans = "A"
CASE X=2
Ans = "B"
CASE X=3
Ans = "C"
CASE X=4
Ans = "D"
CASE @TRUE
Ans = "X"
END CASE
Plus this logic into a function and play with it. It should demonstrate a CASE construct reasonably well.
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
I have very complicated case logic and its not evaluating like i would have thought.kcbland wrote:No.
The construct exits on the first @TRUE evaluation. So, a last CASE statement of @TRUE always evaluates to @TRUE.Code: Select all
BEGIN CASE CASE X=1 Ans = "A" CASE X=2 Ans = "B" CASE X=3 Ans = "C" CASE X=4 Ans = "D" CASE @TRUE Ans = "X" END CASE
Plus this logic into a function and play with it. It should demonstrate a CASE construct reasonably well.
Code: Select all
*Arg1 = Country
*Arg2 = Ultport
*Arg3 = Ultcode
*Arg4 = Sline
*Arg5 = Name
*Arg6 = Fname
*Arg7 = Uscode
Ans = 'NON-STD OTHER'
Begin Case
*(PACIFIC TRADE GENERAL):
Case (( Arg1 = '588' Or Arg1 ='570' Or Arg1 ='580' Or Arg1 ='582' Or Arg1 ='583' Or Arg1 ='560' Or Arg1 ='559' Or Arg1 ='549' Or Arg1 ='565' Or Arg1 ='557' Or Arg1 ='552' Or Arg1 ='538' Or Arg1 ='555' Or Arg1 ='579' Or Arg1 ='566' Or Arg1 ='546' Or Arg1 ='574' Or Arg1 ='561' Or Arg1 ='684' Or Arg1 ='553') AND NOT(Arg2 = 'MARSHAL ISL' OR Arg2 ='KWAJALEIN')) OR (Arg1 = 462 AND Arg2 ='ABAKAN' or Arg2 ='KHABAROVSK' or Arg2 ='KORSAKOV' or Arg2 ='MAGADAN' or Arg2 ='PETROPAVLOVSK' or Arg2 ='VLADIVOSTOK' or Arg2 ='VOSTOCHNY' or Arg2 ='YUZHNO SAKHAL' or Arg2 ='YUZHNO SAKHALINSK')
Ans = 'PACIFIC TOTAL'
*(WEST MED GENERAL TRADE):
case (Arg1 ='471' Or Arg1 ='735' Or Arg1 ='733' Or Arg1 ='469' Or Arg1 ='467' Or Arg1 ='759' Or Arg1 ='475') OR ( Arg1 = '427' AND Arg3 ='42776' or Arg3 ='42782') OR (Arg1 = '427' AND Arg3 ='42776' or Arg3 ='46905' or Arg3 ='46961' or Arg3 ='48945' or Arg3 ='46931' or Arg3 ='47527' or Arg3 ='50220' or Arg3 ='46994' or Arg3 ='27900' or Arg3 ='47500' or Arg3 ='47531' or Arg3 ='47300' or Arg3 ='47507' or Arg3 ='47537' or Arg3 ='47125' or Arg3 ='47500' or Arg3 ='46935' or Arg3 ='48939' or Arg3 ='50801' or Arg3 ='48452' or Arg3 ='42782') OR (Arg2 = 'MONACO')
Ans = 'MECL-WEST MED'
*(ATLANTIC TRADE GENERAL):
case (Arg1 ='101' or Arg1 ='400' or Arg1 ='401' or Arg1 ='403' or Arg1 ='405' or Arg1 ='409' or Arg1 ='412' or Arg1 ='416' or Arg1 ='419' or Arg1 ='421' or Arg1 ='423' or Arg1 ='425' or Arg1 ='428' or Arg1 ='429' or Arg1 ='433' or Arg1 ='435' or Arg1 ='437' or Arg1 ='441' or Arg1 ='447' or Arg1 ='449' or Arg1 ='451' or Arg1 ='455') OR (Arg1 = '427' AND NOT (Arg3 ='42776' or Arg3 ='46905' or Arg3 ='46961' or Arg3 ='48945' or Arg3 ='46931' or Arg3 ='47527' or Arg3 ='50220' or Arg3 ='46994' or Arg3 ='27900' or Arg3 ='47500' or Arg3 ='47531' or Arg3 ='47300' or Arg3 ='47507' or Arg3 ='47537' or Arg3 ='47125' or Arg3 ='47500' or Arg3 ='46935' or Arg3 ='48939' or Arg3 ='50801' or Arg3 ='48452' or Arg3 ='42782')) Or (Arg1 = '462' AND NOT (Arg2 ='ABAKAN' or Arg2 ='KHABAROVSK' or Arg2 ='KORSAKOV' or Arg2 ='MAGADAN' or Arg2 ='PETROPAVLOVSK' or Arg2 ='VLADIVOSTOK' or Arg2 ='VOSTOCHNY' or Arg2 ='YUZHNO SAKHAL' or Arg2 ='YUZHNO SAKHALINSK' or Arg2 ='ARMENIA' or Arg2 ='YEREVAN' or Arg2 ='AZERBAIJAN' or Arg2 ='BAKU' or Arg2 ='TIMASEVSK' or Arg2 ='STAVROPOL' or Arg2 ='KRASNODAR' or Arg2 ='NOVOROSSIYSK' or Arg2 ='KRIVOJ ROG' or Arg2 ='YALTA' or Arg2 ='SIMFEROPOL' or Arg2 ='CHERKASSY' or Arg2 ='ODESSA' or Arg2 ='DNEPROPETROVS' or Arg2 ='ZHDANOV' or Arg2 ='DONECK' or Arg2 ='BORISPOL' or Arg2 ='KIEV' or Arg2 ='ILLYICHEVSK' or Arg2 ='ILICHEVSK' or Arg2 ='KREMENCHUG' or Arg2 ='ALMA ATA' or Arg2 ='ALMATY' or Arg2 ='KZYLORDA' or Arg2 ='KAZAKHSTAN' or Arg2 ='BISHKEK' or Arg2 ='OSH' or Arg2 ='KYRGYZSTAN' or Arg2 ='KULYAB' or Arg2 ='DUSANBE' or Arg2 ='TAJIKISTAN' or Arg2 ='DUSHANBE' or Arg2 ='TADZHIKISTAN' or Arg2 ='TURKMENISTAN' or Arg2 ='UZBEKISTAN' or Arg2 ='TIRASPOL' or Arg2 ='MOLDOVA'))
Ans = 'TRANS-ATLANTIC TOTAL'
*(OTHER MED GENERAL TRADE):
case (Arg1 ='508' or Arg1 ='489' or Arg1 ='729' or Arg1 ='484' or Arg1 ='504' or Arg1 ='479' or Arg1 ='714' or Arg1 ='491' or Arg1 ='485' or Arg1 ='463' or Arg1 ='721' or Arg1 ='723' or Arg1 ='487' or Arg1 ='481' or Arg1 ='472' or Arg1 ='502' or Arg1 ='725' or Arg1 ='473' or Arg1 ='737') OR (Arg1 = '462' AND (Arg2='ARMENIA'or Arg2 ='YEREVAN')) OR (Arg1 = '462' AND (Arg2 ='AZERBAIJAN' or Arg2 ='BAKU')) OR ((Arg1='462'or Arg1='485') AND (Arg2 ='TIRASPOL' or Arg2 ='MOLDOVA')) OR (Arg1 = '462' AND (Arg2 ='TIMASEVSK' or Arg2 ='STAVROPOL' or Arg2 ='KRASNODAR' or Arg2 ='NOVOROSSIYSK')) OR (Arg1 = '462' AND (Arg2 ='KRIVOJ ROG' or Arg2 ='YALTA' or Arg2 ='SIMFEROPOL' or Arg2 ='CHERKASSY' or Arg2 ='DNEPROPETROVS' or Arg2 ='ZHDANOV' or Arg2 ='DONECK' or Arg2 ='BORISPOL' or Arg2 ='KIEV' or Arg2 ='ILLYICHEVSK' or Arg2 ='ILICHEVSK' or Arg2 ='ODESSA' or Arg2 ='KREMENCHUG'))
Ans = 'MECL-OTHER MED'
case (Arg1 ='533' or Arg1 ='517' or Arg1 ='520' or Arg1 ='535' or Arg1 ='513' or Arg1 ='511' or Arg1 ='525' or Arg1 ='523' or Arg1 ='518' or Arg1 ='542' or Arg1 ='521' or Arg1 ='507' or Arg1 ='505' or Arg1 ='568' or Arg1 ='777' or Arg1 ='732' or Arg1 ='531' or Arg1 ='536' or Arg1 ='774') OR (Arg1 = '462' AND (Arg2 ='ALMA ATA' or Arg2 ='KZYL ORDA' or Arg2 ='KAZAKHSTAN' or Arg2 ='ALMATY' or Arg2 ='BISHKEK' or Arg2 ='OSH' or Arg2 ='KYRGYZSTAN' or Arg2 ='KULYAB' or Arg2 ='DUSANBE' or Arg2 ='TAJIKISTAN' or Arg2 ='DUSHANBE' or Arg2 ='TADZHIKISTAN' or Arg2 ='TURKMENISTAN' or Arg2 ='UZBEKISTAN'))
Ans = 'MECL-MEIP60'
Case (Arg4 = 'DFFC' and (Arg5 ='DOLE PURCHASING' or Arg5 ='DOLE FRESH FRUIT' or Arg5 ='DOLE FRESH FRUIT INTL LTD' or Arg5 ='DOLE OCEAN LINER' or Arg5 ='PRODUCTORA CARTONERA' or Arg5 ='STANDARD FRUIT STEAMS HI' or Arg5 ='STANDARD FRUITSTEAMSHI' or Arg5 ='STANDARD FRUIT STEAMSHI' or Arg5 ='STANDARD FRUIT & STEAMSHI')) OR (Arg6 ='DOLE PURCHASING')
Ans = 'DOLE'
Case (Arg4 = 'GWFL' and (Arg5 ='CHIQUITA BRANDS' or Arg5 ='CHIQUITA UNIFRUTTI JAPAN' or Arg5 ='CHIQUITA ITALIA S P A' or Arg5 ='CHIQUITA ITALIA SPA' or Arg5 ='MARITROP TRDG')) or (Arg6 ='CHIQUITA BRANDS')
Ans = 'CHIQUITA'
Case (Arg4 = 'SOLY' and Arg5 = 'SOLTECH') or (Arg6 = 'PARADISE FARMS')
Ans = 'SOLTECH'
Case (Arg4 = 'NETS' and (Arg5 = 'DEL MONTE'))
Ans = 'DEL MONTE'
Case (Arg4 = 'ECUA' and (Arg5 = 'PACIFIC FRUIT'))
Ans = 'PACIFIC FRUIT'
Case (Arg1 = '232' or Arg1 = '236' or Arg1 = '239' or Arg1 = '241' or Arg1 = '243' or Arg1 = '244' or Arg1 = '245' or Arg1 = '247' or Arg1 = '248' or Arg1 = '272' or Arg1 = '274' or Arg1 = '277' or Arg1 = '283' or Arg1 = '307' or Arg1 = '312' or Arg1 = '315' or Arg1 = '317' or Arg1 = '911') and not (Arg7 ='4904' or Arg7 ='4907' or Arg7 ='4908' or Arg7 ='4909' or Arg7 ='4911' or Arg7 ='4912')
Ans = 'AMR-CARIB'
Case (Arg1 ='301' or Arg1 ='331' or Arg1 ='333' or Arg1 ='335' or Arg1 ='337') and not (Arg7 ='4904' or Arg7 = '4907' or Arg7 = '4908' or Arg7 = '4909' or Arg7 = '4911' or Arg7 = '4912')
Ans = 'AMR-WCSA'
case (Arg1 ='351' or Arg1 = '353' or Arg1 = '355' or Arg1 = '357') and not(Arg7 ='4904' or Arg7 = '4907' or Arg7 = '4908' or Arg7 = '4909' or Arg7 = '4911' or Arg7 = '4912')
Ans = 'AMR-ECSA'
Case (Arg1 ='201' or Arg1 ='205' or Arg1 ='208' or Arg1 ='211' or Arg1 ='215' or Arg1 ='219' or Arg1 ='223' or Arg1 ='225') and not (Arg7 ='4904' or Arg7 ='4907' or Arg7 ='4908' or Arg7 ='4909' or Arg7 ='4911' or Arg7 ='4912')
Ans = 'AMR-CAMR'
Case (Arg1 ='738' or Arg1 ='741' or Arg1 ='742' or Arg1 ='744' or Arg1 ='745' or Arg1 ='746' or Arg1 ='747' or Arg1 ='748' or Arg1 ='749' or Arg1 ='750' or Arg1 ='751' or Arg1 ='752' or Arg1 ='753' or Arg1 ='754' or Arg1 ='755' or Arg1 ='756' or Arg1 ='758' or Arg1 ='760' or Arg1 ='761' or Arg1 ='762' or Arg1 ='764' or Arg1 ='763' or Arg1 ='765' or Arg1 ='766')
Ans = 'AFR-WEST AFRICA'
Case (Arg1 ='780' or Arg1 ='785' or Arg1 ='787' or Arg1 ='788' or Arg1 ='789' or Arg1 ='791' or Arg1 ='792' or Arg1 ='793' or Arg1 ='794' or Arg1 ='795' or Arg1 ='796' or Arg1 ='797' or Arg1 ='799') OR ( Arg1 = '790' and Arg2 = 'REUNION')
Ans = 'AFR-SOUTH AFRICA'
Case (Arg1 ='767' or Arg1 ='769' or Arg1 ='778' or Arg1 ='779' or Arg1 ='783' or Arg1 ='790') AND NOT (Arg2 = 'REUNION')
Ans = 'AFR-EAST AFRICA'
Case (Arg1 ='602' or Arg1 ='604' or Arg1 ='614' or Arg1 ='615' or Arg1 ='622' or Arg1 ='641' or Arg1 ='686' or Arg1 ='951') OR (Arg1 = '684' AND (Arg2 ='MARSHAL ISL' or Arg2 ='KWAJALEIN'))
Ans = 'OCEANIA TOTAL'
Case (Arg1 ='201' or Arg1 ='205' or Arg1 ='208' or Arg1 ='211' or Arg1 ='215' or Arg1 ='219' or Arg1 ='223' or Arg1 ='225')
Ans = 'NON-STD CENTRAL AMERICA'
Case (Arg1 ='232' or Arg1 ='236' or Arg1 ='241' or Arg1 ='245' or Arg1 ='247' or Arg1 ='248' or Arg1 ='272' or Arg1 ='274' or Arg1 ='277' or Arg1 ='283' or Arg1 ='307' or Arg1 ='312' or Arg1 ='315' or Arg1 ='317')
Ans = 'NON-STD CARIBBEAN'
Case (Arg1 ='301' or Arg1 ='331' or Arg1 ='333' or Arg1 ='335' or Arg1 ='337')
Ans = 'NON-STD W. COAST S. AMERICA'
Case (Arg1 ='351' or Arg1 ='353' or Arg1 ='355' or Arg1 ='357')
Ans = 'NON-STD E. COAST S. AMERICA'
Case (Arg1 ='461' or Arg1 ='462' or Arg1 ='463' or Arg1 ='467' or Arg1 ='469' or Arg1 ='471' or Arg1 ='472' or Arg1 ='473' or Arg1 ='475' or Arg1 ='479' or Arg1 ='481' or Arg1 ='484' or Arg1 ='485' or Arg1 ='487' or Arg1 ='489' or Arg1 ='491' or Arg1 ='504' or Arg1 ='508' or Arg1 ='714' or Arg1 ='721' or Arg1 ='723' or Arg1 ='729' or Arg1 ='733')
Ans = 'NON-STD MED'
Case (Arg1 ='533' or Arg1 ='535' or Arg1 ='538' or Arg1 ='542')
Ans = 'NON-STD ISC'
Case (Arg1 ='511' or Arg1='513' or Arg1='517' or Arg1='518' or Arg1='520' or Arg1='521' or Arg1='523' or Arg1='525')
Ans = 'NON-STD MIDEAST'
Case (Arg1 ='546' or Arg1='549' or Arg1='552' or Arg1='555' or Arg1='557' or Arg1='559' or Arg1='560' or Arg1='561' or Arg1='565' or Arg1='568')
Ans = 'NON-STD SOUTH ASIA'
Case (Arg1 ='566' or Arg1 ='570' or Arg1 ='574' or Arg1 ='580' or Arg1 ='582' or Arg1 ='583' or Arg1 ='588')
Ans = 'NON-STD EAST ASIA'
Case (Arg1 ='015' or Arg1 ='018' or Arg1 ='101' or Arg1 ='122' or Arg1 ='015' or Arg1 ='016' or Arg1 ='017' or Arg1 ='018' or Arg1 ='025' or Arg1 ='026' or Arg1 ='035' or Arg1 ='055' or Arg1 ='065' or Arg1 ='066' or Arg1 ='067' or Arg1 ='085' or Arg1 ='090' or Arg1 ='096' or Arg1 ='124' or Arg1 ='134' or Arg1 ='138' or Arg1 ='140' or Arg1 ='144' or Arg1 ='152' or Arg1 ='243' or Arg1 ='244' or Arg1 ='502' or Arg1 ='507' or Arg1 ='531' or Arg1 ='536' or Arg1 ='579' or Arg1 ='604' or Arg1 ='614' or Arg1 ='615' or Arg1 ='622' or Arg1 ='641' or Arg1 ='684' or Arg1 ='686' or Arg1 ='735' or Arg1 ='759' or Arg1 ='760' or Arg1 ='764' or Arg1 ='770' or Arg1 ='777' or Arg1 ='790' or Arg1 ='911' or Arg1 ='935' or Arg1 ='951' or Arg1 ='999')
Ans = 'NON-STD OTHER'
End Case
Jim
Sure I need help....But who dosent?
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
When a CASE construct is compiled it generates exactly the same code as the equivalent nested IF construct. I expect, therefore, if your conversion is exact, that you will still get the same result. And, thus, will need to re-examine your actual logic.
Only the first CASE in a CASE construct for which the expression is true has its corresponding statements executed. Control then passes to the next executable statement following END CASE. What happens after that is in your (the programmer's) hands. If you want to transfer control to the next record immediately, why not put a CONTINUE statement to transfer control to the next iteration of the loop?
Only the first CASE in a CASE construct for which the expression is true has its corresponding statements executed. Control then passes to the next executable statement following END CASE. What happens after that is in your (the programmer's) hands. If you want to transfer control to the next record immediately, why not put a CONTINUE statement to transfer control to the next iteration of the loop?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
You are correct about the case statment vs the if then statment. I have just tested and confirmed that (sorry I had to learn myself)ray.wurlod wrote:When a CASE construct is compiled it generates exactly the same code as the equivalent nested IF construct. I expect, therefore, if your conversion is exact, that you will still get the same result. And, thus, will need to re-examine your actual logic.
Only the first CASE in a CASE construct for which the expression is true has its corresponding statements executed. Control then passes to the next executable statement following END CASE. What happens after that is in your (the programmer's) hands. If you want to transfer control to the next record immediately, why not put a CONTINUE statement to transfer control to the next iteration of the loop?
You are saying that in a case statment once the record evaluates true its done with it and moves on to the next record...Correct?
If so then because im not getting what I need in this logic then there is a problem witht the logic. Is the order that I put the case statments importatn. Should it be more restrictive progressivly down to less restrictive?
Jim
Sure I need help....But who dosent?
-
- Participant
- Posts: 145
- Joined: Fri May 02, 2003 9:59 am
- Location: Seattle, Washington. USA
im in the middle of a brain melt down. Im gona need you to explane that a bit more. why will that show me a problem?shawn_ramsey wrote:If you change your code a bit it would be easy to test if your theory is correct. Just change the Ans = 'String' to Ans = Ans : 'String'. Look at the result and see if you have concatenation of the strings. If you do then your theory is correct if not then you have some debugging to do.
Shawn
Jim
Sure I need help....But who dosent?
-
- Participant
- Posts: 145
- Joined: Fri May 02, 2003 9:59 am
- Location: Seattle, Washington. USA
Add this:
*(PACIFIC TRADE GENERAL):
Case (( Arg1 = '588' Or Arg1 ='570' Or Arg1 ='580' Or Arg1 ='582' Or Arg1 ='583' Or Arg1 ='560' Or Arg1 ='559' Or Arg1 ='549' Or Arg1 ='565' Or Arg1 ='557' Or Arg1 ='552' Or Arg1 ='538' Or Arg1 ='555' Or Arg1 ='579' Or Arg1 ='566' Or Arg1 ='546' Or Arg1 ='574' Or Arg1 ='561' Or Arg1 ='684' Or Arg1 ='553') AND NOT(Arg2 = 'MARSHAL ISL' OR Arg2 ='KWAJALEIN')) OR (Arg1 = 462 AND Arg2 ='ABAKAN' or Arg2 ='KHABAROVSK' or Arg2 ='KORSAKOV' or Arg2 ='MAGADAN' or Arg2 ='PETROPAVLOVSK' or Arg2 ='VLADIVOSTOK' or Arg2 ='VOSTOCHNY' or Arg2 ='YUZHNO SAKHAL' or Arg2 ='YUZHNO SAKHALINSK')
Ans = Ans : 'PACIFIC TOTAL'
*(PACIFIC TRADE GENERAL):
Case (( Arg1 = '588' Or Arg1 ='570' Or Arg1 ='580' Or Arg1 ='582' Or Arg1 ='583' Or Arg1 ='560' Or Arg1 ='559' Or Arg1 ='549' Or Arg1 ='565' Or Arg1 ='557' Or Arg1 ='552' Or Arg1 ='538' Or Arg1 ='555' Or Arg1 ='579' Or Arg1 ='566' Or Arg1 ='546' Or Arg1 ='574' Or Arg1 ='561' Or Arg1 ='684' Or Arg1 ='553') AND NOT(Arg2 = 'MARSHAL ISL' OR Arg2 ='KWAJALEIN')) OR (Arg1 = 462 AND Arg2 ='ABAKAN' or Arg2 ='KHABAROVSK' or Arg2 ='KORSAKOV' or Arg2 ='MAGADAN' or Arg2 ='PETROPAVLOVSK' or Arg2 ='VLADIVOSTOK' or Arg2 ='VOSTOCHNY' or Arg2 ='YUZHNO SAKHAL' or Arg2 ='YUZHNO SAKHALINSK')
Ans = Ans : 'PACIFIC TOTAL'
Shawn Ramsey
"It is a mistake to think you can solve any major problems just with potatoes."
-- Douglas Adams
"It is a mistake to think you can solve any major problems just with potatoes."
-- Douglas Adams
I need to know what this will tell me. can you expane that?shawn_ramsey wrote:Add this:
*(PACIFIC TRADE GENERAL):
Case (( Arg1 = '588' Or Arg1 ='570' Or Arg1 ='580' Or Arg1 ='582' Or Arg1 ='583' Or Arg1 ='560' Or Arg1 ='559' Or Arg1 ='549' Or Arg1 ='565' Or Arg1 ='557' Or Arg1 ='552' Or Arg1 ='538' Or Arg1 ='555' Or Arg1 ='579' Or Arg1 ='566' Or Arg1 ='546' Or Arg1 ='574' Or Arg1 ='561' Or Arg1 ='684' Or Arg1 ='553') AND NOT(Arg2 = 'MARSHAL ISL' OR Arg2 ='KWAJALEIN')) OR (Arg1 = 462 AND Arg2 ='ABAKAN' or Arg2 ='KHABAROVSK' or Arg2 ='KORSAKOV' or Arg2 ='MAGADAN' or Arg2 ='PETROPAVLOVSK' or Arg2 ='VLADIVOSTOK' or Arg2 ='VOSTOCHNY' or Arg2 ='YUZHNO SAKHAL' or Arg2 ='YUZHNO SAKHALINSK')
Ans = Ans : 'PACIFIC TOTAL'
Jim
Sure I need help....But who dosent?
CASE statements are top-down. The first to evaluate to @TRUE exits the construct. So, put them in priority order.
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
-
- Participant
- Posts: 145
- Joined: Fri May 02, 2003 9:59 am
- Location: Seattle, Washington. USA
I agree, case statements are top down. :D If they were not, modifying the script in this manner would result in a concatinated string of all the cases that evaluated to true.kcbland wrote:CASE statements are top-down. The first to evaluate to @TRUE exits the construct. So, put them in priority order.
![Shocked :shock:](./images/smilies/icon_eek.gif)
Shawn Ramsey
"It is a mistake to think you can solve any major problems just with potatoes."
-- Douglas Adams
"It is a mistake to think you can solve any major problems just with potatoes."
-- Douglas Adams
Ohh I seeshawn_ramsey wrote:I agree, case statements are top down. :D If they were not, modifying the script in this manner would result in a concatinated string of all the cases that evaluated to true.kcbland wrote:CASE statements are top-down. The first to evaluate to @TRUE exits the construct. So, put them in priority order.
Im rerunning now after I have changed the order of some of the test statments. I guess from what you guys have said its just gona be trial and error.
Jim
Sure I need help....But who dosent?
-
- Participant
- Posts: 145
- Joined: Fri May 02, 2003 9:59 am
- Location: Seattle, Washington. USA
I am not sure about Trial and Error. You just need to make sure that the case evaluates in a manner where the most specific evaluation is first then through the other cases. In other words if multiple cases evaluate to true for a specific condition make sure that the correct one comes first in the case.
If you are not sure what is going on you could always bust the code up into a bunch of individual if statements and use the concatenation technique I described to see what ones are evaluating to true for you problem test rows.
This would result in a concatenated string of all the cases that meet the input criteria. You can then move these around in the code until the concatenated string has the correct result in front of the string. Once that is done then reconstruct your case statement in tat order.
If you are not sure what is going on you could always bust the code up into a bunch of individual if statements and use the concatenation technique I described to see what ones are evaluating to true for you problem test rows.
Code: Select all
If (( Arg1 = '588' Or Arg1 ='570' Or Arg1 ='580' Or Arg1 ='582' Or Arg1 ='583' Or Arg1 ='560' Or Arg1 ='559' Or Arg1 ='549' Or Arg1 ='565' Or Arg1 ='557' Or Arg1 ='552' Or Arg1 ='538' Or Arg1 ='555' Or Arg1 ='579' Or Arg1 ='566' Or Arg1 ='546' Or Arg1 ='574' Or Arg1 ='561' Or Arg1 ='684' Or Arg1 ='553') AND NOT(Arg2 = 'MARSHAL ISL' OR Arg2 ='KWAJALEIN')) OR (Arg1 = 462 AND Arg2 ='ABAKAN' or Arg2 ='KHABAROVSK' or Arg2 ='KORSAKOV' or Arg2 ='MAGADAN' or Arg2 ='PETROPAVLOVSK' or Arg2 ='VLADIVOSTOK' or Arg2 ='VOSTOCHNY' or Arg2 ='YUZHNO SAKHAL' or Arg2 ='YUZHNO SAKHALINSK')
Then
Ans = Ans : 'PACIFIC TOTAL'
End
If (Arg1 ='471' Or Arg1 ='735' Or Arg1 ='733' Or Arg1 ='469' Or Arg1 ='467' Or Arg1 ='759' Or Arg1 ='475') OR ( Arg1 = '427' AND Arg3 ='42776' or Arg3 ='42782') OR (Arg1 = '427' AND Arg3 ='42776' or Arg3 ='46905' or Arg3 ='46961' or Arg3 ='48945' or Arg3 ='46931' or Arg3 ='47527' or Arg3 ='50220' or Arg3 ='46994' or Arg3 ='27900' or Arg3 ='47500' or Arg3 ='47531' or Arg3 ='47300' or Arg3 ='47507' or Arg3 ='47537' or Arg3 ='47125' or Arg3 ='47500' or Arg3 ='46935' or Arg3 ='48939' or Arg3 ='50801' or Arg3 ='48452' or Arg3 ='42782') OR (Arg2 = 'MONACO')
Then
Ans = Ans : 'MECL-WEST MED'
End
.
.
.
Shawn Ramsey
"It is a mistake to think you can solve any major problems just with potatoes."
-- Douglas Adams
"It is a mistake to think you can solve any major problems just with potatoes."
-- Douglas Adams