VBScript, integers into strings
10 years
Assuming this to be a VBScript question, but I cannot seem to find the solution on the net.

Is there a way of adding an integer to the end of the string? Then, I can add another integer to that same string and build up a few values before processing them. e.g. accumulating a few COG_Xs prior to averaging them.
Anonymous from United Kingdom  [99 posts] 10 years
I guess I am not answering your question directly, but here is some vbscript that calcuates the average of 10 cog_x values and stores them in the variable average.

Total = GetVariable("Total")
cog_x = GetVariable("COG_X")
Run = GetVariable("Run")

Run = Run + 1
Total = Total + cog_x
if Run > 9 then
  Average = int(Total / Run)
  Run = 0
  Total = 0
end if


Hope this helps
Anonymous 10 years
Thanks for the averaging suggestion. I think that I mostly figured out the problem of adding integers to the end of a string.

x_position = GetVariable("MOUSE_CLICK_X")
y_position = GetVariable("MOUSE_CLICK_Y")
target_list = GetStrVariable("targer_list")

target_list = target_list & "," & x_position & "," & y_position

SetVariable"target", target
SetVariable"target_list", target_list

Now, a problem occurs. It is supposed to add another pair of numbers to the string next time it loops through the pipeline, but it does not. Instead of adding the numbers to the end of the string, it starts from an empty string, overwriting the previous string contents.

Can anyone figure it out?
Anonymous 10 years
Typo in you target_list = GetStrVariable("targer<.b>_list")

it should be target_list = GetStrVariable("target_list")

This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index