stdcpp - file access
Monkey Forums/Monkey Programming/stdcpp - file access
| ||
First off, why no lone forum for this target!. Anyway... On to my question, I am trying read/write files using the C++ Tool target however using the standard modules it looks like it does not like it. The following code... #Rem Trying to get file reading / writing working in cpp #End Rem 'Make sure its only compiled under C++ #If TARGET<>"stdcpp" #Error "Compile Error: C++ target only supported" #Endif Strict Import brl 'Import os Function Main:Int() Print "*** started ***" Local f:=FileStream.Open("monkey://data/test.txt","r") Print "*** finished ***" Return 0 End generates the following ... main.cpp: In member function 'bool BBDataBuffer::_Load(String)': main.cpp:1573:22: error: 'BBGame' has not been declared main.cpp: In member function 'bool BBFileStream::Open(String, String)': main.cpp:1878:8: error: 'BBGame' has not been declared main.cpp:1879:34: error: 'BBGame' has not been declared According to the documentation (v70f), this should work? |
| ||
Do you need to import monkey? (blind guess) EDIT: Ignore that. just tried it myself and get the same |
| ||
Last time I checked, ever since V67 you've needed to use the BBGame class/system, which isn't available for STDCPP by default. However, you can do what I've done, and edit some of the old V66 code, and use that (If you do this, you'd need to add support for the updates yourself). By the way, what are you using STDCPP for? Sadly it isn't garbage collected, so there's not much of a use for it; right now it's really only useful for things like "trans". You can work off of the target yourself, but then you might as well set up the BBGame functionality, which brings us back to the first issue. I still don't understand why this is forced in V67+, V66's target 'independent' setup was a lot nicer for the BRL module. EDIT: After looking into it a bit more, you may be able to get away with using the default STDCPP target. The "brl.gametarget" module may actually have what you need. |
| ||
I am really just playing around at the moment. My aim is to make a app in monkey that generates a plug in for sublime text. I want it to examine the help files of monkey to create a .tmLanguage file for sublime text (to enable syntax hi-lighting). Yes I am aware that someone has already made one, but as I said previous this is me just playing around. I have a few ideas I want to try regarding this alternative IDE. Hence why stdcpp target is all I need, no user input required. |
| ||
After just adding 'Import brl.gametarget', the module in question has a compile error of 'Native Game class not found.'. |
| ||
Hi! So i thought about this and wanted a bare-bones target to play with as well, so I created this: http://monkeycoder.co.nz/Community/posts.php?topic=5286 Please read the warnings, it's bare-bones but fast. I've added helper functions for garbage collecting, but please note that calling GCCollect will wipe out everything that isn't GCMark() every time you call it. also note that cpptool will not copy anything from the .data folder, so you'll have to keep it local (or use "../myfile.txt"). have fun! |
| ||
Ok, I've fudged around this a little for now - results are up at github/develop. |
| ||
Thanks all, I shall have a poke about and see what happens. |
| ||
*Using the develop branch* My next issue is how to access files at certain locations... Using Local file:=FileStream.Open("test_file.txt","r") Accesses the file in CurrentDir(), this is the .build/cpptool/ folder. Prefixing it with C:\ reports successes however but does not work. Looks like the only way to access files in other locations is to do something like.. Local fp:String="c:\test_file.txt" ChangeDir(ExtractDir(fp)) Local file:=FileStream.Open(StripDir(fp),"r") I guess this is a question about FileStream now and resource types. My question about the above, is how do you access files on the computer? |