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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Output redirection
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

rikseventyseven

Switzerland
10 Posts

Posted - 09/09/2009 :  08:26:48 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Dear Developers,

I'm developing an analysis tool for my business. The piece of code that I wrote up to know prints results in the command window since I run the program from there.

Now I have two questions:

1- How can I create a menu item (for example in the Analysis Menu) so that I can run the program with a simple click.

2- Alternatively, how can I avoid compiling the program every time that I open an Origin session and run the program from the command window?

3- When the program is run from a menu item, the output is not shown in the command window anymore... Any suggestions on how can I display the results to the user in a smarter way? Is it possible to redirect the program "printf" output to command window?

Thanks a lot

Origin Ver. 8 and Service Release SR5 (Select Help-->About Origin):
Operating System: WinXP

-------------------------------
"Stay hungry, stay foolish."

rlewis

Canada
253 Posts

Posted - 09/09/2009 :  12:04:09 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The following is a code snippet from one of my utility functions. It illustrates redirection of output stored in a atring array " " to either the script window, a notes window or to a file.
Hope this helps ...


.....
			switch (ControlID)
			{
				case IDC_RBN_Script_Window:
					double dVal=LabTalk.type.redirection;
					LT_execute("type -a    ");
					LT_execute("type.redirection=1");
					for(int i=0;i<szOutPut.GetSize();i++)
					{
						strLine=szOutPut[i];
						out_str(strLine);
					}
					LabTalk.type.redirection=dVal;
					strTemp="Results Written to Script Window";
					SetDataDisplayText(strTemp);
				break;
				case IDC_RBN_NOTEPAGE:
					if(OutNote.IsValid()==false)
					{
						if(OutNote.CreateVisible(false)==false)
						{
							SetDataDisplayText("NotePageCreation Error ... Data Not Saved");
							return (false);
						}
					}
					int numLines=szOutPut.GetSize();
					for(i=0;i<numLines;i++)
					{
						OutNote.AddLine(szOutPut[i]);
					}
					strTemp="Results Written to NotePage:"+OutNote.GetName();
					SetDataDisplayText(strTemp);
				break;
				case IDC_RBN_FILE:
					string strPath;
					StringArray saFiletypes;
					saFiletypes.SetSize(1);
					saFiletypes[0]="[ASCII TEXT (*.TXT)] *.txt";
					string strFilePath = GetSaveAsBox( saFiletypes );
					if(strFilePath.IsEmpty()==false)
					{
						stdioFile TextFile;
						if (TextFile.Open(strFilePath, file::modeCreate | file::modeWrite)==true)
						{
							for(int i=0;i<szOutPut.GetSize();i++)
							{
								strLine=szOutPut[i];
								TextFile.WriteString(strLine);
							}
							TextFile.Close();
							strTemp="Results Written to File: "+GetFileName(strFilePath);
							SetDataDisplayText(strTemp);
						}
					}
				break;
			}
...
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000