Skip to content

Commit 9ccefa2

Browse files
Update TUTORIAL.md
1 parent a9f0043 commit 9ccefa2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

TUTORIAL.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,26 @@ the equivalent in FreakC would be:
12051205

12061206
open[] /B "" file.bat
12071207

1208+
Example with functions:
1209+
1210+
enb_delay[]
1211+
1212+
:: asynchronous code
1213+
open[] /b "" count[..] "Dog"
1214+
:: synchronous code
1215+
count[..] "Sheep"
1216+
1217+
:: Count function to print a string 10 times
1218+
function[] count
1219+
@echo off
1220+
loop[] %%i in (1 1 10) do (
1221+
print[] %%i %~1
1222+
wait[] 2 >nul
1223+
)
1224+
endfunc[]
1225+
1226+
You would be able to see that it doesn't wait for 2 seconds to print out Dog and *then* Sheep, Dog and Sheep are printed at almost the same time. This is because the code is run asynchronously, it is non blocking. This helps a lot in improving performance because you can technically change "in-order" tasks into tasks that run together. Think of it as a bathtub, rather than making one people take a bath and then proceeds to the next one, you can just put all people into the bathtub, which should reduce a lot of time, and should scale well if given more people (who in real case, are users). Or if you are developing a videogame, the code can reacts to user's input while the game is still rendering normally.
1227+
12081228
# Parentheses
12091229
## An alternative
12101230
Because FreakC uses more "human-friendly" syntax, but Batch uses parentheses for creating blocks of codes, so I've decided to add a crappy "human version" of this:

0 commit comments

Comments
 (0)