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 / Resetting the file read "cursor"

Author
Message
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 31st Mar 2016 18:08
Hi all! Fairly straightforward question for you all. Not sure if it's an available functionality or not, but when I open a file with OPEN TO READ, the "read cursor" starts at the beginning of the file. So if I then use the READ STRING command it will start with the very first line. If I use READ STRING again, it will read the next line, etc, etc (this is a simplified example, but I'm using it to just illustrate this quickly).

Is there a way for me to "reset the read cursor" back to the beginning of the file again to "re-read" previously read lines of the file? I know I can do it by closing the file and re-opening it again, but if possible I'd like to do it without having to go through that.

Hopefully I'm making sense with this. It's 3am and I've been coding all day hahaha

Any help would be awesome. If you need more info or have no idea what I'm on about, let me know and I'll try and clarify. Thanks in advance!
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 31st Mar 2016 20:43
Are you using IanM's Matrix1 utilities? If you are then it might be worth looking at his DATAFILE commands which might enable you to do this sort of thing.


Powered by Free Banners
Attila
FPSC Reloaded TGC Backer
19
Years of Service
User Offline
Joined: 17th Aug 2004
Location:
Posted: 31st Mar 2016 21:44
close and reopen the file, open will always set the pointer to the beginning of a file
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 31st Mar 2016 22:02
Attila, I think you missed this bit of his post:

Quote: "Is there a way for me to "reset the read cursor" back to the beginning of the file again to "re-read" previously read lines of the file? I know I can do it by closing the file and re-opening it again, but if possible I'd like to do it without having to go through that."




CumQuaT, On second thoughts I suspect the DATAFILE solution will require a fair bit of rewriting your code - but only you can judge.


Powered by Free Banners
Derek Darkly
12
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 31st Mar 2016 23:42

You could put the read results in an array, which would automatically hold the line number, and then re-read them conveniently from the array instead of the file.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Apr 2016 00:29
Yes, I wondered about that - but didn't suggest it because I suspect the files might be very large. Only CumQuaT knows whether that is likely to be an issue. If size is not a problem then I agree with you.


Powered by Free Banners
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 1st Apr 2016 01:43
You're spot on, Green Gandalf. The files are pretty hefty, so dimming them out would be a bit of a hit on the ol' memory banks. It's odd, you'd think this kind of thing would be pretty standard...

I'm actually only requiring this functionality for one specific part of my program, so re-writing it to use the MATRIX1 stuff might be fesable... Now I just need to dig up the how-tos... Haven't seen them for a looooong time!
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 1st Apr 2016 02:18
Hows the game development going? What's new?

If RAM permits, convert the file to a memblock using make memblock from file; then access the data rapidly and directly

It is a shame the SKIP BYTES command does not allow skipping back a number of bytes.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Apr 2016 12:12
Quote: "If RAM permits, convert the file to a memblock using make memblock from file; then access the data rapidly and directly"


Sounds worth a try.

Quote: "It is a shame the SKIP BYTES command does not allow skipping back a number of bytes."


Indeed.

Quote: " It's odd, you'd think this kind of thing would be pretty standard."


It is - in other languages I've used.

Quote: "The files are pretty hefty, so dimming them out would be a bit of a hit on the ol' memory banks."


What happens when a file is opened to read? Is it loaded into memory so that you'd end up using about twice as much if you also read it into an array? Would Chris Tate's method bypass this doubling? Or is it not an issue? This sort of behind the scenes stuff is a mystery to me.


Powered by Free Banners
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 1st Apr 2016 13:29
Quote: "Hows the game development going? What's new?"


I'm amazed there are still people here who remember my dinosaur of a project hahaha it's coming to a close finally, thanks for asking! A big memory limit issue has been throwing a massive bloody spanner in the works in the last leg where DBPro projects can only have so many lines of code in them before they won't compile anymore. I've ever tried working with precompiler code and such to get things working but without much avail (precompilers fix the data limit issue but make the final EXE unstable as all hell for the end-user) so in the end I wrote a little script decoder into the code and am now outsourcing large swathes of code into external script files which I then read in through the decoder and getting it to work that way. Crazy? Yes. Working? Also yes. At this point after 5 years, to run into something like that was pretty emotionally devastating, so I'm doing whatever I can to get around it. But so far I'm managing and things are back on track to my finishing the project once and for all. I'm just around the corner from pushing out the second-to-last major update before the game is finally done.

