NaaLaa
Windows Program Console - Printable Version

+- NaaLaa (https://www.naalaa.com/forum)
+-- Forum: NaaLaa (https://www.naalaa.com/forum/forum-1.html)
+--- Forum: NaaLaa 7 Questions (https://www.naalaa.com/forum/forum-3.html)
+--- Thread: Windows Program Console (/thread-147.html)



Windows Program Console - dantas72 - 07-14-2024

What's up guys! Can we have examples of practical use of codes for the Windows console?

1 - Search.
2 - create directory.
3 - A program to receive two numbers from the user and make the sum and display it on the screen.
4 - Remove directories.
5 - Search within files, .txt, Doc.
6 - Basic Mini Compiler.
7 - Receive arguments via the prompt command line.

Something to learn more about the language.
thanks Smile


RE: Windows Program Console - dantas72 - 07-15-2024

Hello!

Below is the first example. Console program name: add.n7a

Code:
' Programa para somar dois números recebidos do usuário
' Program to add two numbers received from the user

' Função principal
function main()
    ' Variáveis para armazenar os números e o resultado
    ' Variables to store the numbers and the result
    num1 = 0
    num2 = 0
    resultado = 0

    ' Solicitar o primeiro número
    ' Prompt for the first number
    pln("Enter the first number:")
    num1 = rln() ' Ler o primeiro número do console
                 ' Read the first number from the console
  
    ' Solicitar o segundo número
    ' Prompt for the second number
    pln("Enter the second number:")
    num2 = rln() ' Ler o segundo número do console
                 ' Read the second number from the console
 
    ' Realizar a soma
    ' Perform the sum
    resultado = int(num1) + int(num2)

    ' Exibir o resultado
    ' Display the result
    pln("The result of the sum is: " + resultado)
endfunc

' Chamar a função principal
' Call the main function
main()



RE: Windows Program Console - Marcus - 07-15-2024

I'll see if I can write some examples for the undocumented file library (file.n7). It contains functions for listing files etc. You can also use the 'system' command/function directly to execute any command line command.

I believe someone wrote an interpreter for tiny basic in n7, should be somewhere around here Smile