mIRC Homepage

script file indenting

Posted By: maroon

script file indenting - 04/04/21 06:20 AM

An unmatched curly brace within a /* */ block causes all lines beneath the comment to be indented in the physical disk file, though you can't see it from the display in the scripts editor. This happens in both alt+D aliases and alt+R script files. It appears that the only way this doesn't happen is if you perform a bracket-check immediately prior saving changes to disk. If you do something between the bracket-check and the save, it's as if you didn't do the bracket check.

Below is a sample script which does not have the EVENT or any of the aliases indented as far as viewing in the scripts editor's view is concerned, but in the physical disk file.mrc every non-blank line beneath the comment section is indented with 2 extra spaces than appear in the scripts editor. The example's 1st alias should be able to see all aliases by looking for lines where the first word is the not-indented word 'alias' (with false positive possible within a /**/ block), but the indent glitch causes the rest of the aliases to not be reported.

However if you make any edit followed by performing the Ctrl+H bracket check then saving immediately, then the script is saved to disk without the extra indents. But if you then edit the file by inserting a space in front of one of the echoes without doing the bracket-check again, the extra spaces are all back again.

Code
/*
alias list_aliases_in_scriptfile {
  if ($1 != $null) {
    if ($isfile($1-)) var %file $1-
  }
  else var %file $script
  filter -fwg $qt(%file) $active /^(n\d+\=)?alias /
}

{
  comment section indented by using open bracket
  but closing bracket is not needed
  however this causes the remainder of the file to be indented
  */

  alias view_this_script_in_notepad {
    run $qt($script)
  }

  on $^*:TEXT:/^(@|!)triggername( +[^ ]+$|$)/i:#:{
    echo -g # $chr(22) $scriptline debug: ($1-) $1- regml1: $qt($regml(1)) regml2: $qt($regml(2)) | halt
  }

  alias alias_that_should_not_be_indented {
    echo -ag $script $scriptline
  }
© 2021 mIRC Discussion Forums