I am writing a script in SuiteScript 2.0 where I pass a function to a different module to use, in order to decouple functionality between the two. The functions of the modules seem to work fine together but when I call search.create on an ad-hoc saved search I got "Cannot find function _marshal in object [object Object]" error, I have no idea what this is. I tried passing in the scope using call and that had no affect but the shared functions between the modules are fine. Any help with this would be greatly appreciated. thanks
I also received this error using a search.create, but it was because I was passing in an object instead of a single value for the internal ID.
Apparently, the loading of multiple common modules like search etc, was causing the problem. By centralizing the access to the different modules seemed to have stopped the error. Also, side note, by getting rid of global objects like shared arrays between the modules seemed to make the code run quite a bit faster.
Related
When I am creating a NodeJS module to be exported, the module object is not recognized. Is there a way to get this module object ot be recognized. I looked under the Settings&Framworks > Node and that appears to be correct. Although I can't seem to keep the "Coding assistance for Node.js" checked (it keeps clearing the 'check')
I looked through IntelliJ's Reference Material Here
I actually may be coding incorrectly as well, perhaps I'm not supposed to hook into this 'exports' object in this manor.
Advice and guidance appreciated.
First this question is very similar to This Question
First I went to the settings (Ctrl-Alt-S) and
'Language & Frameworks' > JavaScript > Libraries
Then I hit the Download button till I found a bunch of node libraries. I figured this was a very 'basic' node object so I used the plain 'node' libary.
Then the #types/node was present for me to enable
I've been toying with this all day to no avail so far. I've been using chartjs-node with no issues but I can't even load chartjs-chart-financial.
I've built the library and even used their pre-provided one (https://github.com/vmpowerio/chartjs-node), but whenever I require() the file, it throws errors such as:
Window is not defined
Chart.Ticks is undefined
These errors are on the loading of this file, not even the execution of the function.
I can't seem to figure out what's wrong and all my workarounds aren't getting anywhere. I feel like I'm missing something right in front of my face, too.
My program has a very specific error that took me a while to track down - now I don't know how to fix it. My code is very long and in many files and I don't see much point in posting it here.
In the IDE, everything runs fine, in both Debug and Release (with the runtime library set to either /MTd or /MT, respectively, so I'm assuming all dependencies are included).
However, when I run the standalone, I get a crash. At first I thought it was a dependency problem but it doesn't seem so.
At some point in the code, I am accessing a vector via a method call: t->GetList(), where GetList is defined as std::vector<T*> & GetList() and the method simply returns a member variable (simply defined as std::vector<T*> field in the class).
It turns out, if I print out the size of the list while running from the IDE, I get 0 (which is the correct answer in this case).
However, when doing the same thing running from standalone, I get the size as 467467353.
I tried changing the method declaration to std::vector<T*> * GetList() and doing return &field; and updating the rest of the code but this didn't fix anything.
I then tried replacing the member variable field with a pointer, and in the constructor instantiating a new vector and deleting it in the destructor. Still no luck.
So I made a simple test case program that simply made a class with a vector field, and a method to return a reference to it. Then in main I would create an instance variable and getting the vector and printing the size. This worked both in VC++ and as a standalone - both returned zero.
This is driving me nuts and I can't figure out why I'm getting different behaviour. Why is the standalone running differently, and what should I be looking at to fix this?
Thanks
Okay so it was literally a bug in my code that was very well hidden. I was dynamically casting to a wrong type.
Somehow it slipped past when I was running on Windows and OSX in both Debug and Release, and as a standalone on OSX. Good thing I found it.
I have an erlang program, compiled with rebar, after the new debian release, it won't compile anymore, complaining about this:
-import(erl_scan).
-import(erl_parse).
-import(io_lib).
saying:
bad import declaration
I don't know erlang, I am just trying to compile this thing.
Apparently something bad happened to -import recently http://erlang.org/pipermail/erlang-questions/2013-March/072932.html
Is there an easy way to fix this?
Well, -import(). is working but it does NOT do what you are expecting it to do. It does NOT "import" the module into your module, nor does it go out, find the module and get all the exported functions and allow you to use them without the module name. You use -import like this:
-import(lists, [map/2,foldl/3,foldr/3]).
Then you can call the explicitly imported functions without module name and the compiler syntactically transforms the call by adding the module name. So the compiler will transform:
map(MyFun, List) ===> lists:map(MyFun, List)
Note that this is ALL it does. There are no checks for whether the module exists or if the function is exported, it is a pure naive syntactic transformation. All it gives you is slightly shorter code. For this reason it is seldom used most people advise not to use it.
Note also that the unit of code for all operations is the module so the compiler does not do any inter-module checking or optimisation at all. Everything between modules like checking a modules existence or which functions it exports is done at run-time when you call a function in the other module.
No, there is no easy way to fix this. The source code has to be updated, and every reference to imported functions prefixed with the module in question. For example, every call to format should be replaced with io_lib:format, though you'd have to know which function was imported from which module.
You could start by removing the -import directives. The compilation should then fail, complaining about undefined functions. That is where you need to provide the correct module name. Look at the documentation pages for io_lib, erl_scan and erl_parse to see which functions are in which module.
Your problem is that you were using the experimental -import(Mod) directive which is part of parameterized modules. These are gone in R16B and onwards.
I often advise against using import. It hurts quick searches and unique naming of foreign calls. Get an editor which can quickly expand names.
Start by looking at what is stored in the location $ERL_LIBS, typically this points to /usr/lib/erlang/lib.
What is a good strategy for stopping a requireJS module from loading from information you won't know until run-time?
The scheme I came up with involves using a loader plug-in that checks some run-time attributes and checks the "protected" modules against their attribute lists, and if they're not supposed to load, doesn't call load() from inside the loader plug-in load() function. However, this results in a browser error, which in older versions of IE, cause actual script errors, which is not what I want/need (it's actually a time-out error because load() is never called).
Is there a way to say, "Yeah, I got that you wanted to load this, but, um, we don't want to, and that's not an error, so go about your business with the rest of your loading business." Or perhaps a better scheme to achieve what I want?
I solved this by doing load(null) and checking for null in the places where the module that could possibly not be loaded is referenced.