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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

When "XXX" read from excel and inserted, then pull up other code in sc

Status
Not open for further replies.

esoare

Programmer
Jun 15, 2005
199
US
ript.

Well, that Subject line was to long. :)

Hello all.

Trying to do the following.

If KEY2 = SCR 423 to be more specific (SCR, SCN, MCR, MCN)
then I would like it to run the
waitfor " CPND "
transmit "^M"
waitfor " VMB "
transmit "^M"
waitfor "KEY "
and then go back to the script were it left off.

now. there are potentially 75 keys. And these keys can have anything in them. Like TRN,AO6,ADL 16. Now those don't need the whole
waitfor " CPND "
transmit "^M"
waitfor " VMB "
transmit "^M"
waitfor "KEY "
but
"waitfor "KEY "
and the script should just continue on to the next key to input.

So the first thing is to read what is in the Excel box for that perticular "string" and based upon that (after it inputs it to the switch) it would run the IF ELSE command.

Now is there a way to have that programmed into a script once, were it calls those commands all the time, and then continues at the key # / Excel Column that it deviated from.

i/e, would then continue with Key3.

I could place the IF / ELSE after each "KEY" area. But I was thinking that there has to be an easier way.

I trust I explained my self well.

Thanks,
ES
 
Instead of a big if/else statement, I think you would find it easier to use a switch/case structure. You can have one case statement that applies to the first, longer set of steps you mentioned, and then a second case statement for the second group where only one command needs to be sent. Here's a quick untested example based on the script in the help file to give you a better idea:

Code:
proc main
   string sKey             ; String to check in switch case.

   switch sKey 3        
      case "SCR"                 
      case "SCN"
      case "MCR"
      case "MCN"
         waitfor "  CPND "
         transmit "^M"
         waitfor "  VMB "
         transmit "^M"
         waitfor "KEY "      
      endcase
      case ...
         waitfor "KEY "
      endcase
   endswitch
endproc

The case ... statement would be populated with the keys that used the shorter steps.

One thing I was not aware that switch could do is key off a subset to the string - the 3 at the end of the switch statement indicates to only look at the first three characters in the string.

 
knob,

Below is how I did the programming. It Doesn't work. (probably my fault). :)
Now, I looked at the help file for switch command, and it said that if a case was true, that it would only do lines that were under it. That is why I only placed "SCN" in there, for testing purposes.

So do I have it placed correctly? KEY11 is a string.

I am reading the info.

then case to see if it has SCN at the beginning.

IT DOES.

Then it should transmit key11
and do the waitfor and all that.

currently it goes on to KEY12

waitfor "KEY "
transmit KEY10
waitfor "KEY "
switch KEY11 3
case "SCN"
transmit KEY11
waitfor " CPND "
transmit "NEW ^M"
waitfor " NAME "
transmit key0name
waitfor " XPLN "
transmit "^M"
waitfor " DISPLAY_FMT "
transmit "^M"
waitfor " VMB "
transmit "^M"
waitfor "KEY "
endcase
endswitch
transmit KEY12
waitfor "KEY "
transmit KEY13
waitfor "KEY
 
Since you are both switching on and transmitting the value in KEY11, I take it you are doing this as just a way to test a small portion of the script?

Try adding a couple usermsg commands to track the flow of the script - one just after the case statement to see if the script entered that structure and a second after the endswitch command to let you know when the script has finished with the switch statement.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top