I come from C-family "mainstream" langages and i'm currently giving a try in Lua .
I made a simple code that check for a user entry and try to open an URL (built with user entry) in the default browser.
Saw the command os.execute("start "URL") that failed, saying that "os is undefined".
Well, seemed to be logical. I then researched the reason and discovered the "require" key word (which seems to act as a LoadLibrary or kind).
This is where I'm lost !
All forums says "yeah yeah just add require os and it will do". But it actually fail !
I obviously suspect that i am missing a "file" or path pointing at that "os" description. And that it's so obvious nobody found useful enough to explain or ask for it.
Can someone explain me what does require, in details ? Which file am i supposed to add (if i really need to ?).
If someone also have an online lesson to advise me, i'll accept it with pleasure. I feel like i'm missing a lot of basics and that's really not a "try to step-up" friendly langage
The standard Lua environment has os available without using require, so you must be using a non-standard Lua environment.
When Lua is embedded into different software, access to libraries like os is usually removed, as it is a security risk. (For example, if you allowed full access to the os library to anyone using Lua on a webserver, it would mean that anyone could run random shell commands on that server.)
If your Lua environment has been altered in this way, then there is a good chance that you will never be able to use the os library whatever you do.
Related
I have a lua project with lua files specified in multiple directories all under the same root folder with some dependencies.
Occasionally I run into issues where when a table is being loaded at load time I get a nil exception as the table is referencing a not yet initialised table, like:
Customer =
{
Type = CustomerTypes.Friendly
}
Which causes a nil exception for CustomerTypes as CustomerTypes.lua has not yet loaded.
My current solution is to simply have a global function call in these lua files to load the dependency scripts.
What I would like to do is pre-process my lua files to find all dependencies and at run time load them in that order without needing function calls or special syntax in my lua files to determine this (i.e. the pre-processor will procedurally work out dependencies).
Is this something which can be realistically achieved? Are there other solutions out there? (I've come across some but not sure if they're worth pursuing).
As usual with lua there are about 230891239122 ways to solve this. I'll name 3 off the top of my head but I bet I could illustrate at least 101 of them and publish a coffee table book.
First of all, it must be said that the notion of 'dependencies' here is strictly up to your application. Lua has no sense of it. So this isn't anything like overcoming a deficiency in lua, it's simply you creating a scripting environment in your application that makes you comfortable, and that's what lua's all about.
Now, it seems to me you've jumped to a conclusion that preprocessing is required to solve the given problem. I don't think that's warranted. I feel somewhat comfortable saying a more conventional approach to solving the problem would be to make a __newindex metamethod globally which handles the "CustomerTypes doesnt exist yet" situation by referencing a list of scripts which have been scanned out of the filesystem initially for one called CustomerTypes.lua and running that.
But maybe you have some good reason for wanting it done strictly as preprocessing. In your case, I would start by considering 'dependencies' to be any name which is a script found in your scripts filesystem. Then scan each script to look for the names of dependencies using the definitions/list you just created, and prepend a load(dependency) command to each of those scripts.
Since the concept of "runtime" or "preprocessing" is somewhat ambiguous in this context, you might mean at script-compile-time. You could use the LuaMacros token filters system to effect a macro which replaces CustomerTypes with require("CustomerTypes.lua") or something to that effect after having discovered that CustomerTypes is a legal dependency name.
I am new to Pure Data and have no idea why the following are displayed after I clicked help:
I am using Windows 7 and pd-extended 0.43.4.
This error (xy ...could not crate) means that this abstraction or external failed to instantiate. It could be that you don't have it installed, or it is not in Pd's search path so it can't find it. In the patch you are opening those objects seem to be used. In your case that might be the help file.
This is an answer on the pd forum by user whale-av already,
whale-av:
[midiin] and [sysexin] are not supported in windows. Some people have written patches to get around the lack of sysex, and instead of midiin you can use [ctrlin] [notein] etc.
[powtorms~] [mstopow~] do not exist as far as I know even in vanilla for windows, and in the windows extended 0.43.4 release they do not. I remember seeing that they were in a Linux vanilla build, and in a very old Pd build for XP.... so you might be able to find them......... someone might have built them as an external that you could add to your pd/extra folder and then use them like any other object. If you have opened someone elses patch then it is possible that they used those objects in that patch, but you do not have them so they will not "create" and will just show the name in a red dotted box instead of a solid black outline.
[scalar] does not exist, but [scalar-help] does and that explains how to use scalars....... which use other objects but not [scalar]
So, basically, not all objects exist in all versions of Pd, and certainly not under all operating systems.
I'm trying to add a .mo file for en_US translations but I keep getting this error:
Updating the catalog failed. Click on 'Details >>' for details.
And the content is:
execvp(xgettext--force-po, -o, /tmp/poeditf0AcvR/0extrated.pot <...> ) failed with error 2!
You know what's a much better place to report problems with applications you use than SO? As a rule of thumb, its developer is best able and most qualified to help. It's a good idea to provide relevant details, too (this evergreen is worth every second spent reading it, please do: http://www.chiark.greenend.org.uk/~sgtatham/bugs.html), such as version of the app, your platform, specifics of what you're actually doing ("add a .mo" isn't quite as descriptive as it could be).
Seeing that Poedit is apparently trying to launch a program named xgettext--force-po, which quite obviously doesn't exist, my blind guess would be that you went to Poedit's preferences, messed with the settings for whatever extractor you use for this and accidentally removed a space after xgettext from the extraction command in there.
Remove the extractor, quit Poedit and let it recreate it.
I am trying to use the file:open(....) function in erlang but it doesn't seem to work. I keep getting an {error, eio} exception.
Ive looked into it in the erlang documentation and all i have found is that it is the posix error for input/output... go figure.
The file name im outputting in is in the formation of "C:/directory/file.txt"
Im not sure if this has something to do with it.
Is there anyway i can make erlang give me a more specific explanation to what is wrong?
Thanks,
Jack
Unfortunately I do not know of a way to find out more without peeking inside the Erlang/VM.
If you look in the windows erlang source code there are a bunch of different errors which could cause en eio error. You can find a list of them here. In order to figure out which specific one it is, I would attach with windbg and step through the code as instrumenting and recompiling it on windows is a pain.
You might also be able to use something like Process Monitor to find out which system calls are being made and what they return.
I'm trying to write a little python application, and to start i simply drop the .py into the device and execute from there.
Now I am at the point where i probably need some credentials for accessing the tracker.
I dont want to create an aegis manifest at this point, since im still in early development, or in the worst case i would like to create a flying manifest for my script and thats it.
I found out (actually in the nokia sdk docs) that what i need is something called aegis-su (in aegis-dss-tools) or aegis-manifest (for the worst case), from aegis-manifest-dev
problem: i searched all google, and i cannot find these packages anywhere..
can someone help me?