Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

200
Visualizações
The variable is not defined, but it is

I have declared global variables at the top of the script, and I have initialised them.

I can set the "do JavaScript" to the variable "emptyDue" fine. But then as soon as I try to compare the result of the JavaScript to the serviceDate variable, I get: "error "The variable emptyDue is not defined." number -2753 from "emptyDue"".

Why can I assign emptyDue on one line, and then on the very next line, it suddenly forgets that it should exist?

global emptyDue, serviceDate
set emptyDue to ""
set serviceDate to "2021-11-30"

on isEmptyDue()
    
    tell application "Safari" to tell document 1
        
        set emptyDue to do JavaScript "document.getElementById('trgUseNext').click();
 document.getElementById('trgUseNext').value; --gets the date value from a webpage."
        
        if emptyDue < serviceDate then
            display dialog "TRUE"
        else
            display dialog "FALSE"
        end if
        
    end tell
    
end isEmptyDue

isEmptyDue()
log emptyDue
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There is a known flaw in AppleScript’s design: it is possible for a command to return no value. If you then bind the result of that command to a variable, it effectively makes that variable undefined.

You can avoid that -2753 error by making sure your command always returns a value, even if that value is just an empty string.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda