Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whitespace sensitivity for EventMacro #3759

Open
KoukatsuMahoutsukai opened this issue Jun 2, 2023 · 6 comments
Open

Whitespace sensitivity for EventMacro #3759

KoukatsuMahoutsukai opened this issue Jun 2, 2023 · 6 comments

Comments

@KoukatsuMahoutsukai
Copy link

KoukatsuMahoutsukai commented Jun 2, 2023

  • Openkore version git: Latest
  • Server: Private server
  • Bug Report / Feature Request: Whitespace sensitivity for EventMacro
  • Summary: Just wondering if the Flow control statements are intended to be whitespace sensitive? the macro 1,2 and 3 below would behave differently after all. if its intended then neverminded me, if its not I can take a look at it further, might be a problem with the regex?
macro 1{
	$i = 0
	while($i < 10) {
	log \$i = $i
	$i++
        )
}

macro 1 would do the first iteration and print out a $i = 0, then would proceed to break out of the while loop, when i turn on the debug messages i would get these at the end
[eventMacro] Script '}'.
[eventMacro] Script is the end of a not important block (if or switch).

macro 2{
	$i = 0
	while ($i < 10) {
	log \$i = $i
	$i++
        }
}

macro 2 would work as intended, logging 1 to 10.

macro 3{
	$i = 0
	while ($i < 10){
	log \$i = $i
	$i++
        }
}

And macro 3 would outright crash the openkore and would output a message of
"The error message is:
Modification of non-creatable array value attempted, subscript -1 at plugins/eventMacro/eventMacro/Runner.pm line 1421."

@VasilyGorborukov
Copy link

You forgot about the second "}". For Example:

macro 3{
	$i = 0
	while ($i < 10){
	log \$i = $i
	$i++
	}
}

@KoukatsuMahoutsukai
Copy link
Author

yeah sorry for that typo, results stay the same fortunately/unfortunately.

@LycorisRecoil-NishikigiChisato
Copy link

LycorisRecoil-NishikigiChisato commented Jun 3, 2023

@KoukatsuMahoutsukai
macro 3{
$i = 0
while ($i < 10){
log \$i = $i
$i++
}
}

For example:
while ($i < 10) { } O
while($i < 10) { } X
while ($i < 10){ } X
while($i < 10){ } X
while ( $i < 10 ) { } X
macro 3{ } X

" " Blank space between program statements is very important.
The lack of blank space will make the statement unrecognizable.
Correct:
macro 3 {
$i = 0
while ($i < 10) {
log \$i = $i
$i++
}
}

@KoukatsuMahoutsukai
Copy link
Author

Thank you for elaborating on the points I raised. My main concern with it is if it was intended since not all programming languages are inherently whitespace sensitive,

From my understanding the macro syntax undergoes regex transformation into Perl code through the plugin right? The plugin was designed to provide a pseudo code-like syntax, making it more user-friendly for non-technical users if I'm not wrong. However, the current whitespace sensitivity seems incongruent with this objective. Additionally, I couldn't find any mention of this sensitivity to spacing in the documentation. Although the examples here are of what works and what doesn't work.

@LycorisRecoil-NishikigiChisato

Thank you for elaborating on the points I raised. My main concern with it is if it was intended since not all programming languages are inherently whitespace sensitive,

From my understanding the macro syntax undergoes regex transformation into Perl code through the plugin right? The plugin was designed to provide a pseudo code-like syntax, making it more user-friendly for non-technical users if I'm not wrong. However, the current whitespace sensitivity seems incongruent with this objective. Additionally, I couldn't find any mention of this sensitivity to spacing in the documentation. Although the examples here are of what works and what doesn't work.

The wiki has detailed usage:
https://openkore.com/wiki/macro_plugin

@KoukatsuMahoutsukai
Copy link
Author

KoukatsuMahoutsukai commented Jun 4, 2023

I have read that and it has indeed detailed explanations but nowhere does it mention it is whitespace sensitive for Flow controls and labels, Also the macro plugin is different from the eventMacro plugin https://openkore.com/wiki/eventMacro.

the example you gave:

macro 3 {
	 $i = 0
	 while ($i < 10) {
	    log \$i = $i
	    $i++
           }
 }

wouldn't work at all with macro plugin since it has a different syntax, below is how while loops are used with macro plugin

macro while {
   $i = 0
   while ($i < 10) as loop
   log \$i = $i
   $i++
   end loop
}

And again my concern with it is if it was intended or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants