|
VBScript, integers into strings Anonymous |
15 year
|
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] |
15 year
|
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
SetVariable("Average"),Average
end if
SetVariable("Total"),Total
SetVariable("Run"),Run
Hope this helps program.robo
|
|
|
Anonymous |
15 year
|
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 |
15 year
|
Typo in you target_list = GetStrVariable("targer<.b>_list")
it should be target_list = GetStrVariable("target_list")
|
|