Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old May 1, 2013, 04:57 PM   #1
farmerdoug
macrumors 6502a
 
Join Date: Sep 2008
redirection

Where, inside of Xcode, can I input a file name for output redirection? Thanks
farmerdoug is offline   0 Reply With Quote
Old May 1, 2013, 07:25 PM   #2
lloyddean
macrumors 6502a
 
Join Date: May 2009
Location: Des Moines, WA
Menu Bar -> Product -> Scheme -> Edit Scheme

From the left list "Run"


On the right panel "Arguments passed on launch"
lloyddean is offline   0 Reply With Quote
Old May 1, 2013, 07:45 PM   #3
farmerdoug
Thread Starter
macrumors 6502a
 
Join Date: Sep 2008
I looked where you directed me. I didn't see where or how to add redirection. ./program > output.txt Places for arguments but not redirection. Xcode 4.40
farmerdoug is offline   0 Reply With Quote
Old May 2, 2013, 06:50 AM   #4
farmerdoug
Thread Starter
macrumors 6502a
 
Join Date: Sep 2008
More online search seems to suggest that Xcode 4 has bugs which doesn't do redirection of output to a file. Can I change the directory where the exe is placed so it's not so unaccessible.
farmerdoug is offline   0 Reply With Quote
Old May 2, 2013, 11:54 AM   #5
cqexbesd
macrumors member
 
Join Date: Jun 2009
Quote:
Originally Posted by farmerdoug View Post
More online search seems to suggest that Xcode 4 has bugs which doesn't do redirection of output to a file.
I'm going to speculate here and have done no research whatsoever. With that disclaimer out of the way...

I would guess that XCode execs your binary. If you supply "> file" as an argument it will get passed to your binary. The problem is your binary probably doesn't understand "> file". When running from the command line redirection is handled by the shell before a binary is execed. In this case you probably don't have a shell so there is nothing to do the redirection.

Quote:
Originally Posted by farmerdoug View Post
Can I change the directory where the exe is placed so it's not so unaccessible
Probably but you other alternative is just to symlink it so it appears to be in another location. No need to play with XCode settings at all.
cqexbesd is offline   0 Reply With Quote
Old May 21, 2013, 07:24 PM   #6
farmerdoug
Thread Starter
macrumors 6502a
 
Join Date: Sep 2008
splitting a list of dates

Not sure why I can't get this but if anybody can tell me how to know when I am at the line before "stop, here" I would appreciate it. As you can see the date becomes more recent at that point. The actually dates are not important only the order. In C please. Thanks

,20050107,000000,18.2200,18.3300,18.0000,18.0800,1297,0
EWG,D,20050106,000000,18.2200,18.2500,18.0800,18.2000,1563,0
EWG,D,20050105,000000,18.1000,18.2400,18.0900,18.1900,1208,0
EWG,D,20050104,000000,18.4600,18.4800,18.1000,18.1800,1613,0
EWG,D,20050103,000000,18.5000,18.6400,18.4900,18.5500,1505,0
"Stop here"
EWG,D,20130321,000000,24.8300,25.0450,24.7900,24.8600,31938,0
EWG,D,20130320,000000,25.2500,25.3000,25.1450,25.2100,31307,0
EWG,D,20130319
farmerdoug is offline   0 Reply With Quote
Old May 21, 2013, 08:55 PM   #7
chown33
macrumors 603
 
Join Date: Aug 2009
Maybe I'm missing what the question is, but the obvious thing is to read the next line and check it for "Stop Here".

If there's not an actual line that says "Stop Here", i.e. the data is like this:
Code:
EWG,D,20050105,000000,18.1000,18.2400,18.0900,18.1900,1208,0
EWG,D,20050104,000000,18.4600,18.4800,18.1000,18.1800,1613,0
EWG,D,20050103,000000,18.5000,18.6400,18.4900,18.5500,1505,0
EWG,D,20130321,000000,24.8300,25.0450,24.7900,24.8600,31938,0
EWG,D,20130320,000000,25.2500,25.3000,25.1450,25.2100,31307,0
then the next most obvious thing is to look at the dates, or presumed dates, i.e. the 3rd field, which contains an 8-digit numeric string. There is a jump of 7 years (or 70000) at that point, which seems like it would be quite easy to detect in any of several ways (as a substring, as a parsed string, as a parsed number).

