Text comparison in Dynamics Nav "C/AL" - dynamics-nav

I would like to know if a text ends in '0000' in C/AL code, but I am not sure if I am doing something wrong or the documetned functions simply are not prensent in the version of NAV I am using (NAV 2016). String Functions in NAV
In any case I would like to know how can I do this if it's not with this functions.
Text.ENDSWITH('0000'); // Does not compile,
//no autocomplete for the ENDSWITH function either

Article you are referring to is about AL - the language for developing extensions for Nav 2018 and Dynamics 365.
Here is the link you’re looking for https://learn.microsoft.com/en-us/dynamics-nav/text-data-type
No ENDSWITH analog though. You can use COPYSTR or DELSTR to simulate it.
Alternatively you can use .Net variable of type System.String to get access to all string functions of C#. C/AL’s text is assignable to .Net’s string.

you can use something like this:
IF COPYSTR(TheText,STRLEN(TheText)-4) = '0000' THEN

Related

Xtend: evaluate expression directly from a string

Is there a possibilty in the Xtend language to evaluate an expression directly from a string, e.g. like Eval in Groovy. I want to do something like this in Xtend (the example is from Groovy):
import groovy.util.Eval
assert Eval.me('2*5') == 10
If there is no built-in way to do this, what would be the most similar alternative to achieve this (if any)?
P.S. Just to be clear: the expression is of course not just a simple math operation (like in the example); in particular, I would like to call my own Xtend function doing some transformation on a list.
I think there isn't anything like this in Xtend, so you should probably look for Java libraries that do this.
For example Java EL seems like a good standard way for evaluating strings. Since EL 3 there is the ELProcessor which doesn't require JSP anymore and it seems quite easy to use:
ELProcessor elp = new ELProcessor();
elp.defineBean("employee", new Employee("Charlie Brown"));
String name = elp.eval("employee.name");
Here is nice article about the latest features of EL, like lambda expression. The article also contains some examples about collections and how to call external methods.

Track C variable doxygen

New to Doxygen and wondering can it be used to draw a graph showing what functions use a given global variable. I have been able to get call/caller graphs working for functions and want to do something similar for a hand full of variables.
REFERENCED_BY_RELATION = YES: In a Variable description it documents all functions which have used the variable and generates a hyperlink to these functions in the code. In the function documentation, this documents all functions being used in that particular function and also generates a hyperlink to the actual code.
REFERENCES_RELATION = YES: In a function documentation, this documents all functions that have called the function being described and also generates a hyperlink tot he code.
Although this is not a graphical solution (which would be way better), this is something one can definitely work with.

How to use phloc schematron-pure with Document -schema-definition

This question concerns phloc-schematron, a library for ISO Schematron validation.
I am creating schematron-files on the fly, so I have them available as document (or as string of course)
I cannot find a constructor for SchematronResourcePure that takes a string or document as argument, nor can I find a method to create a IReadableResource from the same.
Can someone suggest how to do this?
In case this is still relevant:
Switch to ph-schematron at https://github.com/phax/ph-schematron/ and use the static SchematronResourcePure.fromString method.
But you are right - this is a case that is currently not considered - building the Schematron from scratch. I will see, what I can do!

Eclipse - How do I view java arrays / collections better in debugger

Viewing/Searching java arrays and collections in the Eclipse Java debugger is tedious and time-consuming.
I tried this promising plugin (in alpha as of Aug 2012)
http://www.cvast.tuwien.ac.at/projects/visualdebugging/ArrayExplorer
But it freezes Eclipse for simple arrays beyond a few hundred elements.
I do use Detail formatters, but that still needs clicking on each element to see the values.
Are there any better ways to view this array/collection data?
Use the 'Expressions' tab.
There you can type in any number of expressions and have them evaluated in the current scope.
ie: collection.size(), collection.getValueAt(i), ect...
Eclipse > Preferences > Java > Debug >Detail Formatter
This may be close to what you are looking for. It is another tedious work to setup but once done you can see the value of objects in Expressions window.
Here is link to start
override toString method of your class and you will be able to see what you want to see. i'm attaching example to show you exactly that.
Even though i could not find a way to see them in nice table/array, i found a halfway workaround.
The solution is to define a static method in a throwaway class that takes the array as input and returns a string of concatenated values that one wants to quickly glance at. it could include the array index and newlines to view results formatted nicely. It can be fine tuned to print out only certain array indices to reduce clutter.
This static method can then be used in the watch area.

Using Windows Forms and VC++ with Unmanaged Static Libraries

I am currently trying to write a UI for a Data Acquistion System in Visual Studio C++ 2010, and I am having a lot of trouble dealing with the interfacing of the third party libraries I am using and Windows Forms. The two libraries I am using are DAQX, a C library for a Data Acqustion System, and VITCam, a C++ library for a 1394 High Speed Camera. It's extremely frustrating trying to work with these libraries and any UI library that VS has to offer, as none of the function arguments ever get along.
DAQX uses windows types like WORD and DWORD, in normal C fashion, and when I'm writing a normal program, no UI involved, it works fine, but Windows Forms seems to hate anytime I want to make a simple DWORD Array inside the class.
VITCam is even worse. I can open the camera fine, but I am completely lost when it comes to trying to put the image on the screen somehow. I haven't uncovered an equivalanet, easy to follow way for putting it to the screen as to how the documentation puts it:
CDC* pDC=GetDC(); // obtain the device context for your window...
// move the image data
::SetDIBitsToDevice(pDC->m_hDC,0,0,
(int) (MyCam.GetDispBuf()->bmiHeader.biWidth),
(int) (MyCam.GetDispBuf()->bmiHeader.biHeight),
0,0,0,(WORD) (WORD) MyCam.GetDispBuf()->bmiHeader.biHeight,
MyCam.GetDispPixels(),MyCam.GetDispBuf(),
DIB_RGB_COLORS);
I can barely follow it as is. So, without doing to much blathering, How do most people work with static unmanaged libraries that were not developed with Windows Forms in mind? I've tried MFC as the VITCam documentations mentioned it, but it makes very little sense and isn't as intuitive as Windows Forms feels.
Edit:
This is the error message I get when trying to use a normal (at least to me) array.
Error 1 error C4368: cannot define 'buffer' as a member of managed 'WirelessHeadImpact::Form1': mixed types are not supported
And it points to this line:
private:
WORD buffer[BUFFSIZE*CHANCOUNT];
What I had before was this:
static array<WORD>^ _buffer;
And within a function I create the former array, pass it to the function, then return the latter after looping through and updating the array.
WORD buffer[BUFFSIZE*CHANCOUNT];
DWORD scansCollected = 0;
while (total_scans < SCANS) {
daqAdcTransferBufData(_handle, buffer, BUFFSIZE, DabtmWait, &scansCollected);
if (scansCollected > 0) {
for (WORD i=0;i<scansCollected;i++) {
_buffer[i] = buffer[i];
}
mixed type support is removed in Visual C++ 2005. If you want to associate a DWORD array to a managed class, use new (not gcnew) to allocate the array itself on the native heap and save the pointer of the array in the class.
by the way, you cannot pass addresses of objects on the managed heap to a native function without pinning the object, otherwise the GC is free to move the object at any time. If you want to pass a managed value to a native function, make sure your pass by value or the object is pinned.
It helps the readers if you post the actual error message you are getting, instead of having to guess out from your question.

Resources