Teacup #5: Files, Input, and Automation tutorial

Files, Input, and Automation


When programs leave the screen

Until now, everything we built lived only in memory.

  • Variables disappear when the program ends

  • Arrays vanish

  • Objects fade away

Real programs need something more.

They need to:

  • Read information from the user

  • Save data for later

  • Automate boring tasks

This is where programming stops being a lesson
and starts becoming a tool.


1. Reading input – Let the user speak

Programs are more interesting when they can listen.

In GTLang, reading user input is very simple.

@echo "What is your name?"
$name : @input

Now use it:

@echo "Hello " $name

Example run:

What is your name?
< John
Hello John

No parsing.
No configuration.
Just conversation.


2. Files – Giving memory to your program

Files allow programs to remember things after they stop running.

Think about:

  • Notes

  • Logs

  • Settings

  • Saved results

GTLang provides simple file functions for exactly these needs

GREENTEA-PROGRAMMING-LANGUAGE-M…


Writing to a file

@file_write "notes.txt", "Remember to drink green tea\n"

If the file exists, GTLang appends to it.
If it doesn’t exist, GTLang creates it.


Reading from a file

$content : @file_read "notes.txt"
@echo $content

Your program now remembers something from the past.


Initializing a file (reset or create)

@file_init "log.txt", "Program started\n"

This is useful for:

  • Logs

  • Daily reports

  • Fresh output files


3. Real example #1 – A simple note keeper

Let’s build something real and useful.

@echo "Write a note:"
$note : @input
@file_write “notes.txt”, $note “\n”

@echo “Saved!”

Every time you run this program, it:

  1. Asks for a note

  2. Saves it

  3. Keeps it forever

That’s automation.


4. Reading and processing file content

Files are not just storage.
They are data sources.

$text : @file_read "notes.txt"
$lines : ("\n" @split $text)
foreach $lines as $line
@echo “- ” $line

Now your program understands file content, not just stores it.


5. Automation – Let the computer do boring work

Automation is the real power of programming.

Anything that is:

  • Repetitive

  • Predictable

  • Time-consuming

…should be done by a program.


Real example #2 – Simple daily logger

$time : @now
@file_write "daily.log", "Run at " $time "\n"

Every run adds a timestamp.

Perfect for:

  • Tracking activity

  • Debugging

  • Building habits


6. Combining input, logic, and files

This is where everything connects.

Real example #3 – Simple user registry

@echo "Username:"
$username : @input
@echo “Role (admin/user):”
$role : @input

@file_write “users.txt”, $username “,” $role “\n”

@echo “User saved”

Now you have:

  • Input

  • Data formatting

  • Persistent storage

This is how real tools begin.


7. Automation mindset (the most important lesson)

Programming is not about typing code.

It’s about asking:

“What am I doing repeatedly?”

If the answer exists —
then a program can do it for you.

Even a small script can:

  • Save hours

  • Reduce mistakes

  • Bring clarity

GTLang is designed so beginners can reach this moment early.


8. Why GTLang is good for automation

GTLang shines here because:

  • Syntax stays readable

  • No boilerplate

  • Files are easy

  • Logic flows naturally

You think → you write → it works.

No fighting the language.


Final thoughts – You are building tools now

At this point, you can:

  • Read input

  • Write files

  • Process data

  • Automate tasks

  • Combine everything into real scripts

You are no longer “learning to program”.

You are using programming.

That is the most important transition of all.

The rest is just refinement.

In the next step, you could:

  • Build a full mini project

  • Create command-line tools

  • Combine objects + files

  • Design your own small systems

Slow progress.
Strong foundation.
Like green tea ☕🌱