Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Colon Seperator

Author
Message
Dave47
10
Years of Service
User Offline
Joined: 30th Aug 2014
Location:
Posted: 14th Mar 2015 15:52
Can anyone explain how I can use a colon separator?
Should the "Print(y)" and "Print(z)" not be ignored if x <> 1?


x = 0
y = 2
z = 3

Do

If x = 1 Then Print (x): Print(y): Print(z)

sync()

Loop
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 14th Mar 2015 16:37
A colon is effectively a line end. Are you trying to do this:



Quidquid latine dictum sit, altum sonatur
=PRoF=
21
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 14th Mar 2015 19:42 Edited at: 14th Mar 2015 19:46
Using a colon to string together several commands on one line is something which is a bit of a legacy from when you had to input line numbers as well as code.

It still works in AppGameKit v2 as demonstrated by the following snippet..



However, you cannot use this with If/Then blocks as BatVink said.

Dave47
10
Years of Service
User Offline
Joined: 30th Aug 2014
Location:
Posted: 14th Mar 2015 20:08
I am doing exactly as BatVink says. It saves a lot of lines.
I use this in Visual Basic and it works perfectly.
Thanks for the replies.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 14th Mar 2015 21:17 Edited at: 14th Mar 2015 21:30
v1 have sometimes very lazy compiler erros for a basic language.
normal is the line break the command separator & endif and : should work after then as expected.

thats similar batvink example


AGK 108 (B)19 + AppGameKit V2 Alpha .. : Windows 8.1 Pro 64 Bit : AMD Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Mike Archer
9
Years of Service
User Offline
Joined: 19th Feb 2015
Location: Wales
Posted: 14th Mar 2015 22:17
Remember a colon is the same as a newline in AGK2, so...

If x = 1 Then Print (x): Print(y): Print(z)

is the same as writing

If x = 1 Then Print (x)
Print(y)
Print(z)

What is needed is

If x = 1
Print(x)
Print(y)
Print(z)
EndIf

If you want that on one line you could write it as..

If x = 1 : Print(x): Print(y): Print(z): EndIf

Login to post a reply

Server time is: 2024-11-25 18:43:07
Your offset time is: 2024-11-25 18:43:07