WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

AskItemList and Switch Statement

Keywords: askitemlist	 

Here's a script to select items from AskItemList, set a number to the item, and use the switch statement for decision making.

;;set the variables

tab=num2char(9)
var1=0
var2=0
var3=0
var4=0

start=1
;;create the list, put (hypen number) -# in front of item.

list=strcat("-1  Red",tab,"-2  Blue",tab,"-3  Yellow",tab,"-4  Green")
A=AskItemList("Colors", list, tab, @sorted, @multiple)

;Pause("items selected are", A)	 ;;add for debugging, what was selected?

count=ItemCount(a, tab)	 ;; count the items selected in order to loop thru and
		       
;Pause("number of items", count) ;;add for debugging

;; collect the numbers.
pos=1
while start < count	;;set loop.  While less than the count...
     pos=Strscan(a, "-", pos, @fwdscan)	 ;; search for hyphen position
     pos=pos+1		;;add one to the position to find the numbers position.
     danum=StrSub(a, pos, 1)	 ;;extract the number.
     Switch danum	    ;;use switch to reset danum to a seperate variable.
	  case 1
	       ;Message("the code ", danum)  ;;add for debugging
	       var1=danum
	       break
	  case 2
	       ;Message("the code ", danum) ;;add for debugging
	       var2=danum
	       break
	  case 3
	       ;Message("the code ", danum)   ;;add for debugging
	       var3=danum
	       break
	  case 4
	       ;Message("the code ", danum)    ;;add for debugging
	       var4=danum
	       break
     endswitch	     
     start=start+1  ;;add one to the start to increment thru the loop.
endwhile

;;decision making example 
If (var1 ==1) && (var4 == 4) then Message(", "looks like this will work")


Article ID:   W13041
Filename:   AskItemList and Switch Statement.txt
File Created: 1999:04:15:16:51:22
Last Updated: 1999:04:15:16:51:22