What's new

If else Java help!

  • Thread starter iTzTECHKiNG
  • Start date
  • Views 1,027
iTzTECHKiNG

iTzTECHKiNG

Enthusiast
Messages
816
Reaction score
49
Points
95
Sin$
0
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!
 
Z61

Z61

Some times our saints are sinners
Retired
Programmer Forum Addict Odysseus' Summit
Messages
5,468
Reaction score
3,429
Points
1,042
Sin$
0
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
 
iTzTECHKiNG

iTzTECHKiNG

Enthusiast
Messages
816
Reaction score
49
Points
95
Sin$
0
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.
 
Z61

Z61

Some times our saints are sinners
Retired
Programmer Forum Addict Odysseus' Summit
Messages
5,468
Reaction score
3,429
Points
1,042
Sin$
0
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")
  }
 
iTzTECHKiNG

iTzTECHKiNG

Enthusiast
Messages
816
Reaction score
49
Points
95
Sin$
0
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.
 
iTzTECHKiNG

iTzTECHKiNG

Enthusiast
Messages
816
Reaction score
49
Points
95
Sin$
0
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?
 
Z61

Z61

Some times our saints are sinners
Retired
Programmer Forum Addict Odysseus' Summit
Messages
5,468
Reaction score
3,429
Points
1,042
Sin$
0
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.
 
thetechnation

thetechnation

gaming developer
Messages
1,418
Reaction score
144
Points
165
Sin$
0
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
Login
Register