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 Discussion / Manual Doesn't Say How To Get Rid Of Problem (various)

Author
Message
Sequence
8
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 8th Apr 2013 22:42 Edited at: 8th Apr 2013 22:44


Well, even though I got over enthusiastic there, turns out it DOESN'T work!

Want to explain why there is a blank line at the end of the file and ***how to get rid of of said *bleeping* line***.


Very, very oddly another BASIC language that I used to code in for over 10 years has the very same shortcoming and I was never able to resolve it. Even with a command where I was able to move the write file "print head" back 2 bytes!!!!! Weird that I should hit the very same problem a decade later.

If all the "1"s are in the right place, it'll work like a charm.
Sequence
8
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 8th Apr 2013 22:48
Turns out that only one array can be defined per line. I use arrays extensively. I have 50 lines of code that define one array each. Then I remembered that I could have multiple commands per line if separated by the colon character. Would have been nice if the manual told me that.

If all the "1"s are in the right place, it'll work like a charm.
Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 8th Apr 2013 22:53
I don't think you can actually stack multiple dims on the same line. What on earth do you need 50 arrays for? Would it help to combine some of them into multi-dimensional arrays perhaps?


Sequence
8
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 8th Apr 2013 22:53
The
Text 50,30,A$
command.

Would have been nice if I was told that it can not continue from where it leaves off,

Text ,," This continues from where you were"

or that the coordinates that it left off at from printing are not retrievable by the coder. I had both of those at my disposal in my previous version of BASIC that I used to code in.

If all the "1"s are in the right place, it'll work like a charm.
Sequence
8
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 8th Apr 2013 23:01 Edited at: 8th Apr 2013 23:04
Hi OBese87

What I do is:


And I do use multi-dimensional arrays. That was just an example. Since I figured out how to properly use the inkey$() command (previously, I had a 4,500 line program (535 K source code file) with only one inkey$(), something that looks like I can't get away with in Dark BASIC) I am now starting to write a game.

It has spells which mostly use 2 dimensional arrays, but the characters need 3 dimensional arrays, very complex stuff. There are dozens of separate arrays for monsters, spells, instructions, etc.

If all the "1"s are in the right place, it'll work like a charm.
Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 8th Apr 2013 23:09 Edited at: 8th Apr 2013 23:13
Text issue: PRetty messy but something like this might work for you.


Arrays: Hmm, I'll have to get back to you on that. DB isn't the best at data manipulation, but there are ways.


Sequence
8
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 8th Apr 2013 23:17
What command do I use to get 32 bit colour, and the screen fully opened to 1920*1080 with windows (the OS) completely gone from the display?

I've only been able to achieve this by clicking the outside boxes in the IDE* and pick something like "other PC format" (don't have Dark BASIC running to tell you the exact phrase). After all, when coding, that is the first thing you want gone, ms' worthless windows.


* integrated development environment

If all the "1"s are in the right place, it'll work like a charm.
Sequence
8
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 8th Apr 2013 23:21
So, tx is the end pixel of the text write.... Doesn't the value become zero when the function terminates?

If all the "1"s are in the right place, it'll work like a charm.
Sequence
8
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 8th Apr 2013 23:36
Why is it that...


...produces a screen of partially garbled text?

The vertical can display 27 lines of text in the size of font I was printing in before scrolling. 1920*1080 32 bit.

If all the "1"s are in the right place, it'll work like a charm.
Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 10th Apr 2013 01:08
Quote: "What command do I use to get 32 bit colour, and the screen fully opened to 1920*1080 with windows (the OS) completely gone from the display?"

SET DISPLAY MODE 1920,1080,32
It should be fullscreen by default... are you using an IDE that specifies the resolution? If there is no 1920x1080 option then use the command above to override it.

Quote: "So, tx is the end pixel of the text write.... Doesn't the value become zero when the function terminates?"

That is normally the case but in DBC local variables are preserved. That was a quick and dirty fix, have you tried searching the code base for suitable functions?

If you don't need special fonts this would be much easier to do with the print command. printc (or printr I can't remember) prints where the last print command left off. It's an undocumented command for some reason, so it wont be syntax highlighted unless you manually add it to the keywords. Also the print command outputs characters in uniform size so it's much easier to position things.


Latch
13
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 10th Apr 2013 07:07
Quote: "Want to explain why there is a blank line at the end of the file and ***how to get rid of of said *bleeping* line***.
"


This behavior isn't an error, the command is designed that way. What's happening is that each time you write a string to a file, a carriage return and a linefeed (CR+LF) are added to the end of the string. This makes it very easy to write formatted text to a file as the file position is always updated to the beginning of the next line - like lists for example - without the user having to do any really intervention.

If you want to eliminate the CR+LF, one way is to write the string information to the file byte by byte. If it's just the last line you are worried about, then write the bytes just to handle that line omitting the CR+LF:



Enjoy your day.
Sequence
8
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 25th May 2013 21:38 Edited at: 25th May 2013 21:45
Thank you Latch, that works. Very happy to have that information.

