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.

DarkBASIC Professional Discussion / print with ";" not working with numerical values in loops

Author
Message
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 12th Sep 2011 04:12 Edited at: 12th Sep 2011 04:15
not sure if it's always been this way but the use of ";" or "," doesn't work for numerical values in loops. Though it seems to work inside of loops if you convert the value to a string using str$(value) and ";" but not for ",".

As far as I'm concerned this is a bug



Your signature has been erased by a mod please reduce it to 600 x 120.
Qqite
16
Years of Service
User Offline
Joined: 28th Feb 2010
Location: Florida, U.S.
Posted: 12th Sep 2011 04:49 Edited at: 12th Sep 2011 04:50
Why are the "," and ";" outside of the str$() function? A string can only = something inside quotes...
a = "A string"
b = "1" //A string
c = "2.222" //A string
d = str$(2.22) //A string

e = ";" //This is a proper string
e = ; //This is NOT a proper string.

So in essence, that ";" and "," you are throwing after the str$() function is not proper.

If you want something that works in that sort, try this:


Ventures of the worlds around us are limited only by our imagination.
Suicidal Sledder
21
Years of Service
User Offline
Joined: 17th Aug 2004
Location: Tikrit, Iraq
Posted: 12th Sep 2011 06:52
I believe QQ is incorrect. the ; should belong outside of the str$() function since they are not actually part of the string.



will not work since a is not a string. it is an integer variable. the correct way to code what you are trying to do is as you have it:


If you are actually attempting to include the ; and , characters at the end of your string then QQs last example is exactly what you need to do.

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 12th Sep 2011 10:31 Edited at: 12th Sep 2011 10:36
; means print on the same line, I've never used the comma. But if str$(x); works it's not so bad.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Sep 2011 12:26 Edited at: 12th Sep 2011 12:36
I agree with zenassem - except his snippet doesn't tell the story correctly.

The first version, i.e.



works because only one print command is being used.

The semi-colon is for concatenating successive print commands (see Help file), for example,



That also works inside for/next loops as zenassem's original snippet shows - but neither version work with U77RC7 when you use numeric variables. The bug is nothing to do with for/next loops and I'm sure it used to work correctly at one point. If I get time later today I'll see if I can find out when it changed.

Edit It looks as if it works correctly as long as the print includes at least one string even an empty string. The following all work:

zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 12th Sep 2011 13:48
@Green Gandalf,
Thanks for looking into it. Yeah, somehow I missed copying the "successive" prints into the example code snippet. Thanks for picking up on that.

In actual code I stumbled upon this when trying to print values stored in a numerical array; indexing the array through a for-loop. Picked up on str$(); working,, but didn't think of trying an empty string. Curious to find out when/how this changed.

Your signature has been erased by a mod please reduce it to 600 x 120.
Sequence
15
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 22nd Sep 2011 10:27
I don't understand.

Got me this output.


If all the "1"s are in the right place, it'll work like a charm.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 22nd Sep 2011 13:55
Quote: "I don't understand"


Ok, then what do you think the output of this should be?



Your signature has been erased by a mod please reduce it to 600 x 120.
Sequence
15
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 22nd Sep 2011 14:01 Edited at: 22nd Sep 2011 14:04
Found a software bug in the forum software!!!!! When I posted ONLY the output of the code which is below, it came up with the message "TURN OFF CAPS LOCK KEY" and would NOT post he message.


1111122222

If all the "1"s are in the right place, it'll work like a charm.
zenassem
23
Years of Service
User Offline
Joined: 10th Mar 2003
Location: Long Island, NY
Posted: 22nd Sep 2011 14:09
That's not what outputs on ver 7_7 Rc7 rather the result is

1
1
1
1
1
2
2
2
2
2

Your signature has been erased by a mod please reduce it to 600 x 120.
Sequence
15
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 22nd Sep 2011 14:12
The following program, FOR SOME STRANGE REASON!!!

Gives this as output!!!!

SERIOUSLY, that IS the output I am getting.

If all the "1"s are in the right place, it'll work like a charm.
Sequence
15
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 22nd Sep 2011 14:14
This

outputs this:


If all the "1"s are in the right place, it'll work like a charm.
Sequence
15
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 22nd Sep 2011 14:21
Run this:

Then run this


If all the "1"s are in the right place, it'll work like a charm.
Sequence
15
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 22nd Sep 2011 14:25
Congratulations zenassem, you've found a software bug in DarkBasic Professional.

And it's one of the OLDEST commands that BASIC has to offer!

If all the "1"s are in the right place, it'll work like a charm.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 22nd Sep 2011 14:40
Well 1.075 works fine, and 7.7 is a beta so its a bug then in a beta test.

Sequence
15
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 22nd Sep 2011 14:43
That would have driven me crazy if I couldn't track it down. I've long ago quit using "PRINT". I use the TEXT command, and when I found out that "PRINT"... DOESN'T in the bottom 3 lines of the output screen, well, that did it for me.

If all the "1"s are in the right place, it'll work like a charm.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 22nd Sep 2011 14:47
What version of DB do you use?

Sequence
15
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 22nd Sep 2011 14:56
Dark Basic Professional 1.074

If all the "1"s are in the right place, it'll work like a charm.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 22nd Sep 2011 15:01 Edited at: 22nd Sep 2011 15:01
Well try 1.075 it doesn't print what you said it prints.

Sequence
15
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 22nd Sep 2011 15:07 Edited at: 22nd Sep 2011 15:09
Oh, I guess I was using a different version on my computer with windows XP Professional 32 bit (got it in March of this year, I believe). I'm using 64 bit Windows 7 Professional now. It wasn't "PRINT"ing into the last 3 lines on the screen when I went to full screen in 1280x1024x32 bit on a monitor with 1280x1024 max resolution, a CRT.

I was using, I believe, Verdana font in 24 as character size.

I just tried it on this version, it IS printing in the bottom 3 lines, AND in Verdana too. Thanks though, I didn't know there was a higher version already as I got this about a week or 2 ago now.

If all the "1"s are in the right place, it'll work like a charm.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 22nd Sep 2011 15:13
Yeah, you may have a point, I get some bugs too.

Login to post a reply

Server time is: 2026-07-10 15:30:54
Your offset time is: 2026-07-10 15:30:54