Can you guess the output of this code?

Holzchopf

Well-known member
3rd Party Module Dev
Tutorial Author
Today I'm challenging you a bit =) Have a look at this code and try to figure out, what it will produce. Then run it. Don't worry, it won't destroy anything.

Strict

Function Main:Int()
Quirky.Run()
Return 0
End

Class Quirky
Function Run:Void()
Local i:Int, o:Int, O:Int, I:Int
Local txt:String
Local name1:String = "Alice"
Local name2:String = "Bob"

' try to guess the output
Print("I'm up!")
#rem
Well actually that one was easy, wasn't it?

But behold! It's getting worse >
#end

' let's see if we can break it
For i = 5 To 1 Step -1
Print(i)
Next
Print("I'm still up!")
' that was too easy, try some maths
For i = 5 To 1 Step -1
o = i * 4 - 6
O = -o * 5 - 11
I = (O - 19) / -20
Print(I)
Next

Print("I'm still up!")

'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.
' JUST SOME COMMENTS - DO YOU THINK THEY INFLUENCE THE CODE IN ANY WAY?
#rem

Or, maybe, I'm a magician and all this is just to distract you from the real
thing that's going on

#end
.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'.'

' guess again
Print("I'm still up!")
' WAIT WHAT?
Print "Who said that? (Looking at "+name1+" who's standing next to Bob)
' It's always important to have director instructions in scripts like
' these, isn't it?
' Now let's find Bob.
Print( name2 ) ' <- here he is
' (Yes he is. Now find him in the output window)
' Somehow we're still looking for bob..?
' Anyways... Do you know the meaning of these emojis?
' ( ͡° ͜ʖ ͡°)
' ¯\_(ツ)_/¯
' ʕ•ᴥ•ʔ
' (⊙_☉)
' .·´¯`(>▂<)´¯`·.
' )))'"[o..O]'"(((
' (ｏ・_・)ノ”(ᴗ_ ᴗ。)
' ლ(ಠ_ಠლ)
Print("Done finding Bob yet?")
End

' this overloads Print so it always appends "Simon says:"
Function Print:Void(pString:String)
.Print "Simon says: ~q" + pString + "~q"
End
End

HA HA I like how the syntax highlighter of the forum breaks some lines before the code does

Now be honest - did you guess everything correct?

Edit damn the syntaxhighlighting of the forum software is better than that one of TED/Mollusk and already gives away some things

Last edited:

MikeHart

CX Code Contributor
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Nope ....

Last edited:

Holzchopf

Well-known member
3rd Party Module Dev
Tutorial Author
Psst!

(but honestly: don't worry, not a single comment influences the code)

MikeHart

CX Code Contributor
3rd Party Module Dev
3rd Party Target Dev
3rd Party Tool Dev
Btw. I fixed your #rem #end issue. #end has to be always written small.

Holzchopf

Well-known member
3rd Party Module Dev
Tutorial Author
Nooooo this gives away the quirks in the code :-O

Edit
Had to remove the code tags. Seeing things through the forum-syntax-highlighting is cheating

Edit II
But thanks for the corrections anyways. I'll try to remember that ;-)