But the misery continues....

1) Turns out that
Read 1, A$
has a line length limitation... A limitation that causes the program to crash.

2) Turns out that
Write 1, A$
also has a line length limitation, also causing the DarkBASIC program you make to crash, and they are both different lengths!!!


First one is about 1300 characters, and the second is somewhere in the 1800 to 2250 range.

Too bad that the user manual doesn't warn you of this, as I guess that just good old common sense/intuitive knowledge no doubt applies to you not succumbing to that pitfall?



I really don't know how to code using DarkBASIC. It is near impossible to do.

I wrote a project and program. I wanted to make another program just by itself, because I just can't deal with, nor do I know what a "project" is. I'm using Indigo Beta. So, I pick "New", and it forces me to choose a name for the new program immediately. I make a name, copy/paste the entire program I'm working on over to it, change a whole lot of lines, run it, and nothing new that I coded is there. I'm staring at new code and none of it is being run. What's running? The program I coded before. So, I do another copy of the whole program, close all the open tabs, pick "new", paste in the code, do changes, it runs. HOWEVER, it turns out that my OLD program, when I load it, get this, I'm looking at the old code and it's running the NEW program that I made? I think I've lost my old program now???


I remember and miss the "good old days" where, you type some code in, run it, and it runs, start a new program, and indeed, THAT program runs. I'm almost ready to just throw in the towel on this as, well, I just can't get things to work, as in, type in commands, and they run. Save a program, and it gets saved.

