Using Lists

I am trying to create a variable list from a file, the following variable is giving me an error I do not understand:

Selection Failed in 0:0:00 STObjectNot aContainer Attemp to change the value of an object that is not a container.

tc_1 (works)
“tcpreplay -i eth0 --timer=gtod -K -q FTP_Target_ED.cap” (error message above)
tcpreplay -i eth0 --timer=gtod -K -q FTP_Target_ED.cap (error message above)
1312 (works)

What I have done is create a text file with variables in it. I read the file, split it into line, and then split the line, and assign the strings to a variable.

Thanks,
Mark

This is probably a usage issue – it would be helpful to see the code that you are using to read and parse the file. It’s unclear from your post exactly what you are doing that causes the error.

// open file “/Users/testMac/Documents/OmniPeek_SUT.suite/tcpreplay_list.txt” for reading
if there is a file “/Users/testMac/Documents/OmniPeek_SUT.suite/tcpreplay_list.txt” then
put file “/Users/testMac/Documents/OmniPeek_SUT.suite/tcpreplay_list.txt” as a list into replay_list
put replay_list
put split(replay_list, return) into splitlist
put the number of list items in replay_list into count
put count
else
put “File not found!”
end if

// start test loop

put item 1 of splitlist into linelist
put split(linelist, “,”) into testvar
put item 1 of testvar into testcase
put item 2 of testvar into filter
put item 3 of testvar into target (if I comment this line - no error)
put item 4 of testvar into background (if I comment this line - no error)
put item 5 of testvar into result

put testcase
put filter
put target
put background
put result

Thanks. 2 problems:

  1. You start by converting your file contents to a list. Then you do a split on that list, which treats it as a string and you end up with a single list element that starts with a “(”. If you just remove the “as a list” from the second line, almost everything else works.

  2. I say almost everything works because you’ve used one of the dozen or so reserved words as a variable: “target”. “target” can never be used as a variable – see Appendix A of the SenseTalk Reference.

If you haven’t already done so, you might try using the debugger controls on the Run window. You can set a breakpoint in the script by clicking in the narrow left-hand column of either the Script Editor or the Run window and then step through the script. Use the text field at the bottom of the Run window (known as the Ad-Hoc Do Box, or AHDB) to query your variables. I ran a number of “put” commands in the AHDB to see exactly what the contents of each of your variables is at various points during the execution of the script, which pointed me toward the problem.