Parser problems

Help section from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

junglist
decaying skeleton
decaying skeleton
Posts: 1
Joined: Mon Sep 22, 2003 11:26 am

Parser problems

Post by junglist » Mon Sep 22, 2003 11:31 am

(this script is was supposed to help me practice spell skills and then med when oom until i have enough mana to cast again.)


I'm new to coding in general but it seems that this should work with my limited ability.. could it be caused by a bug of some sort? when i run this macro i get a error saying couldn't parse "ana,pct)>10{"
do i have to format my code in a certain way to avoid this or something?


here goes

Code: Select all






|MAIN

Sub Main

	
	/call Cast

	


|CASTING CODE

Sub Cast
	/stand
	:start
    /if  $char(mana,pct)>10{

		/cast 1
		/delay 50
		/goto :start
	}else
	{
	
		/call Med
	}






|MEDDING CODE

Sub Med


	/delay 50
	/sit
	
	:startmed
	
	/delay 10
	/doability 2
	
/if n $char(mana,pct)>95{

		/call Cast

	}else
	{
	/goto :startmed
	}





MacroFiend
a grimling bloodguard
a grimling bloodguard
Posts: 662
Joined: Mon Jul 28, 2003 2:47 am

Post by MacroFiend » Mon Sep 22, 2003 12:22 pm

One thing I see in your script is that you don't have a space between the end of your conditional and the opening bracket for either of your ifs. The parser is looking for that space to help it determine where things are.

Code: Select all

 /if  $char(mana,pct)>10{
should be

Code: Select all

 /if n $char(mana,pct)>10 {
It could also be a possible bug in the parser for $char(mana,pct) but I didn't see anything wrong when I looked at the code.

There are other bugs in your macro code that could cause some more serious issues. One, you should end a subroutine with a /return command.
Second, you shouldn't really make calls between two subs recursively. In many languages, it could cause a stack overflow. A better way to do this would be to have your Main sub act as the loop with your mana checks and casting.

There is a casterprac macro in the depot that does what you are attempting to do with other features. It might give you some extra insight in to how to structure a macro.

mf