I'm not sure what you mean by the actual dates aren't important. The size of the jump is going to be important in detecting the jump. If the discontinuity is undetectable, or occurs at places that aren't stopping points, then you have ambiguous end conditions, and you need to adjust the criteria until the end conditions are unambiguous.

I assume there's currently some C code that parses the fields and converts to numbers, substrings, etc., perhaps using one of the scanf() family of functions. If so, post that code, so we know what it's doing now. If we don't know how you're parsing the presumed date now, it's difficult to give specific details.


If the question really is how to know you're at the line BEFORE the first line with a 2013xxxx value, then that's impossible. You can't know you're BEFORE any line except by reading the next line and seeing it's the line you have to stop at.

In theory you could do read-ahead (man fseek, man ftell), but that's extra logic and it seems kind of silly to do that on every line. Simply read the next line, decide if it's the stopper line, and stop if it is.


There are also tools you could use (like awk) that can split the file when it transitions from 2005xxxx to 2013xxxx, but I suspect learning awk for that alone is more than you're willing to invest.
chown33 is offline   0 Reply With Quote
Old May 21, 2013, 09:13 PM   #8
farmerdoug
Thread Starter
macrumors 6502a
 
Join Date: Sep 2008
I parsed out the date, I tried various comparisons but they wouldn't work or I was making some sort of stupid mistake.

Typing this I realized that I might be better off not working with strings but converting them to ints; that and the right logic worked.
Thanks.
farmerdoug is offline   0 Reply With Quote
Old May 21, 2013, 09:27 PM   #9
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by farmerdoug View Post
I parsed out the date, I tried various comparisons but they wouldn't work or I was making some sort of stupid mistake.
Without seeing code, no one can possibly tell you what that mistake was. So if you want to fix the mistake, and possibly learn how to do it correctly in the future, you'll have to post code.
chown33 is offline   0 Reply With Quote
Old May 21, 2013, 09:39 PM   #10
robvas
macrumors 68000
 
Join Date: Mar 2009
Location: USA
When are you going to spend an hour looking at Ruby or Python?
robvas is offline   0 Reply With Quote
Old May 22, 2013, 06:55 AM   #11
farmerdoug
Thread Starter
macrumors 6502a
 
Join Date: Sep 2008
This works.
Code:
fgets(firstline, 300, oldfile);
		  strcpy(hold, firstline);
		  junk = strtok (firstline,","); //symbol
			junk = strtok (NULL,","); //
			date1 = strtok (NULL,",");
					  
		do
		{
			fprintf(newfile,"%s",hold);
				
			if (isdigit(date1[0]))
				day1 = strtoul(date1, NULL, 10);
			 	else
				break;
			day2 = day1;
			fgets(firstline, 300, oldfile);
			 strcpy(hold, firstline);

			junk = strtok (firstline,","); //symbol
		 	junk = strtok (NULL,","); //
			date1 = strtok (NULL,",");
	
			if (isdigit(date1[0]))
				day1 = strtoul(date1, NULL, 10);
			 	else
				break;
			printf("%s  %s \n", date1, date2);
					
		  }
		  while( day1 < day2 );


----------

When they are not scripted languages and as fast.
farmerdoug is offline   0 Reply With Quote
Old May 22, 2013, 10:14 AM   #12
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by farmerdoug View Post
This works.
Code:
...
If it works, then I have nothing to add.


You wrote this:
Quote:
I parsed out the date, I tried various comparisons but they wouldn't work or I was making some sort of stupid mistake.
My suggestion applied to the "various comparisons" that didn't work, not the revised code that does work.

If you want to learn what was wrong with the code that didn't work, then you'll have to post that code.
chown33 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 09:33 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC