Olá seguidor e seguidora do blog!
Como parte do processo de aprendizado de uma nova linguagem, muitas vezes temos que nos adaptar a sintaxe e ao paradigma do ambiente e da linguagem que estamos aprendendo. Tendo isso em mente, resolvi olhar para algumas das mais importantes estruturas de repetição e de decisão.
Forma 2: IF…THEN…ELSE IF…ELSE…END IF
Uma forma de aplicar a instrução IF quando mais de uma condição precisa ser considerada.
Forma 3: IF…THEN
if <condição> = “xpto” then exit subPoderia ainda citar outras formas diferentes, utilizando a cláusula and ou or mas, vamos falar sobre o IF no Office Script.
O IF vem acompanhado de parenteses. Dentro dele é que é feita a análise da condição. Somente SE o valor da condição retornar true (verdadeiro), as instruções que estão entre as chaves ({ }) serão executadas. Caso a condição retorne false (falso), as instruções localizadas após o else serão executadas.
Parace difícil? Posso te garantir que não é. O IF tem a mesma funcionalidade que a função SE na planilha e por ser uma função lógica, pode dar um certo trabalho no começo entender como ela funciona mas, com o tempo, você estará escrevendo suas estruturas de decisão if de uma forma automática e rápida, pois com o tempo sua lógica vai melhorando.
Ufa! Esse é um artigo longo. Gostou? Deixe aqui nos comentários o que achou e me diga: quer ver uma aula somente sobre a função IF no meu canal de vídeos no Youtube? No meu curso completo essa e outras aulas sobre o if já podem ser consultadas.
Para cupons de desconto na Udemy, confira esse outro artigo que escrevi e é atualizado mensalmente com promoções (clique aqui).
✔ Para acesso ao conteúdo programático do curso clique aqui.
Convido você a ler outros artigos que já escrevi sobre o Office Script:
Office Script | TypeScript – Método reduceRight para array
Office Script | Que tal estudar esta tecnologia agora?
Office Script | Estrutura de decisão IF … ELSE IF … ELSE … – Artigo 1
Office Script | Estrutura de decisão SWITCH … CASE – Artigo 1
Alessandro Trovato
Compartilhando conhecimento, sempre!
#typescript #officescript #excelonline #excelscript #trovato #mvp #mvpbr #cursostrovato #if #elseif