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.

Newcomers DBPro Corner / I can't get a basic Hello World program to work.

Author
Message
JohnnyJohnson
10
Years of Service
User Offline
Joined: 5th May 2013
Location:
Posted: 5th May 2013 10:49
Hey everyone. I'm pretty new to programming besides a bit of HTML, and I'm trying to put the words "Hello world" on the screen. So I figured out what commands I need to do that with. Finally, I came up with print "Hello world" but it doesn't work. It just comes and immediately goes away. If anyone could help me that would be so great, programming seems like a lot of fun.
Phaelax
DBPro Master
20
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th May 2013 07:33
There's nothing holding the application window open after it prints to the screen, and so the program ends. Either halt the program, or use a continuous loop.

Method 1:



Method 2:



Once you start making actual programs, you'll be using a loop to keep the flow of the program going.

"You're all wrong. You're all idiots." ~Fluffy Rabbit
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 6th May 2013 13:49 Edited at: 7th May 2013 02:44
Hello my DBpro buddies! JohnnyJohnson, let me explode your mind by furthering Phaelax's second technique.

My code with REM;



And below is the same code but without remarks;



Note how in my example, I did not use the CLS command? This is something you should make a note of, and learn when, or if, you should be using CLS.

Now, see if you can't optimise my code, or improve on it! That way I can learn something in return, and we all win!

EDIT: Here's an example of the power that we've unleashed here.



Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
CSL
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: USA
Posted: 18th May 2013 19:30
Burning Feet Man

Do you have some sort of plugin or alternate version of DBPro?
The ink command takes two parameters, and it doesn't run on my regular version of DBPro.

Parameter for 'INK' do not match 'Foreground Color,Background Color' at line 3.

CSL
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 19th May 2013 02:30
I think ink is overloaded in the M1U library to just use the foreground colour and slap in the previous / default background one.
Just add ", 0" and it should run for you with just the standard DBP functions.


"Why do programmers get Halloween and Christmas mixed up?"
CSL
15
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: USA
Posted: 19th May 2013 04:54
Quote: "Just add ", 0" and it should run for you with just the standard DBP functions."

I actually commented the instruction and the program worked fine. My point is that newcomers usually have the bare bones version of DBPro, and having this type of non-standard code may throw them off.
No harm done, just an observation

CSL
JohnnyJohnson
10
Years of Service
User Offline
Joined: 5th May 2013
Location:
Posted: 23rd May 2013 00:32
Thanks guys, sorry for the long reply delay.
Burning Feet Man
16
Years of Service
User Offline
Joined: 4th Jan 2008
Location: Sydney, Australia
Posted: 24th May 2013 06:24
CSL, it's always the simply things, isn't it! You'll bump into this problem a lot when trawling through code on the forums. Remming' out the odd ends is usually the safest bet when troubleshooting.

Help build an online DarkBASIC Professional help archive.
DarkBasic Help Wikia
Sixty Squares
17
Years of Service
User Offline
Joined: 7th Jun 2006
Location: Somewhere in the world
Posted: 1st Jun 2013 04:39 Edited at: 1st Jun 2013 04:40
For those who may not know what the M1U Library is, it's one of the most useful libraries to have for DBP
http://forum.thegamecreators.com/?m=forum_view&t=85209&b=18


Guns, cinematics, stealth, items and more!

Login to post a reply

Server time is: 2024-03-28 21:44:10
Your offset time is: 2024-03-28 21:44:10