|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On July 04 2013 00:45 Intgrl wrote: You should rewrite your while-loop. Just put while (true) and check if the number is even or odd and do the changes, then immediately after changing the number you check if it's 1 and then break; Remember to print the numbers after every change.
Hope I didn't help too much(?) Thanks for your help.
|
On July 04 2013 00:50 HyunA wrote:Show nested quote +On July 04 2013 00:45 Intgrl wrote: You should rewrite your while-loop. Just put while (true) and check if the number is even or odd and do the changes, then immediately after changing the number you check if it's 1 and then break; Remember to print the numbers after every change.
Hope I didn't help too much(?) I still can't manage to get it to work, I give up. Thanks for your help. Well if you want to see the code, it's here http://pastebin.com/kNw5Yuun Just make sure if you really want to see it or if you'll try it again later. Up to you.
|
Why do you want to use a while(true) loop? It's prettier to keep the logic in the while loop construct rather than needing to break out of it.
A pastebin.
while(true) is OK for doing threads and so on, but otherwise... meh.
|
The problem screams recursion. Go away with your loops.
|
On July 04 2013 01:15 bangsholt wrote:Why do you want to use a while(true) loop? It's prettier to keep the logic in the while loop construct rather than needing to break out of it. A pastebin. while(true) is OK for doing threads and so on, but otherwise... meh. Well, I'm not going to defend my while(true) loop. It's just whatever came to my mind first and I posted it.
|
Not looking for an actual code but instead just a simple draft/explanation on how it would work.
How would one go about creating a program that can automate a simple task of (for example):
search address for companies paste the result in microsoft excel
Assume best case scenario (all addresses are formatted same way and are easily found on web by your program, user is not an idiot). Would you use something like javascript? Or could you use some higher level language and code it to open a browser, go search on google etc...? What is the go to language or the basic procedure to create a program that would do automated work something similar like above?
|
On July 04 2013 01:42 Zocat wrote: The problem screams recursion. Go away with your loops.
You start with one problem, and apply recursion. Now you have two...
On July 04 2013 02:04 heroyi wrote: Not looking for an actual code but instead just a simple draft/explanation on how it would work.
How would one go about creating a program that can automate a simple task of (for example):
search address for companies paste the result in microsoft excel
Assume best case scenario (all addresses are formatted same way and are easily found on web by your program, user is not an idiot). Would you use something like javascript? Or could you use some higher level language and code it to open a browser, go search on google etc...? What is the go to language or the basic procedure to create a program that would do automated work something similar like above?
.NET platform. Use OpenXML to write the Excel doc. Probably your local phone book company has a nice and detailed database they have exposed through web services or something similar - you really don't want to scrape pages, that is not only hard but also unreliable. That's how I would do it, at least.
|
|
|
On July 04 2013 02:14 bangsholt wrote:Show nested quote +On July 04 2013 01:42 Zocat wrote: The problem screams recursion. Go away with your loops. You start with one problem, and apply recursion. Now you have two...
The base case and the inductive step? 
|
Hyrule19173 Posts
I like to watch that a few times a year. :D
|
On July 04 2013 05:11 tofucake wrote:I like to watch that a few times a year. :D
Yeah it's pretty wat ^^
|
I am learning about arrays in C++ right now (total newbie btw) and I can see the amount of complexity that this will lead to. I'm guessing there can be multi-dimensional arrays that can indicate points in space in, say, games. My head is about to explode.
|
On July 04 2013 06:11 Bayyne wrote: I am learning about arrays in C++ right now (total newbie btw) and I can see the amount complexity that this will lead to. I'm guessing there can be multi-dimensional arrays that can indicate points in space in, say, games. My head is about to explode. There can indeed be multi-dimensional arrays.
Have fun!
|
On July 04 2013 06:11 Bayyne wrote: I am learning about arrays in C++ right now (total newbie btw) and I can see the amount complexity that this will lead to. I'm guessing there can be multi-dimensional arrays that can indicate points in space in, say, games. My head is about to explode.
i dont think you would use it for points in space, after all most of space is 'nothingness', but definitely for standard games. Minecraft for example uses in a theoretical sense, 5D arrays, but that still amounts to the same amount of blocks as a 3D array would, just better organised for various things.
|
On July 04 2013 08:27 CptCutter wrote:Show nested quote +On July 04 2013 06:11 Bayyne wrote: I am learning about arrays in C++ right now (total newbie btw) and I can see the amount complexity that this will lead to. I'm guessing there can be multi-dimensional arrays that can indicate points in space in, say, games. My head is about to explode. i dont think you would use it for points in space, after all most of space is 'nothingness', but definitely for standard games. Minecraft for example uses in a theoretical sense, 5D arrays, but that still amounts to the same amount of blocks as a 3D array would, just better organised for various things.
I think he meant space as in .. 3D space and vectors lol
|
On July 03 2013 03:56 WindWolf wrote: Anyone else using Visual Studio 2012 Update 3 (more specifically, for C++-programming) on 64-bit Windows 7 that has problems that it freezes frequently (and at times, Windows all completely)? Today, it has happened for me a couple of times already, and it's getting really annoying. Now, as a result, I have to set up a new project because it caused corrupted files. It's not the code files that are the problem, those are on my Dropbox and I can revert should I need it, It's the project itself.
Before the most recent freeze, it said some error message about that my graphics card driver has crashed (I don't know what, I didn't manage to screenshot it). I'm running a Nvidia GeForce 555M with driver 320.49 Update: downgraded to driver 320.18 and now it runs as well as it did before
|
As3 question. I have a friend that wants to make flash games for some extra money and I want to learn some OO so I said why not but learning as3 is the most frustrating thing I've tried since I started programming. I am probably missing something really obvious but I cannot figure out why this won't work.
I have a png of a squid that I want to pop up on the stage where the mouse is when the stage is clicked. Both my trace statements are showing up so I know the stage knows it is being clicked and that the squid class constructor is being called but nothing is showing up on my stage :/
I am doing this just to try and figure out how some of this works; the intent is to maybe eventually have a squid that the player controls or something but I am stuck on this simple junk. I kind of hate as3. Any help is appreciated.
Main Class + Show Spoiler + package { import flash.display.Bitmap; import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; public class Main extends Sprite { public function Main() { stage.addEventListener(MouseEvent.CLICK, createSquid); } public function createSquid(e:MouseEvent):void { trace("stage clicked"); var newSquid:Sprite = new squid(); stage.addChild(newSquid); } } }
Squid Class + Show Spoiler + package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Sprite; public class squid extends Sprite { [Embed(source = "/../lib/Squid.png")] public var squidPic:Class; public function squid() { trace("SQUID"); var mysquid:Bitmap = new squidPic(); mysquid.x = mouseX; mysquid.y = mouseY; addChild(mysquid); } }
}
EDIT: False alarm. Turns out my code works fine but I didn't realize my png was actually a ton of whitespace around my squid which altogether was larger than my stage. I trimmed it down and now it works. I still don't like as3; seems to be a lot of code to do something so simple.
|
On July 06 2013 06:54 Azerbaijan wrote:As3 question. I have a friend that wants to make flash games for some extra money and I want to learn some OO so I said why not but learning as3 is the most frustrating thing I've tried since I started programming. I am probably missing something really obvious but I cannot figure out why this won't work. I have a png of a squid that I want to pop up on the stage where the mouse is when the stage is clicked. Both my trace statements are showing up so I know the stage knows it is being clicked and that the squid class constructor is being called but nothing is showing up on my stage :/ I am doing this just to try and figure out how some of this works; the intent is to maybe eventually have a squid that the player controls or something but I am stuck on this simple junk. I kind of hate as3. Any help is appreciated. Main Class + Show Spoiler + package { import flash.display.Bitmap; import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; public class Main extends Sprite { public function Main() { stage.addEventListener(MouseEvent.CLICK, createSquid); } public function createSquid(e:MouseEvent):void { trace("stage clicked"); var newSquid:Sprite = new squid(); stage.addChild(newSquid); } } }
Squid Class + Show Spoiler + package { import flash.display.Bitmap; import flash.display.BitmapData; import flash.display.Sprite; public class squid extends Sprite { [Embed(source = "/../lib/Squid.png")] public var squidPic:Class; public function squid() { trace("SQUID"); var mysquid:Bitmap = new squidPic(); mysquid.x = mouseX; mysquid.y = mouseY; addChild(mysquid); } }
}
I'm more experienced with AS2 but I'll give this a shot. According to the examples I've looked at online, the code looks alright for the most part. My first suggestion would be to remove the forward slash from your path (ie. "../lib/Squid.png"). Second, verify that the path to your image is accurate, relative to the .swf file's location. After that, I would move 'public var squidPic:Class;' down to a new line below the Embed tag, as it might be that it's looking at the line below and not the same line (that would be strange though).
Typically though, I'm more used to importing items and creating movieclips in the library, and referencing them through their linkage IDs. It might be an alternative option worth exploring if you continue to have trouble. Here's a pretty decent tutorial on it: http://www.atksolutions.com/articles/flash_as3_load_display_sprite.html
EDIT: Oho, apparently I made a poor assumption, the path is supposed to be relative to the .as file, not necessarily the .swf file, as referenced here: http://www.bit-101.com/blog/?p=883
|
On July 04 2013 02:04 heroyi wrote: Not looking for an actual code but instead just a simple draft/explanation on how it would work.
How would one go about creating a program that can automate a simple task of (for example):
search address for companies paste the result in microsoft excel
Assume best case scenario (all addresses are formatted same way and are easily found on web by your program, user is not an idiot). Would you use something like javascript? Or could you use some higher level language and code it to open a browser, go search on google etc...? What is the go to language or the basic procedure to create a program that would do automated work something similar like above?
Might be possible with Autohotkey.
As long as it is only restful interfaces you can use something like curl to interact with websites. I'm not sure if there is a better alternative as I'm not too familiar with rest. If you really need UI automation for something complicated on the web then you need selenium webdriver/ide.
The pasting to excel part should either be done with autohotkey or your language of choice.
|
C++ TCP socket programming question:
I've written a small chat program where the client can send a message to the server. i'm using the following piece of code to establish the connection
sockaddr_in connectionInfo; connectionInfo.sin_addr.s_addr = inet_addr("127.0.0.1"); connectionInfo.sin_family = AF_INET; connectionInfo.sin_port = htons(54345); int connectionInfoLen = sizeof(connectionInfo);
connect(clientSocket, (struct sockaddr*)&connectionInfo,connectionInfoLen);
this works perfectly fine when im using my own pc as both client and server, the IP i enter on both sides is simply 127.0.0.1
But what IP do I use if I want to connect to my friends PC if we both have a router in between? only the router's IPs are unique, so wouldnt i have to specify both the unique router IP as well as the internal IP of the PC?
I searched google but I couldnt find anything related to this, possibly because im not searching for the right keywords.
|
|
|
|
|
|