Beyond Compare: compare whole function calls or xml blocks - c

I want to compare c and XML files with Beyond Compare. But I want to detect if there are differences within a Block to the corrosponding on the other file and if there is a difference in a block I dont want Beyond Compare to Show the difference in the block, but handle it like this block is not in the other file. I Need this because in my files are certain Code blocks which are nearly the same but do have different Signalnames in it.
So for example i got a c file that Looks like this:
//1
functioncall(
Singalname1,
Singalname2,
Singalname3,
Singalname4,
Singalname5,
Singalname6);
//2
functioncall(
Singalname31,
Singalname32,
Singalname33,
Singalname34,
Singalname53,
Singalname36);
And a second file which Looks like this:
//1
functioncall(
Singalname1,
Singalname2,
Singalname3,
Singalname4,
Singalname5,
Singalname6);
//2
functioncall(
Singalname371,
Singalname372,
Singalname373,
Singalname374,
Singalname573,
Singalname376);
If I compare those two files with BeyondCompare it determines the difference within the second function call because the signalnames all contain a 7. But i want Beondcompare compare the whol functioncall an if there are differences in the functionCall to Show the functioncall beside empty space so i can add it eaily to the second file.
So not like this:
I want it like this:
I tried to add some comments with a begin comment and an end comment with a incrementing number in it something like this:
//begin1
functioncall(
Singalname1,
Singalname2,
Singalname3,
Singalname4,
Singalname5,
Singalname6);
//end1
And then adding a specific rule in beyond compare. Unfortnatly i did not manage to add this rule to beyond compare.
Furthermore Ithink the Code is not good with this comments in it.

Beyond Compare doesn't provide a method to do this. The best workaround is to use the right click Align With command to shift the function alignment.

Did you try the "Never align differences" checkbox in the Alignment tab of the session settings?

Related

Swift - adding named objects to an array using a variable and a loop

Possibly very stupid question I cannot seem to find an answer for (I am beginning with code)
I want to create a simple loop which appends myArray with three objects, which are members of a custom class MyClass. The objects have the following names: "object1", "object2", "object3".
When I write the following code, there is no issue:
myArray.append(object1)
But I want to write a loop to add all three. Again, very dumb, but I can't figure out how to insert the number in the name of the object as a variable. E.g., here was something I tried
let x = 3
for i in 1...x {
myArray.append(object[i])
}
This gives an error. The reason I want to do it using a loop, and not simply write in the three objects manually, is that I won't always loop three times. Sometimes I'll just want the first two objects, sometimes just the first.
I assume there's some easy way to do this, but when I search it tends to turn up more complex questions

Easier way to call an absurd number of functions

So I'm calling a whole lot of functions what kind of have a similar pattern
(disclaimer:I did not write these)
They go like so:
Write_thing0<x>_object00<y>(somedata);
where <x> takes values from 0 to 6 and <y> takes values from 1 to 20.
Is there a sane way to do this, perhaps in a loop? The token-pasting operator was suggested but that doesn't work or I can't find a way to use it.
Edit:
Okay so I'll go into more depth:
Write_thing000_object001_A(uint8);
Write_thing000_object001_B(uint8);
Write_thing000_object001_C(uint16);
.................................
Write_thing000_object001_Z(uint8);
Write_thing000_object002_A(uint8);
.................................
Write_thing000_object002_Z(uint8);
/* all the way up to object 20, then thing changes to 001 and object count resets */
the pattern of parameters stays the same in each A-Z block.
I hope that makes more sense.
It can be done with x-macros:
#define CALL_ONE(i,j) call_func_##i##_##j(); // Put your function name here.
#define LIST_A(m,d) m(0,d) m(1,d) m(2,d) // Replace 0,1,2 with actual values.
#define LIST_B(m,d) m(X,d) m(Y,d) m(Z,d) // Replace X,Y,Z with actual values.
#define CALL_A(x,unused) LIST_A(CALL_ONE,x)
#define CALL_B() LIST_B(CALL_A,)
Now, CALL_B() expands to:
call_func_0_X(); call_func_1_X(); call_func_2_X();
call_func_0_Y(); call_func_1_Y(); call_func_2_Y();
call_func_0_Z(); call_func_1_Z(); call_func_2_Z();
It should be easy to adapt this for your purposes.
From your example you seem to suggest that the code looks like this:
Write_thing000_object001(somedata);
Write_thing000_object002(somedata);
Write_thing000_object003(somedata);
Write_thing000_object004(somedata);
Write_thing000_object005(somedata);
/// lots of lines
Write_thing006_object0020(somedata);
If this is exactly what your code looks like fine. But it raises a lot of questions to me
1) Does some data stay the same for each function call (or set of calls)
2) Is every function name used or is a subset of names
3) What do all these functions do? It seems likely give the name that they could be all be rewritten like this:
Write_thing_object(somedata,x,y);
then you just have one function and you can put the whole thing in a loop -- why can't you do that?
Also as a side note, this is often called a 'dispatch pattern', if you simple make this function and have it call the correct other function. You could do this efficiently by creating a 2 dimension array of function pointers. If this is what you need to do I could show you how to do that.

Array constant in a formula with non-adjacent cell references

I need to add an array of non-adjacent cells to my array formula. I have tried all of the following array constant-like ways and they all give me a "There is a problem with this formula error".
'Chart Data'!{A12:A14,D3:D11}
{'Chart Data'!A12:A14,'Chart Data'!D3:D11}
'Chart Data'!{A12,A13,A14,D3:D11}
{'Chart Data'!A12,'Chart Data'!A13,'Chart Data'!A14,'Chart Data'!D3:D11}
'Chart Data'!{A12,A13,A14,D3,D4,D5,D6,D7,D8,D9,D10,D11}
{'Chart Data'!A12,'Chart Data'!A13,'Chart Data'!A14,'Chart Data'!D3,'Chart Data'!D4,'Chart Data'!D5,'Chart Data'!D6,'Chart Data'!D7,'Chart Data'!D8,'Chart Data'!D9,'Chart Data'!D10,'Chart Data'!D11}
Entire formula (the array constant goes where the {#####} is):
{=SUM(((1-References!M1:M12)*({#####}*(G3:G14+F3:F14-0.11)))+((References!M1:M12)*('Chart Data'!A12:A23*(G3:G14+F3:F14-0.11)))+((H2:H13*X3:X14)+(H3:H14*Y3:Y14)+(I2:I13*(V3:V14-X3:X14))+(I3:I14*(W3:W14-Y3:Y14))))}
I am 100% positive that it is this particular array constant that is causing the problem. I can't move the cells I'm referencing to put them in line. Is it even possible to reference a non-adjacent range in an array formula? If it's possible, what am I doing wrong?
There are several ways to do this. The following is very simple and pretty direct so my favorite.
EITHER choose a cell to build your string for your non-contiguous array in OR create a Named Range to do it. I'll show the first as it seems nicest for being able to use the mouse freely, but in both of them you can actually be creative using about how you build the string that will become your array. The main advantage of creating it in a Named Range is no helper cell lying about anywhere.
So, you create that string and then make it an array. Say you have a non-contiguous array needed using cells A12:A14 and C3:C11. You use joining and TEXTJOIN() like so:
="{"&TEXTJOIN(",",FALSE,B12:B14,C3:C11)&"}"
to create a text string of the values in those cells wrapped with the curly braces ({}) just as if you'd typed it in ("hardcoded it"). It will look like this with the right values in those cells:
{1,2,3,1,2,3,4,5,6,7,8,9}
but is ain't an array yet.
Now the magic in THIS method. Create a Named Range, perhaps called String2Array, and give it a formula of:
=EVALUATE(A1)
(or whatever cell you used for the above formula creating the text string that you want to be an array). Make the reference absolute. ($A$1... which it will do for you, just don't edit it to be relative. If you use this for similar work, but need it relative, that will work fine, but it just isn't what is needed here.)
Now replace your placeholder in the formula with the Named Range's name (perhaps you DID use String2Array). And you're done.
A couple other methods use INDEX() or CHOOSE() and you can force things to be arrays using the functions DOLLARDE() and IMREAL() (I found on a helpsite in a 2014 post) and some others do the same kind of thing. In those days, one had to use {CSE} too, but SPILL takes care of that now (with those two weird-seeming friendlies and at least two others). The poster was someone I've seen on this site, EXCELXOR was the name for the site, XOR LX was the name of the member here though the functions were mentioned in a comment by a Lori. Since he covers, it seems, aspects not usually covered in helpsites, looking up some of his work here, or elsewhere too, might be worthwhile to some folks.
But this method is very direct and therefore easy to maintain. And personally, I love the idea that EVALUATE() (must be used IN the Named Range functionality, not cell-side) is the gift that keeps on giving, one wonderfully helpful thing after another.
So many ways. You could even literally build the array in a helper column/row somewhere and reference THAT instead of the non-contiguous addresses. I like the joining+TEXTJOIN() approach best because I can use the mouse to easily get all the blocks into the formula since it is a LIVE formula. But you can type out a string fairly easily too and add the {}'s. Or perhaps a user would type a string of addresses and you'd add them like the formula does above. And you can insert actual values (constants) into the string you are building as well if that is appropriate. And you could build it formulaicly... I wouldn't pick that workload first thing off the pile of choices, but if you were going to do it anyway already, then... or if it's a small build.

VIM syntax: conditional function coloring

I'm customizing the standard "c.vim" syntax file in order to tune the visualisation of my C code.
I would like to distinguish the color of the "called functions" from the one of the "declared functions".
Exemple:
int declared_function()
{
int m;
m = called_function();
return (m)
}
I read in depth the VIM documentation, and millions of forums and google results, but all the solutions I tried didn't work.
To resume, I did this:
I defined a region in a recursive way in order to consider all the code within the braces:
syn region Body start="{" end="}" contains=Body
Then I defined through VIM patterns a general function syntax:
syn match cFunction "\<\h\w*\>\(\s\|\n\)*("me=e-1 contains=cType,cDelimiter,cDefine
I did this because I thought I could combine the two in a "if else" condition in the .vimrc file... but after a whole day of failing tests I need the help of someone, who can tell me if it's possible and how to do it.
Thanks everybody.
You're very close. First, you don't need the recursive definition, but contain all other top-level C syntax elements in it, plus the special group you'll define for called functions:
:syn region Body start="{" end="}" contains=TOP,cFunctionUse
Actually, scratch that, the default $VIMRUNTIME/syntax/c.vim already defines a cBlock syntax group.
Then, define a different syntax group that is contained in the cBlock group.
:syn match cFunctionUse "\<\h\w*\>\(\s\|\n\)*("me=e-1 contained containedin=cBlock contains=cType,cDelimiter,cDefine
Finally, link or define a different highlight group for it, so that it actually looks different:
:hi link cFunctionUse Special
You can put those into ~/.vim/after/syntax/c.vim, so that they'll be added automatically to the default C syntax.

Can I put letters instead of some numbers as ticks in a ValueAxis?

this is my program:
Program before
and I want it to look like this:
Program after
is this possible to add letters at some specific points in the ValueAxis?
I'm afraid that your links are not working, you may get a better responce using Imager and adding some example code or a Short, Self Contained, Correct Example.
In the meantime is this what you are trying to do

Resources