Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

DaGr8Gatzby posted:

I think it's just GCC.

It's not GCC's fault. Apple uses its own weird-rear end branch of GCC because they're big babies who don't want to mainline their Objective-C patches.

Adbot
ADBOT LOVES YOU

haveblue
Aug 15, 2005



Toilet Rascal

Avenging Dentist posted:

It's not GCC's fault. Apple uses its own weird-rear end branch of GCC because they're big babies who don't want to mainline their Objective-C patches.

Partly because RMS is a big baby who doesn't want to mainline Objective-C at all (hence the perma-deprecated status of #import and GCC emitting punitive warnings about it).

more falafel please
Feb 26, 2005

forums poster

haveblue posted:

Partly because RMS is a big baby who doesn't want to mainline Objective-C at all (hence the perma-deprecated status of #import and GCC emitting punitive warnings about it).

#import in the actual language would reduce compile times on a lot of large projects by at least 50% (at least on Windows)

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

more falafel please posted:

#import in the actual language would reduce compile times on a lot of large projects by at least 50% (at least on Windows)

No it would not.

Mustach
Mar 2, 2003

In this long line, there's been some real strange genes. You've got 'em all, with some extras thrown in.
Objective-C projects on Windows?!

Blotto Skorzany
Nov 7, 2008

He's a PSoC, loose and runnin'
came the whisper from each lip
And he's here to do some business with
the bad ADC on his chip
bad ADC on his chiiiiip

Mustach posted:

Objective-C projects on Windows?!

With gcc, anything* is possible











*offer does not include legible error messages, correctness or performance of generated code

ufarn
May 30, 2009
I have an assignment in CS to make a concatenator that merges several text files into one (Java ClassName text1.txt text2.txt text3.txt compilation.txt), but we've received no useful reading resource for doing so.

Does anyone know some good guides on the subject online?

haveblue
Aug 15, 2005



Toilet Rascal

ufarn posted:

I have an assignment in CS to make a concatenator that merges several text files into one (Java ClassName text1.txt text2.txt text3.txt compilation.txt), but we've received no useful reading resource for doing so.

Does anyone know some good guides on the subject online?

The documentation for system.io and possibly string? That's not exactly an esoteric topic.

litghost
May 26, 2004
Builder

sund posted:

Does Windows have a kill() equivalent? I'd like to send SIGINT to a background process I spawned with CreateProcess() without too much hassle. TerminateProcess() won't work, it causes this utility to leave temporary files around.

CRT.

GenerateConsoleCtrlEvent will work if you create the original process with CreateProcess and it is a console application. Read the page when it talks about CREATE_NEW_PROCESS_GROUP for details.

yippee cahier
Mar 28, 2005

litghost posted:

GenerateConsoleCtrlEvent will work if you create the original process with CreateProcess and it is a console application. Read the page when it talks about CREATE_NEW_PROCESS_GROUP for details.

Perfect! Thanks a bunch. All Google got me was "send WM_CLOSE".

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe

ufarn posted:

I have an assignment in CS to make a concatenator that merges several text files into one (Java ClassName text1.txt text2.txt text3.txt compilation.txt), but we've received no useful reading resource for doing so.

Does anyone know some good guides on the subject online?

Check out the BufferedReader class in the API, it has a clear example on how to open a file.
code:
BufferedReader in = new BufferedReader(new FileReader("foo.in"));
Then you can use the readLine() method to get each line of text.

For writing a file check out the PrintWriter class.
code:
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("foo.out")));
This class is useful because of all the different print methods that it has.

BizarroAzrael
Apr 6, 2006

"That must weigh heavily on your soul. Let me purge it for you."
I'm curious about why this batch script broke:

code:
SETLOCAL ENABLEDELAYEDEXPANSION
IF "%WCROOT%" == "" SET WCROOT=C:\Coding\Project\
SET MOVEFILE=
FOR /f "tokens=* delims= " %%a IN ('svn status -u %WCROOT%') DO (
	echo %%a | FIND "?      *" >> %LOGDIR%conflictfiles.txt
	IF NOT ERRORLEVEL 1 (
		SET MOVEFILE=%%a
		SET MOVEFILE=!MOVEFILE:~+20!
		ECHO Backing up possible conflict: !MOVEFILE!
		::MOVE /Y !MOVEFILE! !MOVEFILE!_backup
	)
)
ENDLOCAL
This should find files in an SVN working copy that are going to be conflicted with new updates (the string "? *" will be found on the line in the SVN status output for such files) and "moves" (thought effectively only renames) them out of the way of the incoming file. I needed to take the idea back to the drawing board, so disabled the MOVE command so I could keep using the larger script. However, with the command commented out, as you see above, the whole process gets killed. I just disabled the call command to this script instead, but I am curious about why this happened? I see no reason why this would break the loop or anything like that.

