www.ClassicTW.com
https://mail.black-squirrel.com/

SWATH Script Help Needed
https://mail.black-squirrel.com/viewtopic.php?f=15&t=26109
Page 1 of 1

Author:  HiTechRedneck [ Sat Jun 05, 2010 3:13 pm ]
Post subject:  SWATH Script Help Needed

Can anyone tell me what is wrong with this bit of code???

// start our main loop
for (loop = 1; loop < 10 ; loop++);
{
LaunchEtherProbe.exec(start);
start++;
if (start == Swath.main.currSector()) start++;
if (start > totsectors) {
PrintText.exec("\nMax sectors reached quitting!\n");
return true;
}
if ( maxcycles <= cycle ) {
PrintText.exec("\nMax cycles reached quitting!\n");
return true;
}
}

All of the initialization works correctly, values get passed, etc. But when I run the script, it launches 1 probe to the sector I tell it to start in, then the script just ends like it finished. I have tried setting the loop up with both "loop < 10" and "loop >10". No change.

I am trying to create a script that will probe all 20k sectors in the game I am playing in, starting at 1, and reloading on probes as needed. but if I can't get the basic loop to work, nothing else will either. Any help would be greatly appreciated.

Author:  Maniac [ Sat Jun 05, 2010 4:42 pm ]
Post subject:  Re: SWATH Script Help Needed

HiTechRedneck wrote:
Can anyone tell me what is wrong with this bit of code???

// start our main loop
for (loop = 1; loop < 10 ; loop++);
{
LaunchEtherProbe.exec(start);
start++;
if (start == Swath.main.currSector()) start++;
if (start > totsectors) {
PrintText.exec("\nMax sectors reached quitting!\n");
return true;
}
if ( maxcycles <= cycle ) {
PrintText.exec("\nMax cycles reached quitting!\n");
return true;
}
}

All of the initialization works correctly, values get passed, etc. But when I run the script, it launches 1 probe to the sector I tell it to start in, then the script just ends like it finished. I have tried setting the loop up with both "loop < 10" and "loop >10". No change.

I am trying to create a script that will probe all 20k sectors in the game I am playing in, starting at 1, and reloading on probes as needed. but if I can't get the basic loop to work, nothing else will either. Any help would be greatly appreciated.


Just some general help with scripting/programming....

When having problems.... Output the values of all the variables inside your loop....
such as maxcycles and cycles... this is important because the comparison might be causing your loop to abort.

I would also double check all initializations and if statements to make sure that they are what you
assume they would be.

What would happen for arguments sake... start is Greater than totsectors... your loop would
fire 1 probe and exec the PrintText routine and then return true....

<Edit>
After thinking about it some more... do you ever increment cycles?
I know it is just personal choice but I find it helps me to have the test variable come first...
i.e. if (cycles >= maxcycles) to me is more readable... but to each his/her own.


Do you get a message from the PrintText routine? Check both of them...

Author:  HiTechRedneck [ Sat Jun 05, 2010 5:55 pm ]
Post subject:  Re: SWATH Script Help Needed

Ok, I couldn't figure out how to print the values of the variables to the screen, so I tried something else. I reduced the loop part of the program to the following:

// start our main loop
for (loop = 1; loop < 10 ; loop++);
{
LaunchEtherProbe.exec(loop);
PrintText.exec("\nloop\n");

}

The script immediately launched a probe to sector 10, printed \nloop\n (with the \n instead of the CR I expected) and then exited. So it would appear that I have no idea how to do a classic FOR-NEXT loop in Java. Ideas? My understanding is that anything in the {} after the FOR command will execute in the loop, but it looks like the loop is running inside itself and then continuing on with the rest of the program.

Author:  HiTechRedneck [ Sat Jun 05, 2010 6:11 pm ]
Post subject:  Re: SWATH Script Help Needed

Never mind, I really AM a Java idiot...

for (loop = 1; loop < 10 ; loop++);
{
LaunchEtherProbe.exec(loop);
PrintText.exec("\nloop\n");
}

Should have been

for (loop = 1; loop < 10 ; loop++){

LaunchEtherProbe.exec(loop);
PrintText.exec("\nloop\n");
}

I used to program in different versions of BASIC (not VB, just plain good old fashioned B). This Java stuff is a royal PAIN!!!

Thank you for the advice though, that is what pointed me in the right direction.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/