Quote: "If RAM permits, convert the file to a memblock using make memblock from file; then access the data rapidly and directly"


That's a valid idea, certainly... I might end up having to do just that.

Quote: "It is a shame the SKIP BYTES command does not allow skipping back a number of bytes."


I had that same thought and even went to try it with no avail. Kinda makes sense that it should work!

Quote: "What happens when a file is opened to read?"


Surprisingly not too much with just a little script file of a few dozen KB. The issue is DarkBASIC's ability to rapidly process opening and closing files in quick succession. Thus far, if it's only ever a READ operation it seems stable enough, but I've had problems before with this same issue and WRITE operations, so I figured I should probably get a head start on any potential issues and ask the experts for a way around it just in case hahaha
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Apr 2016 16:23
Quote: "ask the experts for a way around it just in case hahaha"


I think they left the forum some time ago.


Powered by Free Banners
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 1st Apr 2016 17:00
But you're still here, Green Gandalf!

It's been a shame reading about how DBPro is kinda being killed off as such. I hope this open-source movement takes off. I'll be honest, I haven't had the time to keep up with where it's all going.

Even though I was a part of initial testing on the AppGameKit I've only recently started dabbling with it and I do enjoy it a great deal, but nothing quite beats DBPro for me. I guess I'm just a fan-boy. There's a lot of things I'd like to see added, but hopefully it'll get there if this does get handed back to the community at large and not just die in the shadows somewhere after all the great things it's done... And it HAS done great things!

I was around back when it really took off. I'd hate to be here to see it fall
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 1st Apr 2016 17:50
Good to see you overcame the limitations. Scripting is definately a good for DBP. PhysX APIs and similar plugins also helps reduce length of code and number of CPU recursions. I am using more than one EXE to help reduce limits on RAM and CPU usage, since not every function has to run in the same program.


Anothing thing, please, if you have not done so already, spare a moment to check out the DirectX 11 plugin being developed if you find some time; this plugin is quite an exciting prospect and needs some support to motivate and facilitate its development. It should become a great way to provide more detailed video options for your players and any future concepts you have in mind.

Good day, keep doing your thing.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Apr 2016 18:07
Quote: "It's been a shame reading about how DBPro is kinda being killed off as such. I hope this open-source movement takes off. I'll be honest, I haven't had the time to keep up with where it's all going."


Yes, I get the distinct impression it's being deliberately killed off despite the flag waving suggesting the contrary. I'm struggling to get up to speed with the open source version too. No idea what a total newcomer wold be expected to do with it.

Fortunately the pre open source versions are still available - but only if you know where to look. It all looks like a clumsy change of direction by TGC to me - and a rather disheartening one at that.


Powered by Free Banners
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Apr 2016 18:17
Quote: "Anothing thing, please, if you have not done so already, spare a moment to check out the DirectX 11 plugin being developed if you find some time; this plugin is quite an exciting prospect and needs some support to motivate and facilitate its development. It should become a great way to provide more detailed video options for your players and any future concepts you have in mind."


Seconded.

I looked at that Plugin some time back and was impressed. A quick glance just now suggests another, more detailed, look is called for.


Powered by Free Banners
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 1st Apr 2016 20:54
Quote: "
Yes, I get the distinct impression it's being deliberately killed off despite the flag waving suggesting the contrary. I'm struggling to get up to speed with the open source version too. No idea what a total newcomer wold be expected to do with it.

Fortunately the pre open source versions are still available - but only if you know where to look. It all looks like a clumsy change of direction by TGC to me - and a rather disheartening one at that."


Off topic but here here! Also glad to see you posting once more; would you enlighten me as to how to look and where please so I can make a note of it ?
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Apr 2016 23:09
Quote: "would you enlighten me as to how to look and where please so I can make a note of it ?"


The various upgrades are still available via IanM's DBPro release details sticky on the Bug Reports board. The second post on that thread contains all the links - but they are all wrong. For example, the link Patch2 directs you to the non-existent page

http://files2.thegamecreators.com/darkbasicprofessional/upgrade/dbpro_upgrade_2.zip

whereas the correct page is

http://files.thegamecreators.com/darkbasicprofessional/upgrade/dbpro_upgrade_2.zip

As far as I can see just change the reference to "files2" to "files" in each link and everything works fine. I don't recall which thread here told me what to do but it was a fairly recent one.

