Edit ARDIS Optimizer .MCO macros in VS Code with syntax highlighting, suggestions, diagnostics, and indentation formatting. The extension does not modify or run macros automatically.
Created by: Douglas Ribeiro Sanguino. Publisher: TopSystem (local-ardis).
Editor diagnostics and function help follow the VS Code display language: Portuguese for pt locales and English otherwise. Snippet titles and descriptions show both languages.
Features
- Theme-aware colors for comments, strings, sections, commands, functions, variables, and numbers. ARDIS built-ins such as
ResFName, ResFPath, ResFSubdir, CURRENTMCO, and SUBSTR have their own color; NOT, AND, and OR are highlighted as keywords.
- Macro variables have a default amber color across themes. You can override it with
editor.tokenColorCustomizations for the variable.other.ardis-mco scope.
- Command and function completions with argument examples. The catalog includes the macro commands and the Optimizer calculator functions (
GET, GETMIN, FIELD, LEN, SUBSTR, DATE, CONCAT, LOOKUP, ASKPATH, and more), plus CNC macro commands such as Routing and GetTool.
- Alt+Shift+F formats MCO indentation: sections start at the left margin, commands inside sections are indented once, and multiline calls receive additional indentation. Expression and comment text is preserved.
- Signature help while typing
( or ;, and descriptions on hover. Hovering or completing SET, OPEN, MACRO, MACROIMPORT, EXPORT, REPORTTOFILE, COPYFILE, WRITEFILE, FIELD, RUNLINK, INSERT, GET, and others shows examples of each form of the command.
- Snippets: type
mco- for macro templates and for each form of the main commands, such as mco-set-variavel, mco-set-condicao, mco-set-partdraw, mco-open-banco, mco-macro-lista, mco-macroimport, mco-writefile, mco-field-ini, and mco-reporttofile. Type mco-header to insert a header with the current date; use Tab to edit the author and descriptions.
- Diagnostics for unclosed quotes, unmatched parentheses on the same line, duplicate sections, and likely function name typos. A quick fix is available for function typos.
- ARDIS syntax diagnostics: a name followed by
( that is not a function or command, a comma used as a separator (use ;), : inside parentheses, a nonexistent operator such as x=-5, an invalid character outside text (including accented letters in names), and a function used as a variable name.
- Ctrl+click a literal section name in
MACRO("SECTION") or MACROLOOP("SECTION" ; ...) to open [SECTION]; a diagnostic appears when the section is missing from the same file.
- Field suggestions in the second argument of
SET for ISTK/*.STK, ISTD/*.STD, LAYSTK, LAYOUTS, LAYSTRIP, *.EDG, *.MCH, ALGRES, and OPTPAR. Type a quote or press Ctrl+Space inside the field name.
- Part drawing fields (
PartDraw): after "PartDraw. the 56 fields appear by short name (EXT04, SIDE, Z2, FUNCTNAME) and long name (PartDrawExt04, PartDrawSide…), each with a description. SET accepts both, and the unknown-field diagnostic suggests the closest name (PartDraw.EXT4 → EXT04). KOPSND., PP., VRAGEN., and the TABLE.field form, such as "MACHTB.MachBlade1L", also work.
- Argument checks for
SET, OPEN, MACRO, MACROLOOP, MACROIMPORT, EXPORT, REPORT, REPORTTOFILE, COPYFILE, DELFILE, WRITEFILE, RUN, CALL, RUNLINK, INSERT, GET, FIELD, WAIT, and similar commands: required arguments, numbers where numbers are expected and text where text is expected, SET fields that exist in the table (with the closest name suggested), a valid variable or option in 2-argument SET, and the SET condition in the 7th argument. Only literal values are checked; variables and expressions are accepted.
- Parentheses inside text are not counted: one string may open
( and another, on another line, close it.
- A recommendation to start with
_ the macro variables used inside SET formula or condition text, as in SET("*.STK" ; "PartExt01" ; "=_codigoLote" ; 1 ; 99999). The quick fix renames the variable throughout the macro.
RUNLINK help for machine links and the mco-runlink-selcoosi snippet: /EDIT=0 runs without opening the parameter editor; /EDIT=1 opens it before execution.
- A style diagnostic for assigned variable names that do not use camelCase (default) or snake_case, as set in
ardisMco.validation.variableNamingStyle. A leading _ is accepted in both styles. It appears only at the first assignment of each name and does not prevent the macro from running.
Diagnostics are lightweight and do not replace ARDIS validation. Check version-specific function support, referenced files, and macro effects in ARDIS. Windows paths with \ before " are accepted.
Macro variables may have names such as pasta_saida_local, _labelFile, DataLote, or Sub. The naming style is a writing convention, not a way to identify ARDIS built-ins. A leading _ makes the variable global, visible inside text formulas of SET, reports, and tables.
Installation
In VS Code, open Extensions, search for TopSystem ARDIS MCO Tools, and select Install. To install a .vsix file, open Extensions → ⋯ → Install from VSIX... and select the file. Open any .MCO file and check that the language in the lower-right corner is ARDIS MCO.
The ardisMco.validation.enabled, ardisMco.validation.suspectedFunctionTypos, ardisMco.validation.unknownFunctions, ardisMco.validation.commandArguments, ardisMco.validation.missingLocalSections, ardisMco.validation.setVariablePrefix, and ardisMco.validation.variableNaming settings can disable editor diagnostics. ardisMco.validation.variableNamingStyle chooses between camelCase and snake_case.
Extensão para editar macros .MCO do ARDIS Optimizer no VS Code. Oferece destaque de sintaxe, sugestões, diagnósticos e formatação de indentação. Não modifica nem executa macros automaticamente.
Criador: Douglas Ribeiro Sanguino. Publisher: TopSystem (local-ardis).
Os diagnósticos e a ajuda de funções seguem o idioma de exibição do VS Code: português para idiomas pt e inglês para os demais. Os títulos e descrições dos snippets aparecem nos dois idiomas.
Recursos
- Cores para comentários, strings, seções, comandos, funções, variáveis e números, conforme o tema do VS Code. Nomes internos como
ResFName, ResFPath, ResFSubdir, CURRENTMCO e SUBSTR usam a cor de recursos do ARDIS; NOT, AND e OR usam a cor de palavras-chave.
- Variáveis da macro recebem uma cor âmbar padrão em qualquer tema. Ela pode ser alterada em
editor.tokenColorCustomizations para o escopo variable.other.ardis-mco.
- Autocompletar funções e comandos com exemplos de argumentos. O catálogo traz os comandos de macro e as funções da calculadora do Optimizer (
GET, GETMIN, FIELD, LEN, SUBSTR, DATE, CONCAT, LOOKUP, ASKPATH e outros), além de comandos de macros de CNC como Routing e GetTool.
- Alt+Shift+F formata a indentação MCO: seções ficam na margem esquerda, comandos das seções recebem um nível de recuo e chamadas divididas em várias linhas recebem recuo adicional. O texto das expressões e comentários é preservado.
- Ajuda de assinatura ao digitar
( ou ;, e descrição ao passar o mouse.
- Snippets: digite
mco- para ver modelos de macro e de cada forma dos comandos principais: mco-set-variavel, mco-set-valor, mco-set-condicao, mco-set-variavel-macro, mco-set-limpar, mco-set-partdraw, mco-set-partdraw-formula, mco-set-laystk, mco-open, mco-open-novo, mco-open-importar, mco-open-banco, mco-macro-lista, mco-macroimport, mco-copyfile-mover, mco-writefile, mco-field-ini, mco-reporttofile e outros.
- Ao passar o mouse ou ao completar
SET, OPEN, MACRO, MACROIMPORT, EXPORT, REPORTTOFILE, COPYFILE, WRITEFILE, FIELD, RUNLINK, INSERT, GET e outros, aparecem exemplos de cada forma do comando.
- Digite
mco-header e escolha o snippet para inserir o cabeçalho. A data é preenchida no momento da inserção; use Tab para editar autor, descrição e a segunda linha descritiva.
- Avisos para aspas sem fechamento, parênteses sem par na mesma linha, seções duplicadas e nomes de função provavelmente digitados errado (com correção rápida).
- Avisos de sintaxe do ARDIS: nome seguido de
( que não é função nem comando, vírgula usada como separador (use ;), : dentro de parênteses, operador inexistente como x=-5, caractere inválido fora de texto (inclusive letra acentuada em nome) e função usada como nome de variável.
- Ctrl+clique no nome literal em
MACRO("SECAO") ou MACROLOOP("SECAO" ; ...) para abrir [SECAO]; aviso quando ela não existe no mesmo MCO.
- Sugestões de campos no segundo argumento de
SET para ISTK/*.STK, ISTD/*.STD, LAYSTK, LAYOUTS, LAYSTRIP, *.EDG, *.MCH, ALGRES e OPTPAR. Digite a aspa ou use Ctrl+Espaço dentro do nome do campo.
- Campos do desenho da peça (
PartDraw): depois de "PartDraw. aparecem os 56 campos pelo nome curto (EXT04, SIDE, Z2, FUNCTNAME) e pelo longo (PartDrawExt04, PartDrawSide…), com a descrição de cada um. O SET aceita os dois, e o aviso de campo inexistente sugere o nome mais próximo (PartDraw.EXT4 → EXT04). Também valem KOPSND., PP., VRAGEN. e a forma TABELA.campo, como "MACHTB.MachBlade1L".
- Integridade de
SET, OPEN, MACRO, MACROLOOP, MACROIMPORT, EXPORT, REPORT, REPORTTOFILE, COPYFILE, DELFILE, WRITEFILE, RUN, CALL, RUNLINK, INSERT, GET, FIELD, WAIT e similares: argumentos obrigatórios preenchidos, número onde se espera número e texto onde se espera texto, campo do SET existente na tabela (com sugestão do nome mais próximo), variável ou opção válida no SET de 2 argumentos e condição do SET no 7º argumento. Só valores literais são conferidos; variáveis e expressões são aceitas.
- Parênteses dentro de texto não são cobrados: um texto pode abrir
( e outro, em outra linha, fechar.
- Recomendação de
_ no início de variáveis criadas na macro e usadas dentro do texto da fórmula ou da condição do SET, como em SET("*.STK" ; "PartExt01" ; "=_codigoLote" ; 1 ; 99999). A correção rápida renomeia a variável em toda a macro.
- Ajuda de
RUNLINK para links de máquina e snippet mco-runlink-selcoosi: /EDIT=0 executa sem abrir a tela de parâmetros; /EDIT=1 mostra a tela de edição antes da execução.
- Aviso de estilo para nomes de variáveis atribuídas que não seguem camelCase (padrão) ou snake_case, conforme
ardisMco.validation.variableNamingStyle. O _ no início é aceito nos dois estilos. O aviso aparece apenas na primeira atribuição de cada nome; não impede a execução da macro.
O verificador é leve, não um compilador ARDIS. Compatibilidade de funções com a versão instalada, arquivos referenciados e efeitos da macro ainda precisam ser validados no ARDIS. Caminhos Windows com \ antes de " são aceitos corretamente.
Variáveis criadas na macro podem ter nomes como pasta_saida_local, _labelFile, DataLote ou Sub. O estilo de nome é uma convenção de escrita, não um critério para identificar variáveis internas do ARDIS. O _ no início torna a variável global, visível dentro das fórmulas em texto de SET, relatórios e tabelas.
Instalação
No VS Code, abra Extensões, procure TopSystem ARDIS MCO Tools e selecione Instalar. Para instalar um arquivo .vsix, abra Extensões → ⋯ → Instalar do VSIX... e selecione o arquivo. Depois abra qualquer .MCO e confira que a linguagem no canto inferior direito é ARDIS MCO.
As opções ardisMco.validation.enabled, ardisMco.validation.suspectedFunctionTypos, ardisMco.validation.unknownFunctions, ardisMco.validation.commandArguments, ardisMco.validation.missingLocalSections, ardisMco.validation.setVariablePrefix e ardisMco.validation.variableNaming permitem desligar os avisos no VS Code. ardisMco.validation.variableNamingStyle escolhe entre camelCase e snake_case.
| |