The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 column manipulation

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Doltergost Posted - 04/04/2024 : 04:01:58 AM
Hello,

i have to manipulate the values of varios columns. For this i made this abornimation


vector &vioncurrent = ioncurrent.GetDataObject();
vector &vh2target = h2target.GetDataObject();
vector &vh2otarget = h2otarget.GetDataObject();
vector &vn2target = n2target.GetDataObject();
vector &vo2target = o2target.GetDataObject();
vector &vmasscheck = masscheck.GetDataObject();
vector &vtimesource = timesource.GetDataObject();
vector &vsource02 = source02.GetDataObject();
vector &vsource12 = source12.GetDataObject();
vector &vsource17 = source17.GetDataObject();
vector &vsource18 = source18.GetDataObject();
vector &vsource19 = source19.GetDataObject();
vector &vsource20 = source20.GetDataObject();
vector &vsource22 = source22.GetDataObject();
vector &vsource28 = source28.GetDataObject();
vector &vsource32 = source32.GetDataObject();
vector &vsource40 = source40.GetDataObject();
vector &vsource43 = source43.GetDataObject();
vector &vsource44 = source44.GetDataObject();
vector &vsource45 = source45.GetDataObject();
vector &vsource46 = source46.GetDataObject();
vector &vsource64 = source64.GetDataObject();
vector &vsource83 = source83.GetDataObject();


