"ls" or "dir" command in Monkey for all targets?
Monkey Forums/Monkey Programming/"ls" or "dir" command in Monkey for all targets?
| ||
Hi All, I just thought I'd check, is there a way to get a list of the available files bundled with my Monkey App? I've foudn out about App.data, and loading my data from a *.txt file... I've got >200 files I need to load. Each contains a some data I want to keep track of. I found OS.LoadDir, but then saw in the docs that it only works for GLFW and STDCPP...but now I'm not even sure about that, because when I compiled for GLFW, I got a bunch of warnings, and a memory violation. Wow. (Error below). When i tried to compile for stdcpp, I got this: ----------- TRANS monkey compiler V1.46 Parsing... /Applications/MonkeyPro70b/modules/brl/gametarget.monkey<4> : Error : Native Game class not found. [Finished in 0.1s with exit code 255] ----------- In actual fact, I don't expect this list of files to change between releases of the software, so though it's work I'd rather not do there's no technical reason I couldn't: 1) make a long list of 200+ LoadString commands. (yuck!) 2) strip out all the extraneous stuff, and have it in a single long text file. Would make it easy to load, but would make for a long file. Should I just punt and go for #2 above? -Ken -------------GLFW error------------------ TRANS monkey compiler V1.46 Parsing... Semanting... Translating... Building... === BUILD NATIVE TARGET MonkeyGame OF PROJECT MonkeyGame WITH CONFIGURATION Debug === Check dependencies CpResource data build/Debug/MonkeyGame.app/Contents/Resources/data cd /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -exclude .git -exclude .hg -resolve-src-symlinks /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/data /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/Debug/MonkeyGame.app/Contents/Resources CompileC build/MonkeyGame.build/Debug/MonkeyGame.build/Objects-normal/x86_64/main.o ../main.cpp normal x86_64 c++ com.apple.compilers.llvm.clang.1_0.compiler cd /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode setenv LANG en_US.US-ASCII /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x c++ -arch x86_64 -fmessage-length=0 -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Wreturn-type -Wno-non-virtual-dtor -Wno-overloaded-virtual -Wno-exit-time-destructors -Wformat -Wno-missing-braces -Wparentheses -Wswitch -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-empty-body -Wno-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wno-constant-conversion -Wno-int-conversion -Wno-enum-conversion -Wno-shorten-64-to-32 -Wno-newline-eof -Wno-c++11-extensions -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -fasm-blocks -fstrict-aliasing -Wdeprecated-declarations -Winvalid-offsetof -mmacosx-version-min=10.8 -g -fvisibility=hidden -fvisibility-inlines-hidden -Wno-sign-conversion -iquote /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/MonkeyGame.build/Debug/MonkeyGame.build/MonkeyGame-generated-files.hmap -I/Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/MonkeyGame.build/Debug/MonkeyGame.build/MonkeyGame-own-target-headers.hmap -I/Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/MonkeyGame.build/Debug/MonkeyGame.build/MonkeyGame-all-target-headers.hmap -iquote /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/MonkeyGame.build/Debug/MonkeyGame.build/MonkeyGame-project-headers.hmap -I/Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/Debug/include -I../glfw/include -I../glfw/lib -I../openal/include -I../glfw/lib/cocoa -I../stb -I/Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/MonkeyGame.build/Debug/MonkeyGame.build/DerivedSources/x86_64 -I/Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/MonkeyGame.build/Debug/MonkeyGame.build/DerivedSources -F/Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/Debug -include /var/folders/29/6zgrrd6n619_47s7b_w74d780000gn/C/com.apple.Xcode.501/SharedPrecompiledHeaders/MonkeyGame_Prefix-czpfhbptkykzpkcmywkiidbpkmwa/MonkeyGame_Prefix.pch -MMD -MT dependencies -MF /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/MonkeyGame.build/Debug/MonkeyGame.build/Objects-normal/x86_64/main.d --serialize-diagnostics /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/MonkeyGame.build/Debug/MonkeyGame.build/Objects-normal/x86_64/main.dia -c /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/../main.cpp -o /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/MonkeyGame.build/Debug/MonkeyGame.build/Objects-normal/x86_64/main.o /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/../main.cpp:3281:15: warning: using the result of an assignment as a condition without parentheses [-Wparentheses] if( alcDevice=alcOpenDevice( 0 ) ){ ~~~~~~~~~^~~~~~~~~~~~~~~~~~~ /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/../main.cpp:3281:15: note: place parentheses around the assignment to silence this warning if( alcDevice=alcOpenDevice( 0 ) ){ ^ ( ) /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/../main.cpp:3281:15: note: use '==' to turn this assignment into an equality comparison if( alcDevice=alcOpenDevice( 0 ) ){ ^ == /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/../main.cpp:3282:17: warning: using the result of an assignment as a condition without parentheses [-Wparentheses] if( alcContext=alcCreateContext( alcDevice,0 ) ){ ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/../main.cpp:3282:17: note: place parentheses around the assignment to silence this warning if( alcContext=alcCreateContext( alcDevice,0 ) ){ ^ ( ) /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/../main.cpp:3282:17: note: use '==' to turn this assignment into an equality comparison if( alcContext=alcCreateContext( alcDevice,0 ) ){ ^ == 2 warnings generated. Ld build/Debug/MonkeyGame.app/Contents/MacOS/MonkeyGame normal x86_64 cd /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode setenv MACOSX_DEPLOYMENT_TARGET 10.8 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/Debug -F/Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/Debug -filelist /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/MonkeyGame.build/Debug/MonkeyGame.build/Objects-normal/x86_64/MonkeyGame.LinkFileList -mmacosx-version-min=10.8 -fobjc-link-runtime -framework Cocoa -framework OpenGL -framework OpenAL -framework IOKit -o /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/Debug/MonkeyGame.app/Contents/MacOS/MonkeyGame Touch build/Debug/MonkeyGame.app cd /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode /usr/bin/touch -c /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.build/glfw/xcode/build/Debug/MonkeyGame.app ** BUILD SUCCEEDED ** Monkey Runtime Error : Memory access violation /Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.monkey<53> /Applications/MonkeyPro70b/modules/diddy/framework.monkey<202> /Applications/MonkeyPro70b/modules/mojo/app.monkey<49> {{~~/Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.monkey<53>~~}} +GameDelegate.StartGame;/Applications/MonkeyPro70b/modules/mojo/app.monkey<49> Self:GameDelegate=@7f9a92843800 +DiddyApp.OnCreate;/Applications/MonkeyPro70b/modules/diddy/framework.monkey<202> Self:DiddyApp=@7f9a928436f0 +MyGame.Create;/Users/kcorey/Developer/MonkeySwirls/MonkeySwirls.monkey<53> Self:MyGame=@7f9a928436f0 TRANS FAILED: Error executing './MonkeyGame', return code=65280 [Finished in 6.1s with exit code 255] |
| ||
be sure you're not using an old version of diddy. |
| ||
Hrm...is there a particular reason? Let's see....Hrm...how does one tell? I don't see a version number listed in the root of the diddyhg folder. That said, the file src/diddy/externfunction.monkey has a date of 2 Mar, and src/diddy/tile.monkey has a date of 3 Mar. Is this an old version? -Ken |
| ||
Those warning are not Diddy code... and they are just warnings. The issue is that the build was succeeded but there was a Memory Access Violation within your code. What happens on line 53 of MonkeySwirls? Are you trying to access an image or something that you havent loaded yet? [edit]Just looking at the line numbers: mojo/app.monkey<49> = _app.OnCreate() diddy/framework.monkey<202> = Create() (in Method OnCreate:Int()) Sounds like you arent setting up your app correctly... |
| ||
Ah...that crash was from trying to call a method on an uninitialised object. It didn't really have anything to do with the LoadDir question. Class MyGame Extends DiddyApp Field myGlyphs:Glyphs Method Create:Void() myGlyphs.LoadGlyphs("") '<----- line 53 testScreen = New TestScreen() Speaking of Diddy though, you're the perfect person to ask: Once Diddy is on my disk, how do I tell what version the code is? It comes in a folder called 'diddyhg', I don't see version numbers anywhere in the code...how do I know when it's time to upgrade to a later version? -Ken |