Offtopic again, but have you got the open source version working? I haven't got a clue where to begin. I've downloaded a massive ZIP file containing loads of Visual Studio C++ projects and am baffled.


Powered by Free Banners
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 2nd Apr 2016 00:25
Thanks for that appreciate it. In the open source download there is a folder named "Install". Just stick it where you want it. Run the Launch.exe as normal - though you may have to add admin rights as I had to on Win10. Once the editor is open go to Tools>Options and it should open up where you can see the option to select a directory for the compiler. Think all I had to do was either add the directory for the compiler folder or I just deleted the entry already there and left it blank - can't remember which, I suspect I did both ways as I have reinstalled recently several times due to computer gremlins then finally having to get a new machine altogether In any case I have a weird set up as I use Indigo as well as having each upgrade version that I could find installed separately alongside one another - something which I picked up on from one of your posts I think).

In any case I was as baffled as you when I looked at it - only because I once watched my mate mess about with getting Unreal 4 compiled did I spot the "Install" folder as out of place that I then saw a familiar layout of DBP installation. Not exactly what a newbie would get working if they saw it which to me is only going to put folks off at stage one if they know absolutely nothing of coding! Heck on the DBP facebook page there's a nice chap who can't figure out what's wrong with his internet connection not working and he was asking about it.

User seppgirty did it another way which looks simpler and made a video on the Newcomers board. https://forum.thegamecreators.com/thread/216772

