Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

ActiveReport SZ/STOCK-XYZ output format


uncle_dolan
 Share

Recommended Posts

Hi Everyone,

 

Been modifying datafields in my active reports to output numbers to 2 decimal places only. I would like to do this for stck sizes as well. I am currently using the SZ/STOCK-XYZ data field to grab my X,Y and Z dimensions for stock as set in mastercam. I would like each of these values to be limited to 2 decimal places but cannot work out how to manipulate the default formatting. Any help would be greatly appreciated!

 

Brendan

Link to comment
Share on other sites

Click on "output format" under "appearance" on the right hand side of your screen when you open Active Reports Designer. Click the box, click on "number" and you should see a field for number of decimal places. ;)

 

Edit to add: make sure you click on the "SZ/STOCK-XYZ " entry first to make sure you are changing the correct field.

Link to comment
Share on other sites

Click on "output format" under "appearance" on the right hand side of your screen when you open Active Reports Designer. Click the box, click on "number" and you should see a field for number of decimal places. ;)

 

Edit to add: make sure you click on the "SZ/STOCK-XYZ " entry first to make sure you are changing the correct field.

 

Tried that one already...since it is not a number field as such, this does not work. the output of the "SZ/STOCK-XYZ" is XXX.XXX,YYY.YYY,ZZZ.ZZZ, with the number of trailing numbers dependant on the specificity of the stock def in mastercam. I have tried a few combimations of formatting changes using the output format section but to no avail. Is there any way that you can set this in the controlling XML Document? Any other ideas?

Link to comment
Share on other sites
  • 3 weeks later...

It's possible to format the stock size with C# code. As you already found out you can't format "SZ/STOCK-XYZ" as a number, because it's actually a "string" of numbers. So you would need to convert that string into numbers, then format the numbers for 2 place decimal, and then convert again back into a string to display in your report. If you want I could work out some code for you.

Link to comment
Share on other sites

It's possible to format the stock size with C# code. As you already found out you can't format "SZ/STOCK-XYZ" as a number, because it's actually a "string" of numbers. So you would need to convert that string into numbers, then format the numbers for 2 place decimal, and then convert again back into a string to display in your report. If you want I could work out some code for you.

 

Hi Thrash,

 

A sample piece of code would be great only if it doesn't take you long to whip up. I'm familiar with a couple of other scripting languages but havent got to C# yet. If you could get me a short piece of code that could work I'm sure I'd be able to tweak it to my purposes! TIA Brendan

Link to comment
Share on other sites

Here you go. You just need to change the code so it points to the Name of your TextBox. I used a TextBox named txtStockSize in example below. If you have any problems\questions, let me know.

 

using System;
using System.Windows.Forms;

public void Detail_Format()
{
// Load s_stocksize variable with the TextBox.Text from your SZ/STOCK-XYZ datafield.
// This example uses a TextBox that has the Name txtStockSize
string s_stocksize = ((TextBox) rpt.Sections["Detail"].Controls["txtStockSize"]).Text;

// If Then to check that the SZ/STOCK-XYZ datafield is not empty
if (!String.IsNullOrEmpty(s_stocksize))
{
	string[] szArray = s_stocksize.Split(',');
	string s_NewString = System.String.Empty;		
	double[] dNumArray = new double[szArray.Length];

	for(int i = 0; i < szArray.Length; i++)
	{
		dNumArray[i] = double.Parse(szArray[i]);
		szArray[i] = String.Format("{0:0.00}", dNumArray[i]);
		//MessageBox.Show(szArray[i]);
	}
	s_NewString = String.Join(", ",szArray);
	((TextBox) rpt.Sections["Detail"].Controls["txtStockSize"]).Text = s_NewString;
}
}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...