digital-entropy
Apr 21, 2002

With Javascript, is there anyway to set document.location.hash without appending an item to the browser's recent history? We have a Flex app at work and I want to let users bookmark/deep-link pages by setting the fragment each time they change the view.

The fragment sets correctly, but the user can then toggle through the recent hashes by using back/forward. I don't plan on picking up those change events so I'd rather the hash changes not append history items.

pseudorandom name
May 6, 2007

digital-entropy posted:

With Javascript, is there anyway to set document.location.hash without appending an item to the browser's recent history? We have a Flex app at work and I want to let users bookmark/deep-link pages by setting the fragment each time they change the view.

The fragment sets correctly, but the user can then toggle through the recent hashes by using back/forward. I don't plan on picking up those change events so I'd rather the hash changes not append history items.

No.

tef
May 30, 2004

-> some l-system crap ->

digital-entropy posted:

With Javascript, is there anyway to set document.location.hash without appending an item to the browser's recent history?

Couldn't you do something horrible with scrollTo or similar?

pseudorandom name
May 6, 2007

tef posted:

Couldn't you do something horrible with scrollTo or similar?

He's not using hashes to scroll to specific locations, he's using them so deep linking works with his Flash app, but he doesn't want to bother making the back/forward buttons work and people like him are the reason the rest of us hate Flash.

digital-entropy
Apr 21, 2002

pseudorandom name posted:

He's not using hashes to scroll to specific locations, he's using them so deep linking works with his Flash app, but he doesn't want to bother making the back/forward buttons work and people like him are the reason the rest of us hate Flash.

The reason I'm attempting to do it this way is that a coworker put app-specific back/forward buttons in and at some point they do need to be stripped out but that's going to be a bigger endeavor than simply working around it for now.

Believe me, I'd rather just use the browser back/forward work but it isn't something I am currently able to do.

But thanks for being a smartass and bothering to inquire why I might be stuck doing things a particular way. People like you are the reason the rest of us hate the internet.

tef
May 30, 2004

-> some l-system crap ->

pseudorandom name posted:

He's not using hashes to scroll to specific locations, he's using them so deep linking works with his Flash app, but he doesn't want to bother making the back/forward buttons work and people like him are the reason the rest of us hate Flash.

oh I see :smithicide:

pseudorandom name
May 6, 2007

digital-entropy posted:

The reason I'm attempting to do it this way is that a coworker put app-specific back/forward buttons in and at some point they do need to be stripped out but that's going to be a bigger endeavor than simply working around it for now.

Believe me, I'd rather just use the browser back/forward work but it isn't something I am currently able to do.

But thanks for being a smartass and bothering to inquire why I might be stuck doing things a particular way. People like you are the reason the rest of us hate the internet.

Sorry man; but every time I use a Flash app with a UI that almost but not quite behaves like a real UI it drives me nuts.

tef
May 30, 2004

-> some l-system crap ->
Just on a quick note:

The cobol aggregator is still alive and kicking at http://sn.printf.net

If anyone wants their blog to be added, just ask.

Seaniqua
Mar 12, 2004

"We'll see how the first year goes. But people better get us now, because we're going to keep getting better and better."
I have a quick newbie Java question regarding random numbers.

Random rand = new Random();

int i = rand.nextInt(30);

As I understand it, this will make i some random int between 0 and 29. Now let's say I want to generate a random long value that is well outside int's range. So, something greater than 2147483647.

Random has a nextLong() method, but as far as I can tell, you can't pass it an upper limit.

So right now, I'm generating a random number and checking that it is less than whatever the upper limit is, regenerating the number until it is less than the upper limit.

It's working but I'm totally sure there is a much more efficient way to do it.

vvvvvvvvvv
Awesome, thank you.

Seaniqua fucked around with this message at 21:21 on Nov 16, 2009

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh
Modulo.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
If an application is completely controlled by different key/values in a JSON object, what's the best way to document all the different parameters you can use?

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

fletcher posted:

If an application is completely controlled by different key/values in a JSON object, what's the best way to document all the different parameters you can use?

By... listing the valid keys? I'm not sure what you're asking here.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Avenging Dentist posted:

By... listing the valid keys? I'm not sure what you're asking here.

I guess I'm looking for a good example that is already out there of what I'm trying to do.

haveblue
Aug 15, 2005



Toilet Rascal

fletcher posted:

I guess I'm looking for a good example that is already out there of what I'm trying to do.

It's not really a complex problem. You can probably get away with a simple two-level list.

  • Key 1: [text]
    • Value 1: [text]
    • Value 2: [text]
  • Key 2: [text]
    • Value 1: [text]
    • Value 2: [text]

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

haveblue posted:

It's not really a complex problem. You can probably get away with a simple two-level list.

  • Key 1: [text]
    • Value 1: [text]
    • Value 2: [text]
  • Key 2: [text]
    • Value 1: [text]
    • Value 2: [text]

Some of the values should be other JSON objects, some should be an array of values, etc, so it is a bit more involved. I guess I should have mentioned that, my bad!

TheWevel
Apr 14, 2002
Send Help; Trapped in Stupid Factory
I'm having problems running a batch file on Windows Server 2008.

code:
@echo off
for /F "eol=; tokens= 1, 2 delims=, " %%I in (ipaddr.txt) do (
for %%R in (\\%%I\c$\VR\errlog.txt) do if %%~zR GTR 0 @echo %%J's logfile is %%~zR bytes.)
pause
exit
All it does is connect to a machine and then checks a certain file's size. For whatever reason it works fine on Windows XP machines in other groups but it won't do anything on this Server 2008 machine. I checked the "for" command's help and from what I could gather the command hasn't changed from XP to Server 2008. All the machines it's checking are Windows XP. I was hoping to use the Server 2008 box because it connects to both subnets and is just a utility machine. Any ideas?

edit: I'm also not a programmer so if that's not the best way of doing what I need, what's a better way? Also how could I parse the byte output to something like kilobytes or megabytes?

edit 2: I found out what the problem was: The password of the Administrator account was different than the XP machines. Changed that to match and it worked fine.

TheWevel fucked around with this message at 04:55 on Nov 17, 2009

1337JiveTurkey
Feb 17, 2005

Seaniqua posted:

I have a quick newbie Java question regarding random numbers.

Random rand = new Random();

int i = rand.nextInt(30);

As I understand it, this will make i some random int between 0 and 29. Now let's say I want to generate a random long value that is well outside int's range. So, something greater than 2147483647.

Random has a nextLong() method, but as far as I can tell, you can't pass it an upper limit.

So right now, I'm generating a random number and checking that it is less than whatever the upper limit is, regenerating the number until it is less than the upper limit.

It's working but I'm totally sure there is a much more efficient way to do it.

vvvvvvvvvv
Awesome, thank you.

Use either of the two implementations here: http://www.cs.gmu.edu/~sean/research/

This solves both the problem of getting a uniform long number within some range and of only 1/65536 of the possible values actually being produced because the default has a 48-bit seed.

Shoes
Dec 19, 2007
I've been working on a little project that involves processing quite a few (50) text files that aren't all quite the same format.

I started doing them 1-by-1 using regexes in perl, but I stumbled across this article which made me think that I might be able to use a more elegant approach.

I'm a total novice at defining grammars (never written a compiler!). Can they pick up paragraph-sized structures? How flexible can you make a grammar before it becomes useless?

Dijkstracula
Mar 18, 2003

You can't spell 'vector field' without me, Professor!

it's not the size of the "structure" that defines what kind of grammar you need, it's how complicated a parser you need. What do you need to do to this data?

If you don't need to do anything as complicated as these (the canonical context-free examples being "counting" multiple elements or navigating a tree-like document structure), it's likely a regular expression is as expressive a grammar as you need.

Shoes
Dec 19, 2007
I have texts split into sections and subsections. The format is consistent within each text but not between them. For each document, I want to recognize sections and subsections and store each one along with its correct title and index (section, subsection).

This is cool stuff, whether or not I actually need it.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Avenging Dentist posted:

By... listing the valid keys? I'm not sure what you're asking here.

Still looking for suggestions on this. Basically I want to see if I can improve this.

Avenging Dentist
Oct 1, 2005

oh my god is that a circular saw that does not go in my mouth aaaaagh

fletcher posted:

Still looking for suggestions on this. Basically I want to see if I can improve this.

Well, step one would be to make the actual options better designed. Since this is presumably meant to be used in a browser, you should be using the already-existing browser names for things. "colour?" "background-colour"? "on-click"? "alpha"? (this last one should be "opacity").

Step two would be cleaning up your quotation marks.

Step three would be to get rid of the bold red (it is really annoying) and to just add a "compatibility" column.

Also drop the "Object" column, format the example better, add hyperlinks to cross-reference the sub-objects, and add some headings in there.

For extra credit, stop using OpenOffice to write your documentation and get a tool designed for writing documentation. Sphinx works well for Python, but you might be able to make it work for this too (or just use plain-Jane ReST).

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb

Avenging Dentist posted:

Well, step one would be to make the actual options better designed. Since this is presumably meant to be used in a browser, you should be using the already-existing browser names for things. "colour?" "background-colour"? "on-click"? "alpha"? (this last one should be "opacity").

Step two would be cleaning up your quotation marks.

Step three would be to get rid of the bold red (it is really annoying) and to just add a "compatibility" column.

Also drop the "Object" column, format the example better, add hyperlinks to cross-reference the sub-objects, and add some headings in there.

For extra credit, stop using OpenOffice to write your documentation and get a tool designed for writing documentation. Sphinx works well for Python, but you might be able to make it work for this too (or just use plain-Jane ReST).

That page I linked isn't mine, it is what I intend to replace. Unfortunately I don't have enough control over the source code (yet) to rename all those attributes, otherwise I would. Is there nothing else out there that uses a JSON formatted object like this so I can see how they documented it?

Otik
Apr 6, 2005

Psycho log baby
I'm working on my first ever Java program for a course at uni, and while I've got most of it working perfectly, I'm having a problem getting the input validation to work properly.

Basically, any input must fill three criteria: it must be the right length, there can only be numbers and none of these numbers can be repeated. In other words, if the length is defined as "3" - 123 would be valid but 113, a23 and 1234 would not.

I'd paste the exact methods I'm using to do this at the moment, but as it's coursework, I can't.

Currently I'm using one method to parse the input into an array (we've been specifically instructed to use arrays) and call the other individual methods to test each validation criterion one by one from this method. When a validation criterion is unmet, the validation methods ask for a new input and sends that back to the first method to start the cycle of array entry and validation over.

If that made any sense, you may have noticed that I'm left with the problem of the validation methods eventually returning to the point immediately after they call the first method after the replacement input has been tested - leading to all sorts of problems.


Cliff notes: What is the best way to structure input validation when there are multiple criteria to be tested?

Sorry if this is a stupid question, but I've got myself going in circles right now, and I'm a bit new to all this.

Janitor Prime
Jan 22, 2004

PC LOAD LETTER

What da fuck does that mean

Fun Shoe
Here is some pseudo code to help you.
code:
Main:
  while true
    ask for input
    if isValid(input)
        break
    print error

  exit

boolean isValid (input)
  return checkLength(input) && checkNumber(input) && checkRepeat(input)

boolean checkLength(input)
...
etc
e: I hate your avatar so much.

Janitor Prime fucked around with this message at 01:52 on Nov 18, 2009

Otik
Apr 6, 2005

Psycho log baby

MEAT TREAT posted:

Here is some pseudo code to help you.
code:
Main:
  while true
    ask for input
    if isValid(input)
        break
    print error

  exit

boolean isValid (input)
  return checkLength(input) && checkNumber(input) && checkRepeat(input)

boolean checkLength(input)
...
etc
e: I hate your avatar so much.

I didn't 100% understand what your pseudocode was saying, but it did inspire me to a perfect and tidy solution (whether it was the way you were trying to tell me or not).

Basically, I made all my validation methods return a boolean and sat them in a while loop until they all returned a true value. With hindsight, it's what I should have done in the first place. Now it works, is way tidier, and I'm pretty much all finished :awesome:. Thanks!


As for the avatar, yeah, I get that a lot. To be fair, that was kind of the point.

BizarroAzrael
Apr 6, 2006

"That must weigh heavily on your soul. Let me purge it for you."
I've got a batch file composing a list of files and directories by identifying them and echoing them into a .txt file, but the list always has trailing spaces at the end of each line, which gets in the way of what I mean to do. Trimming the last character from the string before echoing into the file doesn't cut the space, but the last meaningful character. Is there something I can do to make it not put that space in? Or will I have to manually remove that space every time I use an address from that file?

Adbot
ADBOT LOVES YOU

Pie Colony
Dec 8, 2006
I AM SUCH A FUCKUP THAT I CAN'T EVEN POST IN AN E/N THREAD I STARTED
I have a general implementation question...

Suppose I have a ball moving around the screen. Let's say the code for this was moveBall(delta_x, delta_y) so in a loop where delta_x = delta_y = 1 the ball would move at a constant 45 degree angle, one pixel per iteration.

Now how would I write this if the ball could move at any angle? I was thinking about taking the ratio between sin(a) and cos(a), but how am I going to move sqrt(3) pixels at a time? Furthermore, if I call the speed at which the ball moves for d_x = d_y = 1 b, how can I make it so that the ball moves at speed b for any angle?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply