Is basic a single line single instruction code language?

Just starting out? Need help? Post your questions and find answers here.
AlanFoo
Enthusiast
Enthusiast
Posts: 172
Joined: Fri Jul 24, 2009 6:24 am
Location: Malaysia

Is basic a single line single instruction code language?

Post 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
User avatar
Michael Vogel
Addict
Addict
Posts: 2797
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Post 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 :wink:

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
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

This is also okay:

Code: Select all

Define value.l=22, string$ = "hello", whatever=12
I like logic, hence I dislike humans but love computers.
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6166
Joined: Sat May 17, 2003 11:31 am
Contact:

Post 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

:-)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
AlanFoo
Enthusiast
Enthusiast
Posts: 172
Joined: Fri Jul 24, 2009 6:24 am
Location: Malaysia

Post 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.
UserOfPure
Enthusiast
Enthusiast
Posts: 469
Joined: Sun Mar 16, 2008 9:18 am

Post by UserOfPure »

blueznl wrote:But... the question is: do you WANT multiple instructions per line?
It sure beats scrolling to read your code! :)
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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.
oh... and have a nice day.
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

About the payment, email Fred on this address: alphasnd@purebasic.com.
User avatar
John Puccio
User
User
Posts: 26
Joined: Fri Jun 12, 2009 6:56 am
Location: My Keyboard

Post 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.. :lol:

JP
UserOfPure
Enthusiast
Enthusiast
Posts: 469
Joined: Sun Mar 16, 2008 9:18 am

Post 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? :twisted:
Last edited by UserOfPure on Wed Sep 02, 2009 11:54 am, edited 1 time in total.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post 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.

Code: Select all

If X > 639 : X = 0 : EndIf
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.
oh... and have a nice day.
User avatar
djes
Addict
Addict
Posts: 1806
Joined: Sat Feb 19, 2005 2:46 pm
Location: Pas-de-Calais, France

Post 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

Code: Select all

x = 1.0 : y = 1.0 : z = 1.0
.
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Post by Comtois »

using Global you can write :

Code: Select all

Global Dim a(100), Dim b(200)
or Protected in a procedure :

Code: Select all

Procedure toto()
  Protected Dim a(100), Dim b(200)
EndProcedure
Please correct my english
http://purebasic.developpez.com/
Little John
Addict
Addict
Posts: 4775
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Post 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

Code: Select all

x = 1.0 : y = 1.0 : z = 1.0
.
:?:
We can do that. Your code works fine here with the current version 4.31 (Windows).

Regards, Little John
eesau
Enthusiast
Enthusiast
Posts: 589
Joined: Fri Apr 27, 2007 12:38 pm
Location: Finland

Post 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

Code: Select all

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

Code: Select all

x, y, z = 1.0
Post Reply