Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Splitting and Performing case

Status
Not open for further replies.

pblazeppd

MIS
Jun 27, 2001
16
US
Hi all,

I want to split a field and then translate the split codes into plain english. The field (INMOON_VIEW.Weapon_Used) can contain up to three elements separated by "/". I want to split and translate in one formula if possible. This is what I have picked up from previous postings. In the code below the case does not work. Any and all help is appreciated. I can do multiple formulas, but hope there is a quicker solution.

if ubound(split({INMOON_VIEW.Weapon_Used},"/")) >= 1 then
split({INMOON_VIEW.Weapon_Used},"/")[1]


case"AXE":"AXE / SAW"
case"BAT":"BAT / BOARD"
case"VEHIC":"VEHICLE"
case"BBGN":"PELLET / BB GUN"
case"BODY":"HANDS / FEET / OTHER"
case"BOMB":"BOMB / EXPLOSIVES"
case"BOTTL":"BOTTLE / BROKEN BOTTLE"
case"CHAN":"CHAIN"
case"CHEM":"CHEMICALS"
case"CLUB":"CLUB"
case"FLAM":"OPEN FLAME"
case"GAS":"GASOLINE / ACCELERANT"
case"GLAS":"GLASS OBJECT"
case"GUN":"UNKNOWN TYPE FIREARM"
case"GUNH":"HANDGUN"
case"GUNR":"RIFLE"
case"GUNS":"SHOTGUN"
case"KITUT":"KITCHEN UTENCILS"
case"KNIFE":"POCKET / FIXED BLADE KNIFE"
case"NUNCH":"NUNCHUKA STICKS"
case"OTH":"OTHER"
case"PIPE":"PIPE / TIRE IRON"
case"RAZR":"RAZOR"
case"ROCK":"ROCK / BRICK"
case"SACK":"SACK / BAG"
case"SIMU":"SIMULATED WEAPON"
case"TOOLS":"WRENCH / HAMMER / ETC."
case" ":"NOT ENTERED IN ARS"

Phil
 
Please post your software version, and explain what " In the code below the case does not work." means by posting error messages or if it returns bad results.

Try:

whileprintingrecords;
stringvar MyArray := split({INMOON_VIEW.Weapon_Used},"/");
select MyArray[1]
case "AXE":"AXE / SAW"
case"BAT":"BAT / BOARD"
case"VEHIC":"VEHICLE"
case"BBGN":"PELLET / BB GUN"
case"BODY":"HANDS / FEET / OTHER"
case"BOMB":"BOMB / EXPLOSIVES"
case"BOTTL":"BOTTLE / BROKEN BOTTLE"
case"CHAN":"CHAIN"
case"CHEM":"CHEMICALS"
case"CLUB":"CLUB"
case"FLAM":"OPEN FLAME"
case"GAS":"GASOLINE / ACCELERANT"
case"GLAS":"GLASS OBJECT"
case"GUN":"UNKNOWN TYPE FIREARM"
case"GUNH":"HANDGUN"
case"GUNR":"RIFLE"
case"GUNS":"SHOTGUN"
case"KITUT":"KITCHEN UTENCILS"
case"KNIFE":"POCKET / FIXED BLADE KNIFE"
case"NUNCH":"NUNCHUKA STICKS"
case"OTH":"OTHER"
case"PIPE":"PIPE / TIRE IRON"
case"RAZR":"RAZOR"
case"ROCK":"ROCK / BRICK"
case"SACK":"SACK / BAG"
case"SIMU":"SIMULATED WEAPON"
case"TOOLS":"WRENCH / HAMMER / ETC."
case" ":"NOT ENTERED IN ARS"
default "N/A";

-k
 
Hi all,

Trying to split and translate a 17 character string that contains codes separated by "/". The codes are 3 to 5 characters long. Working with CR9 with ODBC connection.

Tried:

whileprintingrecords;
stringvar MyArray := **split({INMOON_VIEW.Weapon_Used},"/");
** received error starting here. This array must be subscripted. For exmaple: Array**

select MyArray[1]
case "AXE":"AXE / SAW"
case"BAT":"BAT / BOARD"
case"VEHIC":"VEHICLE"
case"BBGN":"PELLET / BB GUN"
case"BODY":"HANDS / FEET / OTHER"
case"BOMB":"BOMB / EXPLOSIVES"
case"BOTTL":"BOTTLE / BROKEN BOTTLE"
case"CHAN":"CHAIN"
case"CHEM":"CHEMICALS"
case"CLUB":"CLUB"
case"FLAM":"OPEN FLAME"
case"GAS":"GASOLINE / ACCELERANT"
case"GLAS":"GLASS OBJECT"
case"GUN":"UNKNOWN TYPE FIREARM"
case"GUNH":"HANDGUN"
case"GUNR":"RIFLE"
case"GUNS":"SHOTGUN"
case"KITUT":"KITCHEN UTENCILS"
case"KNIFE":"POCKET / FIXED BLADE KNIFE"
case"NUNCH":"NUNCHUKA STICKS"
case"OTH":"OTHER"
case"PIPE":"PIPE / TIRE IRON"
case"RAZR":"RAZOR"
case"ROCK":"ROCK / BRICK"
case"SACK":"SACK / BAG"
case"SIMU":"SIMULATED WEAPON"
case"TOOLS":"WRENCH / HAMMER / ETC."
case" ":"NOT ENTERED IN ARS"
default "N/A";

Thanks for any help and explantion for the error.
 
It should be:

whileprintingrecords;
stringvar array MyArray := **split({INMOON_VIEW.Weapon_Used},"/");
//etc.

-LB
 
Right, it wasn't stated as an array, my apologies.

Try:

whileprintingrecords;
stringvar array MyArray := split({INMOON_VIEW.Weapon_Used},"/");
select MyArray[1]
case "AXE":"AXE / SAW"
case"BAT":"BAT / BOARD"
case"VEHIC":"VEHICLE"
case"BBGN":"PELLET / BB GUN"
case"BODY":"HANDS / FEET / OTHER"
case"BOMB":"BOMB / EXPLOSIVES"
case"BOTTL":"BOTTLE / BROKEN BOTTLE"
case"CHAN":"CHAIN"
case"CHEM":"CHEMICALS"
case"CLUB":"CLUB"
case"FLAM":"OPEN FLAME"
case"GAS":"GASOLINE / ACCELERANT"
case"GLAS":"GLASS OBJECT"
case"GUN":"UNKNOWN TYPE FIREARM"
case"GUNH":"HANDGUN"
case"GUNR":"RIFLE"
case"GUNS":"SHOTGUN"
case"KITUT":"KITCHEN UTENCILS"
case"KNIFE":"POCKET / FIXED BLADE KNIFE"
case"NUNCH":"NUNCHUKA STICKS"
case"OTH":"OTHER"
case"PIPE":"PIPE / TIRE IRON"
case"RAZR":"RAZOR"
case"ROCK":"ROCK / BRICK"
case"SACK":"SACK / BAG"
case"SIMU":"SIMULATED WEAPON"
case"TOOLS":"WRENCH / HAMMER / ETC."
case" ":"NOT ENTERED IN ARS"
default "N/A";

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top