vector &vvorlauf = wksTarget.Columns(rowindices[0].start[0]).GetDataObject();
vector &vmnr02 = wksTarget.Columns(rowindices[1].start[0]).GetDataObject();
vector &vmnr03 = wksTarget.Columns(rowindices[2].start[0]).GetDataObject();
vector &vmnr04 = wksTarget.Columns(rowindices[3].start[0]).GetDataObject();
vector &vmnr05 = wksTarget.Columns(rowindices[4].start[0]).GetDataObject();
vector &vmnr06 = wksTarget.Columns(rowindices[5].start[0]).GetDataObject();
vector &vmnr07 = wksTarget.Columns(rowindices[6].start[0]).GetDataObject();
vector &vmnr08c1 = wksTarget.Columns(rowindices[7].start[0]).GetDataObject();
vector &vmnr08c2 = wksTarget.Columns(rowindices[7].start[1]).GetDataObject();
vector &vmnr08c3 = wksTarget.Columns(rowindices[7].start[2]).GetDataObject();
vector &vmnr08c4 = wksTarget.Columns(rowindices[7].start[3]).GetDataObject();
vector &vmnr08c5 = wksTarget.Columns(rowindices[7].start[4]).GetDataObject();
vector &vmnr09c1 = wksTarget.Columns(rowindices.start[0]).GetDataObject();
vector &vmnr09c2 = wksTarget.Columns(rowindices.start[1]).GetDataObject();
vector &vmnr09c3 = wksTarget.Columns(rowindices.start[2]).GetDataObject();
vector &vmnr09c4 = wksTarget.Columns(rowindices.start[3]).GetDataObject();
vector &vmnr09c5 = wksTarget.Columns(rowindices.start[4]).GetDataObject();
vector &vmnr10c1 = wksTarget.Columns(rowindices[9].start[0]).GetDataObject();
vector &vmnr10c2 = wksTarget.Columns(rowindices[9].start[1]).GetDataObject();
vector &vmnr10c3 = wksTarget.Columns(rowindices[9].start[2]).GetDataObject();
vector &vmnr10c4 = wksTarget.Columns(rowindices[9].start[3]).GetDataObject();
vector &vmnr10c5 = wksTarget.Columns(rowindices[9].start[4]).GetDataObject();
vector &vmnr11c1 = wksTarget.Columns(rowindices[10].start[0]).GetDataObject();
vector &vmnr11c2 = wksTarget.Columns(rowindices[10].start[1]).GetDataObject();
vector &vmnr11c3 = wksTarget.Columns(rowindices[10].start[2]).GetDataObject();
vector &vmnr11c4 = wksTarget.Columns(rowindices[10].start[3]).GetDataObject();
vector &vmnr11c5 = wksTarget.Columns(rowindices[10].start[4]).GetDataObject();
vector &vmnr12c1 = wksTarget.Columns(rowindices[11].start[0]).GetDataObject();
vector &vmnr12c2 = wksTarget.Columns(rowindices[11].start[1]).GetDataObject();
vector &vmnr12c3 = wksTarget.Columns(rowindices[11].start[2]).GetDataObject();
vector &vmnr12c4 = wksTarget.Columns(rowindices[11].start[3]).GetDataObject();
vector &vmnr12c5 = wksTarget.Columns(rowindices[11].start[4]).GetDataObject();
vector &vmnr13c1 = wksTarget.Columns(rowindices[12].start[0]).GetDataObject();
vector &vmnr13c2 = wksTarget.Columns(rowindices[12].start[1]).GetDataObject();
vector &vmnr13c3 = wksTarget.Columns(rowindices[12].start[2]).GetDataObject();
vector &vmnr13c4 = wksTarget.Columns(rowindices[12].start[3]).GetDataObject();
vector &vmnr13c5 = wksTarget.Columns(rowindices[12].start[4]).GetDataObject();
vector &vmnr14c1 = wksTarget.Columns(rowindices[13].start[0]).GetDataObject();
vector &vmnr14c2 = wksTarget.Columns(rowindices[13].start[1]).GetDataObject();
vector &vmnr14c3 = wksTarget.Columns(rowindices[13].start[2]).GetDataObject();
vector &vmnr14c4 = wksTarget.Columns(rowindices[13].start[3]).GetDataObject();
vector &vmnr14c5 = wksTarget.Columns(rowindices[13].start[4]).GetDataObject();
vector &vmnr15c1 = wksTarget.Columns(rowindices[14].start[0]).GetDataObject();
vector &vmnr15c2 = wksTarget.Columns(rowindices[14].start[1]).GetDataObject();
vector &vmnr15c3 = wksTarget.Columns(rowindices[14].start[2]).GetDataObject();
vector &vmnr15c4 = wksTarget.Columns(rowindices[14].start[3]).GetDataObject();
vector &vmnr15c5 = wksTarget.Columns(rowindices[14].start[4]).GetDataObject();
vector &vmnr16c1 = wksTarget.Columns(rowindices[15].start[0]).GetDataObject();
vector &vmnr16c2 = wksTarget.Columns(rowindices[15].start[1]).GetDataObject();
vector &vmnr16c3 = wksTarget.Columns(rowindices[15].start[2]).GetDataObject();
vector &vmnr16c4 = wksTarget.Columns(rowindices[15].start[3]).GetDataObject();
vector &vmnr16c5 = wksTarget.Columns(rowindices[15].start[4]).GetDataObject();
vector &vmnr17c1 = wksTarget.Columns(rowindices[16].start[0]).GetDataObject();
vector &vmnr17c2 = wksTarget.Columns(rowindices[16].start[1]).GetDataObject();
vector &vmnr17c3 = wksTarget.Columns(rowindices[16].start[2]).GetDataObject();
vector &vmnr17c4 = wksTarget.Columns(rowindices[16].start[3]).GetDataObject();
vector &vmnr17c5 = wksTarget.Columns(rowindices[16].start[4]).GetDataObject();
vector &vmnr18c1 = wksTarget.Columns(rowindices[17].start[0]).GetDataObject();
vector &vmnr18c2 = wksTarget.Columns(rowindices[17].start[1]).GetDataObject();
vector &vmnr18c3 = wksTarget.Columns(rowindices[17].start[2]).GetDataObject();
vector &vmnr18c4 = wksTarget.Columns(rowindices[17].start[3]).GetDataObject();
vector &vmnr18c5 = wksTarget.Columns(rowindices[17].start[4]).GetDataObject();
vector &vmnr19c1 = wksTarget.Columns(rowindices[18].start[0]).GetDataObject();
vector &vmnr19c2 = wksTarget.Columns(rowindices[18].start[1]).GetDataObject();
vector &vmnr19c3 = wksTarget.Columns(rowindices[18].start[2]).GetDataObject();
vector &vmnr19c4 = wksTarget.Columns(rowindices[18].start[3]).GetDataObject();
vector &vmnr19c5 = wksTarget.Columns(rowindices[18].start[4]).GetDataObject();

vioncurrent = vsource02 + vsource12 + vsource17 + vsource18 + vsource19 + vsource20 + vsource22 + vsource28 + vsource32 + vsource40 + vsource43 + vsource44 + vsource45 + vsource46 + vsource64 + vsource83;
vh2target = vsource02 / vioncurrent * 100;
vh2otarget = vsource18 / vioncurrent * 100;
vn2target = vsource28 / vioncurrent * 100;
vo2target = vsource32 / vioncurrent * 100;
vmasscheck = vh2target + vh2otarget + vn2target + vo2target;

