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 / How to split long lines of code?

Author
Message
Sarah6502
5
Years of Service
User Offline
Joined: 3rd Dec 2019
Location:
Posted: 7th Dec 2019 06:46
I like to have clean looking code and having to drag horizontal scrollbar back and forh is irratating. C++ have backslash for line continuation and If i'm correct Visual Basic seem to have underscore for that. But I can't find the proper way to do it in AGK. Is it possible?
fubarpk
Retired Moderator
20
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Dec 2019 07:03 Edited at: 7th Dec 2019 07:14
To the left you will see line numbers
just to the right of them is a "-" which you can collapse code parts such as functions etc with "+" to expand them
It is also good practice to have other AGC files in your project for example a constants file added to your project
that you use #include to include it in your program

EDIT I just noticed you asked horizontally the answer is no only vertically but white space is always good for code readability
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Sarah6502
5
Years of Service
User Offline
Joined: 3rd Dec 2019
Location:
Posted: 7th Dec 2019 07:28 Edited at: 7th Dec 2019 07:33
Code folding is always useful but my problem is more about the long line that exceed the right edge of the screen. I wish AppGameKit basic could have line continuation character to split the long line like other languages. It should help reading the code a lot.
fubarpk
Retired Moderator
20
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Dec 2019 07:33
true but what would it split it by
for example if you have multiple functions defined on one line splitting between them may work
but why would you want such long lines I like to keep them readable and the days of writing a
program with one line of code for a challenge aren't so common now.

even string definitions can be separated over multiple lines and are much more readable as I think
this is what you are asking
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Sarah6502
5
Years of Service
User Offline
Joined: 3rd Dec 2019
Location:
Posted: 7th Dec 2019 07:40
I think it is common to have long line that need to be splited such as function arguments. Sometimes they can be exceed the 79-character right margin due to the meaningful variable names or calculation inside the brackets.
fubarpk
Retired Moderator
20
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Dec 2019 07:42

is valid code
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Sarah6502
5
Years of Service
User Offline
Joined: 3rd Dec 2019
Location:
Posted: 7th Dec 2019 07:53
Quote: "apples + pears
- peaches + bananas
* fruitbowls"


No, it won't compile. First error is there is no assignment after variable apples. Second, you will got unexpected token "-" at the beginning of the second line.
fubarpk
Retired Moderator
20
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 7th Dec 2019 08:33
Im sure it did work but needed the maths at the end like c++ does ive been looking in the preferences
but I cant find the option as I used to break up my code like that in the past as its much more readable
So maybe not the best example but there is many times when code should be separated across multiple
lines. Theres also alsorts of different fold options in the ide's preferences. limiting to 79 characters would
wrap it to the next line for example

fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
smerf
20
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 21st Dec 2019 02:55
i have issues with line lenght as well sometimes when using lots of types and subtypes i end up with a short novel to the right off of screen space

Login to post a reply

Server time is: 2025-05-25 09:51:32
Your offset time is: 2025-05-25 09:51:32