What's new

If else Java help!

  • Thread starter iTzTECHKiNG
  • Start date
  • Views 905
I

iTzTECHKiNG

Enthusiast
Messages
816
Reaction score
49
So I'm trying to add an "if/else" conditional statement in my .js file in imacros.
What I'm trying to accomplish is if it finds the word "In Battle!" anywhere on the page to run a certain macro.

This is what I have now,

Code:
iimPlay("CODE:TAB T=1\nURL GOTO=InsertLinkhere\nTAG POS=1 TYPE=A ATTR=TXT:In<SP>battle!* EXTRACT=TXT");
var G_Extract=iimGetLastExtract(1);
if (G_Extract=="In<SP>Battle!*")
{
iimPlay ("Battle.iim")
}
else
  {
  iimPlay ("Continue.iim")
  }

Any help would be appreciated!
If you got questions or need me to further explain, Let me know!
 
Z

Z61

Some times our saints are sinners
Retired
Messages
5,476
Reaction score
3,426
This is javascript. Not Java.
Anyways, I see no issue, though I'm not familiar with the custom functions.
If it's just a retrieval function, you should use string.indexOf
 
I

iTzTECHKiNG

Enthusiast
Messages
816
Reaction score
49
This is javascript. Not Java.
Anyways, I see no issue, though I'm not familiar with the custom functions.
If it's just a retrieval function, you should use string.indexOf

Where would that go? Sorry, I have no knowledge of javascript or any type of scripting language to be honest.
 
Z

Z61

Some times our saints are sinners
Retired
Messages
5,476
Reaction score
3,426
Where would that go? Sorry, I have no knowledge of javascript or any type of scripting language to be honest.

http://www.w3schools.com/jsref/jsref_indexof.asp
I hate to link w3schools, but it's a decent reference for javascript.
An example of testing if the string was present this way would be:
Code:
if (G_Extract.indexOf("In<SP>Battle!*") != -1)
{
iimPlay ("Battle.iim")
}
else
  {
  iimPlay ("Continue.iim")
  }
 
I

iTzTECHKiNG

Enthusiast
Messages
816
Reaction score
49
http://www.w3schools.com/jsref/jsref_indexof.asp
I hate to link w3schools, but it's a decent reference for javascript.
An example of testing if the string was present this way would be:
Code:
if (G_Extract.indexOf("In<SP>Battle!*") != -1)
{
iimPlay ("Battle.iim")
}
else
  {
  iimPlay ("Continue.iim")
  }

Code:
iimPlay("CODE:TAB T=1\nURL GOTO=www.theninja-rpg.com\nTAG POS=1 TYPE=A ATTR=TXT:In<SP>battle!* EXTRACT=TXT");
var G_Extract=iimGetLastExtract(1);
if (G_Extract.indexOf("In<SP>Battle!*") != -1)
{
iimPlay ("Battle.iim")
}
else
  {
  iimPlay ("Continue.iim")
  }

That's what I end up using but it's not picking up "In Battle!" on the screen. It sees it but doesn't. if that makes any sense.
 
I

iTzTECHKiNG

Enthusiast
Messages
816
Reaction score
49
http://www.w3schools.com/jsref/jsref_indexof.asp
I hate to link w3schools, but it's a decent reference for javascript.
An example of testing if the string was present this way would be:
Code:
if (G_Extract.indexOf("In<SP>Battle!*") != -1)
{
iimPlay ("Battle.iim")
}
else
  {
  iimPlay ("Continue.iim")
  }

What if I want it to look for a link? and If the link is on the page to run the Battle.iim file but if its not then run Continue.iim?
 
Z

Z61

Some times our saints are sinners
Retired
Messages
5,476
Reaction score
3,426
What if I want it to look for a link? and If the link is on the page to run the Battle.iim file but if its not then run Continue.iim?
Just do the same time? But substitute the string in the test for what you want.
 
U

uid0

Programming Guru
Messages
436
Reaction score
74
Argh I hate when people call javascript java.
 
T

thetechnation

gaming developer
Messages
1,418
Reaction score
144
Code:
iimPlay("CODE:TAB T=1\nURL GOTO=www.theninja-rpg.com\nTAG POS=1 TYPE=A ATTR=TXT:In<SP>battle!* EXTRACT=TXT");
var G_Extract=iimGetLastExtract(1);
if (G_Extract.indexOf("In<SP>Battle!*") != -1)
{
iimPlay ("Battle.iim")
}
else
  {
  iimPlay ("Continue.iim")
  }

That's what I end up using but it's not picking up "In Battle!" on the screen. It sees it but doesn't. if that makes any sense.


may i suggest taking an online coding course https://www.udemy.com/ has some basic intro level courses i think you could benifet from
 
Top Bottom