vmnr02 = vmnr02 - wksSource.Cell(timeindices[1].start[0],indextime);
vmnr03 = vmnr03 - wksSource.Cell(timeindices[2].start[0],indextime);
vmnr04 = vmnr04 - wksSource.Cell(timeindices[3].start[0],indextime);
vmnr05 = vmnr05 - wksSource.Cell(timeindices[4].start[0],indextime);
vmnr06 = vmnr06 - wksSource.Cell(timeindices[5].start[0],indextime);
vmnr07 = vmnr07 - wksSource.Cell(timeindices[6].start[0],indextime);
vmnr08c1 = vmnr08c1 - wksSource.Cell(timeindices[7].start[0],indextime);
vmnr09c1 = vmnr09c1 - wksSource.Cell(timeindices.start[0],indextime);
vmnr10c1 = vmnr10c1 - wksSource.Cell(timeindices[9].start[0],indextime);
vmnr11c1 = vmnr11c1 - wksSource.Cell(timeindices[10].start[0],indextime);
vmnr12c1 = vmnr12c1 - wksSource.Cell(timeindices[11].start[0],indextime);
vmnr13c1 = vmnr13c1 - wksSource.Cell(timeindices[12].start[0],indextime);
vmnr14c1 = vmnr14c1 - wksSource.Cell(timeindices[13].start[0],indextime);
vmnr15c1 = vmnr15c1 - wksSource.Cell(timeindices[14].start[0],indextime);
vmnr16c1 = vmnr16c1 - wksSource.Cell(timeindices[15].start[0],indextime);
vmnr17c1 = vmnr17c1 - wksSource.Cell(timeindices[16].start[0],indextime);
vmnr18c1 = vmnr18c1 - wksSource.Cell(timeindices[17].start[0],indextime);
vmnr19c1 = vmnr19c1 - wksSource.Cell(timeindices[18].start[0],indextime);


if(cyclenumber > 1)
{
vmnr08c2 = vmnr08c2 - wksSource.Cell(timeindices[7].start[1],indextime);
vmnr09c2 = vmnr09c2 - wksSource.Cell(timeindices.start[1],indextime);
vmnr10c2 = vmnr10c2 - wksSource.Cell(timeindices[9].start[1],indextime);
vmnr11c2 = vmnr11c2 - wksSource.Cell(timeindices[10].start[1],indextime);
vmnr12c2 = vmnr12c2 - wksSource.Cell(timeindices[11].start[1],indextime);
vmnr13c2 = vmnr13c2 - wksSource.Cell(timeindices[12].start[1],indextime);
vmnr14c2 = vmnr14c2 - wksSource.Cell(timeindices[13].start[1],indextime);
vmnr15c2 = vmnr15c2 - wksSource.Cell(timeindices[14].start[1],indextime);
vmnr16c2 = vmnr16c2 - wksSource.Cell(timeindices[15].start[1],indextime);
vmnr17c2 = vmnr17c2 - wksSource.Cell(timeindices[16].start[1],indextime);
vmnr18c2 = vmnr18c2 - wksSource.Cell(timeindices[17].start[1],indextime);
vmnr19c2 = vmnr19c2 - wksSource.Cell(timeindices[18].start[1],indextime);

if(cyclenumber > 2)
{
vmnr08c3 = vmnr08c3 - wksSource.Cell(timeindices[7].start[2],indextime);
vmnr09c3 = vmnr09c3 - wksSource.Cell(timeindices.start[2],indextime);
vmnr10c3 = vmnr10c3 - wksSource.Cell(timeindices[9].start[2],indextime);
vmnr11c3 = vmnr11c3 - wksSource.Cell(timeindices[10].start[2],indextime);
vmnr12c3 = vmnr12c3 - wksSource.Cell(timeindices[11].start[2],indextime);
vmnr13c3 = vmnr13c3 - wksSource.Cell(timeindices[12].start[2],indextime);
vmnr14c3 = vmnr14c3 - wksSource.Cell(timeindices[13].start[2],indextime);
vmnr15c3 = vmnr15c3 - wksSource.Cell(timeindices[14].start[2],indextime);
vmnr16c3 = vmnr16c3 - wksSource.Cell(timeindices[15].start[2],indextime);
vmnr17c3 = vmnr17c3 - wksSource.Cell(timeindices[16].start[2],indextime);
vmnr18c3 = vmnr18c3 - wksSource.Cell(timeindices[17].start[2],indextime);
vmnr19c3 = vmnr19c3 - wksSource.Cell(timeindices[18].start[2],indextime);

if(cyclenumber > 3)
{
vmnr08c4 = vmnr08c4 - wksSource.Cell(timeindices[7].start[3],indextime);
vmnr09c4 = vmnr09c4 - wksSource.Cell(timeindices.start[3],indextime);
vmnr10c4 = vmnr10c4 - wksSource.Cell(timeindices[9].start[3],indextime);
vmnr11c4 = vmnr11c4 - wksSource.Cell(timeindices[10].start[3],indextime);
vmnr12c4 = vmnr12c4 - wksSource.Cell(timeindices[11].start[3],indextime);
vmnr13c4 = vmnr13c4 - wksSource.Cell(timeindices[12].start[3],indextime);
vmnr14c4 = vmnr14c4 - wksSource.Cell(timeindices[13].start[3],indextime);
vmnr15c4 = vmnr15c4 - wksSource.Cell(timeindices[14].start[3],indextime);
vmnr16c4 = vmnr16c4 - wksSource.Cell(timeindices[15].start[3],indextime);
vmnr17c4 = vmnr17c4 - wksSource.Cell(timeindices[16].start[3],indextime);
vmnr18c4 = vmnr18c4 - wksSource.Cell(timeindices[17].start[3],indextime);
vmnr19c4 = vmnr19c4 - wksSource.Cell(timeindices[18].start[3],indextime);

if(cyclenumber > 4)
{
vmnr08c5 = vmnr08c5 - wksSource.Cell(timeindices[7].start[4],indextime);
vmnr09c5 = vmnr09c5 - wksSource.Cell(timeindices.start[4],indextime);
vmnr10c5 = vmnr10c5 - wksSource.Cell(timeindices[9].start[4],indextime);
vmnr11c5 = vmnr11c5 - wksSource.Cell(timeindices[10].start[4],indextime);
vmnr12c5 = vmnr12c5 - wksSource.Cell(timeindices[11].start[4],indextime);
vmnr13c5 = vmnr13c5 - wksSource.Cell(timeindices[12].start[4],indextime);
vmnr14c5 = vmnr14c5 - wksSource.Cell(timeindices[13].start[4],indextime);
vmnr15c5 = vmnr15c5 - wksSource.Cell(timeindices[14].start[4],indextime);
vmnr16c5 = vmnr16c5 - wksSource.Cell(timeindices[15].start[4],indextime);
vmnr17c5 = vmnr17c5 - wksSource.Cell(timeindices[16].start[4],indextime);
vmnr18c5 = vmnr18c5 - wksSource.Cell(timeindices[17].start[4],indextime);
vmnr19c5 = vmnr19c5 - wksSource.Cell(timeindices[18].start[4],indextime);
}
}
}
}

Is there a way to do this with a loop? I tried for my self but didnt get anywhere.

Thanks in advance
Markus
2   L A T E S T    R E P L I E S    (Newest First)
Doltergost Posted - 04/15/2024 : 10:30:42 AM
Thanks for the help
jasmine_chan Posted - 04/07/2024 : 04:59:15 AM
you can pass wksTarget and wksInput to a small function like this

static void _minusfunc(Worksheet& wksOutput, int nCol, const Worksheet& wksInput, int rr, int cc)
{
	vector &vv = wksOutput.Columns(nCol).GetDataObject(); 
	vv = vv - wksInput.Cell(rr, cc);
}

And the codes after this row vmasscheck = vh2target + vh2otarget + vn2target + vo2target;
can be changed like

int ii;
for(ii = 1; ii <= 18; ii++)
{
	_minusfunc(wksTarget, rowindices[ii].start[0], wksSource, timeindices[ii].start[0], indextime);
}


if(cyclenumber > 1)
{
	for(ii = 7; ii <= 18; ii++)
	{
		_minusfunc(wksTarget, rowindices[ii].start[1], wksSource, timeindices[ii].start[1], indextime);
	}
	
	if(cyclenumber > 2)
	{
		for(ii = 7; ii <= 18; ii++)
		{
			_minusfunc(wksTarget, rowindices[ii].start[2], wksSource, timeindices[ii].start[2], indextime);
		}

		if(cyclenumber > 3)
		{			
			for(ii = 7; ii <= 18; ii++)
			{
				_minusfunc(wksTarget, rowindices[ii].start[3], wksSource, timeindices[ii].start[3], indextime);
			}
			
			if(cyclenumber > 4)
			{
				for(ii = 7; ii <= 18; ii++)
				{
					_minusfunc(wksTarget, rowindices[ii].start[4], wksSource, timeindices[ii].start[4], indextime);
				}
			}
		}
	}
}

even more, you can pass rowindices and timeindices to another small function to do the 4 times cyclenumber checking

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000