It really is quite fast from what I can tell(compiling), only plugin I have tried that works is Newton Physics(vehicle and fps demo's only), since I down loaded it Lee has uploaded Dark Physics V1 which should work, never tried it though as I was disappointed with it when I bought it, think I felt the car physics wasn't up to scratch and some things I read in forum mentioned that various things didn't work, can't remember as it's years ago(fps control maybe?). The all important Matrix1Utils however did not work "out of the box" but Rudolpho pointed out in the DX11 thread after I mentioned the issue that it probably wouldn't break any rules if we edited the string table to fix it - have a good read of it in WIP board(I went off topic on there as well lol but for good reason), haven't got round to actually trying that out though as that's when gremlins got my machine.


CumQuaT I do apologise for being so off topic. I just bought my first solid state drive so I will be following your path so to speak as I want to see whether load on demand is feasible at some point
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Apr 2016 16:39
*** Still off-topic I'm afraid. Sorry CumQuaT. ***

Quote: " In the open source download there is a folder named "Install". Just stick it where you want it. Run the Launch.exe as normal - though you may have to add admin rights as I had to on Win10. "


Couldn't find those so I tried unzipping the download again and, "Lo! And Behold!" there they were. No idea what went wrong before. I did get some dire warnings about filenames being too long and couldn't unwrap this or that - but I chose to ignore those for the time being. When I launched the open source version Norton intervened and said it was preventing DBP(OS) from connecting to the internet. I chose to ignore that as well and everything seems fine. The only difference I've noticed so far is that the exe files are smaller. Haven't done thorough testing yet - but thanks to you I can now get started.

Not sure yet whether there is some sort of interaction between the two versions, i.e. if I launch the Open Source version and open a project located in my old DBPro folder does it compile using the open source DLLs or the old DBPro DLLs?

I've noticed one oddity though. The Help/Dark Basic Professional version says 1.071 in the Open Source copy and 1.077 in the "old" DBPro. Where has the 1.071 come from???


Powered by Free Banners
James H
17
Years of Service
User Offline
Joined: 21st Apr 2007
Location: St Helens
Posted: 2nd Apr 2016 19:41
I had not even noticed the .exe file size difference! I did have the same concern regarding whether there is any interaction between the two versions but thought at the time I will have to get to testing it somehow, but then noticed that the Indigo editor uses the DBP directory path rather than look specifically for the compiler. This I found suited me best - in my TGC folder the old version is labelled as "Dark Basic Professional Online". So what I used to do I simply carried on doing - I add the version number to the name "Dark Basic Professional Online" and simply keep a text file in the TGC folder which I then make a note of which version I am currently using. So the folders within TGC directory look something like this:
Dark Basic Professional Online U6.x ....and so on
Dark Basic Professional Online U7.x ...and so on(some are name U7.xRCx as I also had all betas installed)
Dark Basic Professional Online Free version U7.5 ...this is the free version of the older compiler that TGC used to provide which they have now replaced with the open source version
Dark Basic Professional Online GameGuru ... this is the open source newer compiler previously name "Install"
So when using a particular version I rename the folder to read "Dark Basic Professional Online" using Ctrl+x to remove version info and then Ctrl+v into the text file I just mentioned so as to keep track. As the Indigo editor is 3rd party and only requires the install path rather than a compiler path, there is no confusion as to which version it is using as it will simply use the contents of "Dark Basic Professional Online" folder I gave it, so I have set just the DBPro files for association with Indigo when opening a project from the project file - I prefer to open dba files in the oldest editor so that the file icon is different, this helps me as I find it visually easier to find the project file if there are lots of dba files in same place as my eye sight gets more blurry as the day progresses.

I used to believe the version info oddity is an editor issue - similar issue crops up with the oldest editor with older versions of DBP being reported incorrectly from what I recall - but then this newer compiler came along and Indigo also reports 7.1 which confuses me. I do seem to remember that the newer compiler originally had to be reverted back to an earlier version of source code before they branched out into creating a faster compiler(for whatever reason - I don't recall), but as this has replaced the older free version which was U7.5 I did expect it to be U7.5 also. I based that on the logic that the older free version was the last version that worked without issues, which also confused me as I had thought U6.9 was the last good version without additional issues! So chances are it is indeed U7.1 that your looking at. Another user(Kuper I think) did mention recently that it can be upgraded normally but this may well only achieve the older compiler version with god knows what differences or further bugs might have been introduced by doing so.

To further add to the confusion you may have noticed by now that for those of us with purchased version of DBP and plugins, we are still waiting for our activation keys to be brought forward from the old websites system to this new one(3 months now!), and so in the time being there is a new activator to download, or so it seems, I checked it out a few days ago, its a blatant lie!!!! It is merely a link to download - wait for it - the compiled version of the open source kept separate from the visual studio project, you know the one that would have been better placed on the product page for new users rather than to confuse the crap out of them by linking them to download the entire lot as both yourself and I have done. It may be the case that it can be updated normally and maybe even works for removing the need to activate plugins once updated to whatever update we choose, but it doesn't account for updates 6.8, 6.9 or 7.0, we are stuck with 7.1 onwards and doesn't even come with some basic instructions! I am not convinced that this hap hazard way of thinking would not introduce bugs by simply overwriting existing installations from our accounts - and I feel like I am being looked upon as an idiot into being tricked to thinking that overwriting one full installation of older DBP with the entire new compilers full version is risk free of breaking older projects. Why provide the original purchased DBP in our accounts along with a message indicating activation keys are on their way if all we are going to do is overwrite all the files with the newer compilers version?! They should have left things as they was in terms of availability, updated the rest of the site and simply added the open source new compiler as an extra option - I think they are trying to move away from the on line key activator, maybe once this new site is finished they will just turn it off but to me that means all those plugins we bought that still require security as the owners haven't given them permission to make them available for free and/or open source, well all it takes is for someone who paid for them to make them available on say a torrent site. I have noticed that someone sold their products as "second hand" on the DBP facebook page, existing customers may be folk who wouldn't pirate products in such a way but all it would take is one of them to change their mind or sell second hand to someone who might do so. The way this has all been done seems somewhat dodgy to me, hide the risk by complicating a process is what it looks like to me.
Green Gandalf
VIP Member
19
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Apr 2016 20:13 Edited at: 2nd Apr 2016 23:29
Yes, the presentation of DBPro Open source leaves a lot to be desired. I've just got two folders: Dark Basic Professional and Dark Basic Professional Open Source. I've done some more testing and no further oddities have arisen yet. I do need to be careful when opening a project from File Explorer though - at the moment that process is associated with the old version not the Open Source version even if the project is in the Open Source folder.

As usual you need to know what you are doing I suppose ...

[That comment particularly applies to me, sadly - as evidenced by my recent posts on Rudolpho's DX11 Plugin thread. ]


Powered by Free Banners
CumQuaT
AGK Master
13
Years of Service
User Offline
Joined: 28th Apr 2010
Location: Tasmania, Australia
Posted: 4th Apr 2016 04:06
hahaha hijacked!!!!

Hey James H!

Login to post a reply

Server time is: 2024-04-27 03:39:56
Your offset time is: 2024-04-27 03:39:56