As it stands now, I seem to have projects with no matching code files, and the file dates are all over the map too. :-(

If all the "1"s are in the right place, it'll work like a charm.
Latch
13
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 26th May 2013 03:58 Edited at: 26th May 2013 03:59
You mentioned Indigo, so I'm assuming you are using DarkBASIC Pro. DarkBASIC Pro is a compiled language and is a little different than DarkBASIC Classic (which is the board this thread is on). Pro has more options and overall more advanced functionality built in. But you'll have to compile your code before you can run it.

Classic, is much more like the olden days where you can just type and then run the program. This is an interpreted language - it basically means your source is run like a script on an engine that interprets what you type and executes the commands that match up right there and then - without compiling it (i.e. without converting it to machine language).

Classic doesn't really use projects - it's just code. You might manage the code yourself in a project of sorts or use an editor that does it for you. Besides media, there are generally two types of files:

1. Source - a file ending in .DBA - this you can run in the interpreter and edit it and run it again. There's even a command line interface (CLI) so you can try short commands and see an immediate result without having to write an actual program.

2. An executable - you can convert your source to a standalone program so you can distribute it. You can think of it as a copy of the engine that you wrote and tested your source code in that only interprets your final version - so there is no editing ability once made into the exe.

There are a series of tutorials that can help you get a handle on DarkBASIC in general - both Pro and Classic. There's a link at the top of this board but I'll put it here as well:

TDK's DB tutorials

Enjoy your day.
Sequence
8
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 26th May 2013 18:27 Edited at: 26th May 2013 18:28
All quotes are from;
"TDK_Man's Dark Basic Programming For Beginners Part 4 - File Access"
LOCATION: http://forum.thegamecreators.com/?m=forum_view&t=96084&b=7

Quote: "However there is a limit of 255 characters with DB's strings so if the text file you are reading in has a line greater than 255 then the reading will end abruptly with an error. We'll ignore this point for the moment though and return to it later..."


Unfortunately, reading in strings has an about 1200 characters limit. Although, he isn't talking about DB Pro.

TDK also doesn't say that writing strings has a limit of 255 characters (DB Pro, somewhere between 1800 and 2200), and is that including the CHRs 13 and 10? Since those are added automatically, that means that you can only write lines that are 253 characters in size?


Quote: "
The Read String line reads each piece of data into T$ and it is then placed into the string array using the numeric counting variable LineCount. If anyone is wondering why I use:

Read String 1,T$: TextLines$(LineCount)=T$

rather than

Read String 1,TextLines$(LineCount)

it's because I have encountered problems in the past when reading array values directly. Since using a normal string variable to read the data and then transferring the contents to an array I haven't encountered those errors. Feel free to use whichever method you like - the end result should be the same..."


Speaking of the above problem, wouldn't you read the string, then before assigning it to a variable, do the endfile check first?

I've found that reading byte by byte, and it's off of SSD drives, connected in RAID 0 (striped) with a 3.4 GHz quad core CPU takes a VERY long time to complete!!!!

Also, he doesn't say that not only does it not read or write strings that are longer than these limits, DarkBASIC goes ahead and CRASHES!!!

How am I supposed to know that lines are going to be longer than 255 characters? I think that maybe ALL files have to be read in by byte unless you know that it's a data file created by your program.

Still doesn't save you from a file that is corrupted or tampered with with a hex editor program.

If all the "1"s are in the right place, it'll work like a charm.
Latch
13
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 27th May 2013 02:59
Hi Sequence,

Perhaps if you explain what exactly you are trying to do. What is your goal? It could be your approach needs a little adjusting.

The command you listed:

Read 1, A$

Suggest that you are trying to read a string of data from a series of data statements and store them in a variable named "1".

Perhaps you meant :

Read String 1, A$

which would make all the difference in the world in terms of an error occurring.

Enjoy your day.
Sequence
8
Years of Service
User Offline
Joined: 16th Mar 2011
Location: Canada
Posted: 27th May 2013 21:55 Edited at: 27th May 2013 22:02
Hi Latch,

The limitations of the language (which I rub up against in every aspect of my computing endeavours from using the following (shortened list) of items; "ms"'s so called claims that they have an "os", ms-dos, word processors/DTP, video players and editing SW, web browsers, etc., btw) which are that there isn't a mention of maximum string read size or write size. That the sizes are different for both operations. And how can the compiled program be crashing if the string being read exceeds this maximum size even, anyway???


Yes, meant "Read String 1, A$" but couldn't remember the syntax and was too lazy to look it up.... by that I mean that I didn't want to start a 432 megabyte program (DarkBASIC)(which first has to be copied into RAM before it can be run) to be able to write the exact command line.


My problem is that I want to read/write strings to a file that are in the size range of 600 to 4,000 characters and using the read byte command issssss sooooooo slllooooowwwwww, and that's on a 3.4 GHz quad core CPU with 2 SSD hard drives (in RAID 0, therefore striped, which is MUCH FASTER than a single hard drive, 6 gigabits per second transfer on each connector) running the operating system from the SSD and have 32 gigabytes of RAM and it's 1333 MHz and a 1.5 gigabyte video card which is about 880 MHz and a file that fits on a 3.5 inch high density floppy disk, data which is MERELY being read or written grinds the ENTIRE COMPUTER down to below unupgraded Amiga 2000 performance.


My files are about 800K to 2 Megs that need opening and rebuilding to new ones.

If all the "1"s are in the right place, it'll work like a charm.
Latch
13
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th May 2013 07:36 Edited at: 28th May 2013 07:38
There are several ways to do what you want. And you don't have to be bound by limitations in the length of string variables. You can also write your string directly to memory and save all of that at once using memblocks. A similar thing can be achieved using arrays, but you may run into the string length problems that way.

Here is a loose version I put together that shows a way to use memblocks (blocks of memory) to store your strings and then write them all to a file at once. The example create a file about 2 megs in size filled with string data. I use individual strings to write to the memblock so there is an initial limit on how much can be written at once - but it's easy to loop through the functions to get it all done and contiguous. To write 20,000 strings to the memblock - each 100 bytes in length and then save the file takes about 2 to 3 seconds on my laptop. Once the file is created, it's really just one long string because I don't add any line feeds or carriage returns (intentionally). This is darkbasic classic I'm using so I think it should work in pro - I don't think the commands I used are too different. If it does work, it should be even faster in pro.



The idea is, the tools are available to manipulate stuff the way you want. There is a lot to learn about DB. I've gotten used to it and (using classic) I feel like I can do just about anything I need to with it. It's one of the better BASIC's in my opinion. I will admit, it's default file and string handling isn't the greatest.

Enjoy your day.
Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 11th Jun 2013 16:56
Quote: "I remember and miss the "good old days" where, you type some code in, run it, and it runs, start a new program, and indeed, THAT program runs. I'm almost ready to just throw in the towel on this as, well, I just can't get things to work, as in, type in commands, and they run. Save a program, and it gets saved."

There is a trick with Indigo where after you click NEW PROGRAM and the save window pops up just click cancel and you will get an empty file called "Untitled" that will compile and run in a temporary save file. You should get a blank file when you first start up that you can use the same way too.
I sympathise with your annoyance at all this "project" nonsense, that's why I still use DBC a lot of the time, it's so nice to be able to just throw some code at it.

The difficulty in learning is not acquiring new knowledge but relinquishing the old.
Silverman
12
Years of Service
User Offline
Joined: 18th Jan 2007
Location: France
Posted: 12th Jun 2013 19:27
hi Sequence,

I'm not sure I understood everything, because the English language is a bit difficult for me to understand.
Want to make a file to initialize your array, but you're limited by the size of the string? Is that correct?
For this, there are a couple of command: save array / load array
For quick load file, you can use MemBlocks as mentioned previously Latch.
Another example of memblock use(from DBC help)


DirectX 9.0c (February 2010)/ DBClassic v1.20
Libervurto
13
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 13th Jun 2013 08:36
I had a go at translating your comments.

This is actually a nice way to learn a language because you associate the words with processes.

The difficulty in learning is not acquiring new knowledge but relinquishing the old.
Silverman
12
Years of Service
User Offline
Joined: 18th Jan 2007
Location: France
Posted: 13th Jun 2013 12:46
Thank you !

DirectX 9.0c (February 2010)/ DBClassic v1.20

Login to post a reply

Server time is: 2019-09-23 03:45:19
Your offset time is: 2019-09-23 03:45:19