Page 1 of 2
Is basic a single line single instruction code language?
Posted: Tue Sep 01, 2009 11:56 am
by AlanFoo
Am new to purebasic.
Currently learning to do basic programming in purebasic.
I tried to have multiple instructions codes in a single line e.g.
a$=B$:X=1
or dim a(100), b(200)
etc
Purebasic gives an error . Is there a syntax to do this or purebasic is a single line singe instruction code language?
btw....
Can someone from the Purebaisc adm help?
I tried to order the licence today for Euro 79 thru this site, but was refused for reasons :security reasons.
I checked with my citibank credit card div. they said there is no issue with my card. So what is the other althernative to pay? I I use paypal?
I am from Malaysia. Is it because they refuse purchases from Malaysia?
Regards
Alan
Posted: Tue Sep 01, 2009 12:04 pm
by Michael Vogel
Okay, the security issues should be checked by the PB-Team...
...but I can give you an answer to your single instruction line question: yes and no
Yes - each Purebasic instruction has to be separated, so
IF a<10 THEN a=a+1 ENDIF is not allowed (in a single line)
No - you can use the colon ( : ) as a separator as well, so
IF a<10 : a+1 : ENDIF will work
BTW your
a$=B$:X=1 example should also work without an error (at least with all Purebasic versions I've used so far
Hope you'll be able to get Purebasic soon, I'm quite sure you'll like it,
Michael
Posted: Tue Sep 01, 2009 12:52 pm
by Joakim Christiansen
This is also okay:
Code: Select all
Define value.l=22, string$ = "hello", whatever=12
Posted: Tue Sep 01, 2009 12:57 pm
by blueznl
But... the question is: do you WANT multiple instructions per line?
I think it's a horrible way to keep your code readable, but then again I have been known for having my own opinions
http://www.xs4all.nl/~bluez/datatalk/pure4.htm#1_style

Posted: Tue Sep 01, 2009 1:04 pm
by AlanFoo
Thansk micheal for the reply.
Yes, tried it and it works. Must have been other syntax issues when I got the error.
Regards
Alan
As for payment for purebasic, hope someone from Purebasic adm will help.
Am very eager to use Purebasic for my projects. Love the examples...:>)
and the good support from fello users here.
Posted: Tue Sep 01, 2009 1:30 pm
by UserOfPure
blueznl wrote:But... the question is: do you WANT multiple instructions per line?
It sure beats scrolling to read your code!

Posted: Tue Sep 01, 2009 2:04 pm
by Kaeru Gaman
UserOfPure wrote:blueznl wrote:But... the question is: do you WANT multiple instructions per line?
It sure beats scrolling to read your code!

only if you keep the lines short enough not to need to scroll
horizontally.
but in general, I prefer having Ifs and such multilined.
Posted: Tue Sep 01, 2009 4:59 pm
by Trond
About the payment, email Fred on this address:
alphasnd@purebasic.com.
Posted: Wed Sep 02, 2009 7:50 am
by John Puccio
Well Alan, you've come to the right language. Single line coding is considered to be poor style. As your code grows and you gain experience you will no longer do this.
a$=B$:X=1
instead you will do this
a$ = B$
X = 1
There are exceptions of course, but generally speaking it's not a good way to code. The above code is not a good example because it's too short to make the point. Do a search on the PurePunch contest read the rules. Then unzip the files and look at the source's and you will understand why. Welcome to PURE!
Kaeru Gaman wrote:UserOfPure wrote:blueznl wrote:But... the question is: do you WANT multiple instructions per line?
It sure beats scrolling to read your code!

only if you keep the lines short enough not to need to scroll
horizontally.
You could always set your type size to really really small..
JP
Posted: Wed Sep 02, 2009 9:42 am
by UserOfPure
Code: Select all
Protected a.l, b.l
Global throttle_limit.l, torque.l, driver_name.s
Those who oppose multiple keywords on a single line should therefore also convert the above to:
Code: Select all
Protected a.l
Protected b.l
Global throttle_limit.l
Global torque.l
Global driver_name.s
Otherwise, isn't there just a little bit of hypocrisy there?

Posted: Wed Sep 02, 2009 9:56 am
by Kaeru Gaman
one has to know metes and bounds.
normal Ifs: give it one line per Command.
really short Ifs: put it in one line.
Declarations: group by type and purpose.
Code: Select all
Define.l MX, MY, MBL0, MBR0, MBL1, MBR1
Define.l PlX, PlY
Define.l DpX, DpY
Define.d ShX, ShY, Speed
Define.l EngFlg
Define.l Rotation, RotSpd, RotPhs
Define.d RadaX, RadaY, RadaP
Define.l RadarRot, RadaC
"Readability" is not carved in stone, it's a dynamic thing and changes from situation to situation.
Posted: Wed Sep 02, 2009 10:06 am
by djes
As with Purebasic we can't assign multiples values in one line, I think it sometimes could be convenient to do things like that
.
Posted: Wed Sep 02, 2009 10:42 am
by Comtois
using Global you can write :
or Protected in a procedure :
Code: Select all
Procedure toto()
Protected Dim a(100), Dim b(200)
EndProcedure
Posted: Wed Sep 02, 2009 1:27 pm
by Little John
djes wrote:As with Purebasic we can't assign multiples values in one line, I think it sometimes could be convenient to do things like that
.

We
can do that. Your code works fine here with the current version 4.31 (Windows).
Regards, Little John
Posted: Wed Sep 02, 2009 1:33 pm
by eesau
Little John wrote:djes wrote:As with Purebasic we can't assign multiples values in one line, I think it sometimes could be convenient to do things like that
.

We
can do that. Your code works fine here with the current version 4.31 (Windows).
Maybe he meant something like: