Post any type of program code you have created. Just don't make it over 500lines :3
edit: I'll post my code as soon as I have time to create a program
edit2: Please make your code only command code (idk what it's called). No gui. Plus it would be cool to see something like mathematical stuff :3
As paddle2see pointed out my original post was really broad, i have now narrowed it down.
Last edited by slinger (2012-02-26 09:49:43)
Offline
Codes? Huh? Did you mean Code? I understand why you said Codes, but there's no plural to Code. "Code" is used no matter how much code there is.
Well, I'm making a chat in Command Prompt (EDIT.exe)! I won't post the code yet, because it's unfinished. But I will post it any time soon.
Offline
rdococ wrote:
Codes? Huh? Did you mean Code? I understand why you said Codes, but there's no plural to Code. "Code" is used no matter how much code there is.
Well, I'm making a chat in Command Prompt (EDIT.exe)! I won't post the code yet, because it's unfinished. But I will post it any time soon.
Command Prompt is cmd.exe not EDIT.exe... EDIT.exe is the MS-DOS text editor. Lol.
Offline
nathanprocks wrote:
rdococ wrote:
Codes? Huh? Did you mean Code? I understand why you said Codes, but there's no plural to Code. "Code" is used no matter how much code there is.
Well, I'm making a chat in Command Prompt (EDIT.exe)! I won't post the code yet, because it's unfinished. But I will post it any time soon.Command Prompt is cmd.exe not EDIT.exe... EDIT.exe is the MS-DOS text editor. Lol.
I know -- I am making it in the MS-DOS text editor.
Offline
nathanprocks wrote:
rdococ wrote:
Codes? Huh? Did you mean Code? I understand why you said Codes, but there's no plural to Code. "Code" is used no matter how much code there is.
Well, I'm making a chat in Command Prompt (EDIT.exe)! I won't post the code yet, because it's unfinished. But I will post it any time soon.Command Prompt is cmd.exe not EDIT.exe... EDIT.exe is the MS-DOS text editor. Lol.
well edit.exe is actually a batch program
Offline
ssss wrote:
nathanprocks wrote:
rdococ wrote:
Codes? Huh? Did you mean Code? I understand why you said Codes, but there's no plural to Code. "Code" is used no matter how much code there is.
Well, I'm making a chat in Command Prompt (EDIT.exe)! I won't post the code yet, because it's unfinished. But I will post it any time soon.Command Prompt is cmd.exe not EDIT.exe... EDIT.exe is the MS-DOS text editor. Lol.
well edit.exe is actually a batch program
Yeah -- I'm using a batch program to make a batch program.
Offline
rdococ wrote:
ssss wrote:
nathanprocks wrote:
Command Prompt is cmd.exe not EDIT.exe... EDIT.exe is the MS-DOS text editor. Lol.well edit.exe is actually a batch program
Yeah -- I'm using a batch program to make a batch program.
I attempted to make a chat script in batch but I epic failed.
Offline
nathanprocks wrote:
rdococ wrote:
ssss wrote:
well edit.exe is actually a batch programYeah -- I'm using a batch program to make a batch program.
I attempted to make a chat script in batch but I epic failed.
Actually, mine does not connect, it's just a chat BOT.
Offline
rdococ wrote:
nathanprocks wrote:
rdococ wrote:
Yeah -- I'm using a batch program to make a batch program.I attempted to make a chat script in batch but I epic failed.
Actually, mine does not connect, it's just a chat BOT.
hehehe. chat bots are difficult
I would know.
Offline
The way you have this defined is really too broad! People can write code that do just about anything on a computer. Can you narrow it down to a particular interest of some sort, say a specific language, or a particular kind of coding that you are interested in? And it would be great if you could start with an example of your own
Offline
Just a quick little java snippet. Even if you don't know java syntax, it should be obvious what it does.
Move.java
import java.awt.AWTException; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Robot; public class Move { static Robot r; static int x = 1000; static int rad = 100; static float i = 0; public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice d = ge.getDefaultScreenDevice(); int h = d.getDefaultConfiguration().getBounds().height; int w = d.getDefaultConfiguration().getBounds().width; try { r = new Robot(); } catch (AWTException e) { // TODO Auto-generated catch block e.printStackTrace(); } while (i < x){ i = (float) (i+0.1); r.delay(1); r.mouseMove((int)(Math.sin(Math.toRadians(i))*rad)+(w/2), (int)(Math.cos(Math.toRadians(i))*rad)+(h/2)); } } }
Offline
VB.net code to receive data from Scratch when in Mesh.
Imports System.Net.Sockets Imports System.Text Module Module1 Sub Main() For value As Integer = 0 To 50 Dim tcpClient As New System.Net.Sockets.TcpClient() tcpClient.Connect("127.0.0.1", 42001) Dim networkStream As NetworkStream = tcpClient.GetStream() If networkStream.CanWrite And networkStream.CanRead Then ' Do a simple write. Dim sendBytes As [Byte]() = Encoding.ASCII.GetBytes("Is anybody there") 'networkStream.Write(sendBytes, 0, sendBytes.Length) ' Read the NetworkStream into a byte buffer. Dim bytes(tcpClient.ReceiveBufferSize) As Byte networkStream.Read(bytes, 0, CInt(tcpClient.ReceiveBufferSize)) ' Output the data received from the host to the console. Dim returndata As String = Encoding.ASCII.GetString(bytes) Console.WriteLine(("Host returned: " + returndata)) Else If Not networkStream.CanRead Then Console.WriteLine("cannot not write data to this stream") tcpClient.Close() Else If Not networkStream.CanWrite Then Console.WriteLine("cannot read data from this stream") tcpClient.Close() End If End If End If Threading.Thread.Sleep(4000) Next End Sub End Module
Offline
Some C code for finding the fibonacci pattern. I used it for this scratch project.
#include <stdio.h> double getNextNumber(double lastNumber, double lastLastNumber) { double newNumber = lastNumber + lastLastNumber; return newNumber; } void fibonacci(int length) { double lastNumber = 1; double lastLastNumber = -1; double nextNumber = 0; int i = 0; while(i < (length + 1)) { nextNumber = getNextNumber(lastNumber, lastLastNumber); int tempLastNumber = nextNumber; lastLastNumber = lastNumber; lastNumber = tempLastNumber; printf("%G\n", nextNumber); i++; } return; } int main() { fibonacci(30); return 0; }
Output:
Console wrote:
0
1
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
75025
121393
196418
317811
514229
832040
And surface area of a cylinder code:
#include <stdio.h> #define PI 3.14 int main() { float diameter; float height; float radius; float surfaceArea; printf("Please enter a diameter: "); scanf("%f", &diameter); printf("Please enter a height: "); scanf("%f", &height); radius = diameter/2; //Surface Area of a cylinder is 2PIr^2 + 2PIrh surfaceArea = (2 * PI * (radius * radius)) + (2 * PI * radius * height); printf("\nDiamater is %f, and height is %f\n", diameter, height); printf("\nSurface Area is %.3f\n", surfaceArea); return 0; }
And extremely simple C code (try to figure this out )
#include <stdio.h> int main() { printf("Hello World!\n"); return 0; }
Last edited by gbear605 (2012-02-25 09:48:05)
Offline
hmm I don't know what that code does, lol!
I'm working on a "Words with Philosoraptor" program that retrieves a random quote and then outputs it I just need more quotes now, lol.
Offline
Woot, I made it now so that it can use ANY length of text file perfectly! It uses a loop to check how many lines are in the file, then outputs it.
Offline
final static int NORTH = 1; final static int EAST = 2; final static int SOUTH = 4; final static int WEST = 8; int result; float x,y,mx,my; PImage imgTitle = loadImage("http://www.majhost.com/gallery/veggieman/requests/title.png"); PImage imgChar = loadImage("http://www.majhost.com/gallery/veggieman/requests/veggie.png"); PImage imgChar2 = loadImage("http://www.majhost.com/gallery/veggieman/requests/veggie2.png"); PImage imgMuffin = loadImage("http://www.majhost.com/gallery/veggieman/requests/muffin.png"); int nScreen = 0; int nDirection = 0; boolean bMuffin = false; int nScore = 0; int nTime = 60; int nTimeCount; PFont fntScore; void setup() { size(640,480); frameRate(30); result = 0; x = width/2; y = height/2; mx = width/2+50; my = height/2+50; background(imgTitle); //fntScore = loadFont("Arial"); } void draw() { if (nScreen==1){ if (nTime==0) { nScreen=2; } background(255,156,231); switch(result) { case NORTH: y-=ceil(nTime/6); break; case EAST: x+=ceil(nTime/6); nDirection=0; break; case SOUTH: y+=ceil(nTime/6); break; case WEST: x-=ceil(nTime/6); nDirection=1; break; case NORTH|EAST: y-=ceil(nTime/6); x+=ceil(nTime/6); nDirection=0; break; case NORTH|WEST: y-=ceil(nTime/6); x-=ceil(nTime/6); nDirection=1; break; case SOUTH|EAST: y+=ceil(nTime/6); x+=ceil(nTime/6); nDirection=0; break; case SOUTH|WEST: y+=ceil(nTime/6); x-=ceil(nTime/6); nDirection=1; break; } if (x<=49) x=49; if (x>=width-49) x=width-49; if (y<=59) y=59; if (y>=height-59) y=height-59; imageMode(CENTER); if (!bMuffin){ mx = round(random(20,620)); my = round(random(20,460)); bMuffin=true; } image(imgMuffin,mx,my); if (nDirection==0) image(imgChar,x,y); if (nDirection==1) image(imgChar2,x,y); if (dist(x,y,mx,my)<=50){ nScore+=(round(nTime/6)+5); bMuffin=false; } if (nTimeCount != second()){ nTime--; nTimeCount = second(); } // textFont(fntScore,18); // text("Score: " + nScore, 5, 20); text("Time: " + nTime, 5, 20); } if (nScreen==2){ background(255,255,0); textFont(fntScore,22); fill(0); text("Score: " + nScore, width/2-75, height/2); } } void keyPressed(){ switch(key) { case('w'):case('W'):result |=NORTH;break; case('d'):case('D'):result |=EAST;break; case('s'):case('S'):result |=SOUTH;break; case('a'):case('A'):result |=WEST;break; case(' '): nScreen=1;nTimeCount=second();break; } } void keyReleased(){ switch(key) { case('w'):case('W'):result ^=NORTH;break; case('d'):case('D'):result ^=EAST;break; case('s'):case('S'):result ^=SOUTH;break; case('a'):case('A'):result ^=WEST;break; } } void mousePressed(){ if((mouseX>width/2-50)&&(mouseX<width/2+50)){ if((mouseY>height/2+20)&&(mouseY<height/2+70)){ nScreen=0; } } }
Offline
veggieman001 wrote:
Code:
final static int NORTH = 1; final static int EAST = 2; final static int SOUTH = 4; final static int WEST = 8; int result; float x,y,mx,my; PImage imgTitle = loadImage("http://www.majhost.com/gallery/veggieman/requests/title.png"); PImage imgChar = loadImage("http://www.majhost.com/gallery/veggieman/requests/veggie.png"); PImage imgChar2 = loadImage("http://www.majhost.com/gallery/veggieman/requests/veggie2.png"); PImage imgMuffin = loadImage("http://www.majhost.com/gallery/veggieman/requests/muffin.png"); int nScreen = 0; int nDirection = 0; boolean bMuffin = false; int nScore = 0; int nTime = 60; int nTimeCount; PFont fntScore; void setup() { size(640,480); frameRate(30); result = 0; x = width/2; y = height/2; mx = width/2+50; my = height/2+50; background(imgTitle); //fntScore = loadFont("Arial"); } void draw() { if (nScreen==1){ if (nTime==0) { nScreen=2; } background(255,156,231); switch(result) { case NORTH: y-=ceil(nTime/6); break; case EAST: x+=ceil(nTime/6); nDirection=0; break; case SOUTH: y+=ceil(nTime/6); break; case WEST: x-=ceil(nTime/6); nDirection=1; break; case NORTH|EAST: y-=ceil(nTime/6); x+=ceil(nTime/6); nDirection=0; break; case NORTH|WEST: y-=ceil(nTime/6); x-=ceil(nTime/6); nDirection=1; break; case SOUTH|EAST: y+=ceil(nTime/6); x+=ceil(nTime/6); nDirection=0; break; case SOUTH|WEST: y+=ceil(nTime/6); x-=ceil(nTime/6); nDirection=1; break; } if (x<=49) x=49; if (x>=width-49) x=width-49; if (y<=59) y=59; if (y>=height-59) y=height-59; imageMode(CENTER); if (!bMuffin){ mx = round(random(20,620)); my = round(random(20,460)); bMuffin=true; } image(imgMuffin,mx,my); if (nDirection==0) image(imgChar,x,y); if (nDirection==1) image(imgChar2,x,y); if (dist(x,y,mx,my)<=50){ nScore+=(round(nTime/6)+5); bMuffin=false; } if (nTimeCount != second()){ nTime--; nTimeCount = second(); } // textFont(fntScore,18); // text("Score: " + nScore, 5, 20); text("Time: " + nTime, 5, 20); } if (nScreen==2){ background(255,255,0); textFont(fntScore,22); fill(0); text("Score: " + nScore, width/2-75, height/2); } } void keyPressed(){ switch(key) { case('w'):case('W'):result |=NORTH;break; case('d'):case('D'):result |=EAST;break; case('s'):case('S'):result |=SOUTH;break; case('a'):case('A'):result |=WEST;break; case(' '): nScreen=1;nTimeCount=second();break; } } void keyReleased(){ switch(key) { case('w'):case('W'):result ^=NORTH;break; case('d'):case('D'):result ^=EAST;break; case('s'):case('S'):result ^=SOUTH;break; case('a'):case('A'):result ^=WEST;break; } } void mousePressed(){ if((mouseX>width/2-50)&&(mouseX<width/2+50)){ if((mouseY>height/2+20)&&(mouseY<height/2+70)){ nScreen=0; } } }
Javascript? Yeah.
Offline