PDA

View Full Version : Alan Turing's Thread of Algorithmic Process Specification


Fenrir
20-07-2009, 11:23 PM
Aka The Programming Thread, but don't let me stop you from posting up your UTM (http://en.wikipedia.org/wiki/Universal_Turing_machine) schematic work-in-progress here and requesting debugging assistance.

Anyway, lacking any need for this thread, or programs to brag about at the moment, I'll get this baby started with a few amusing (if typical) links:

Laziness Impatience Hubris
http://c2.com/cgi/wiki?LazinessImpatienceHubris

If programming languages were religions
http://www.aegisub.net/2008/12/if-programming-languages-were-religions.html

Cheers.

EDIT:

TVTropes: Hollywood Hacking
http://tvtropes.org/pmwiki/pmwiki.php/Main/HollywoodHacking

SOX
20-07-2009, 11:33 PM
Finally got a programming job while Hyper was down.
No C or C++ which is a shame, all web programming :/

I actually started today, it's kinda like being at uni again as they train us up!

Fenrir
21-07-2009, 12:06 AM
Yar, C/C++ graduate jobs are rare beasts, far as I've heard.

I've got web work at the moment, too, but I'm not lucky enough to be cushily employed. I'm doing an entire site from scratch for a politician, including subsystems for articles, surveys etc, not receiving much for it, and still waiting for the goddamn project to get the go-ahead from the client. :(

Stevorooni
21-07-2009, 02:14 PM
I have to combine 3 different web apps written by 3 different people with 3 different databases so that they use one common database and interact with each other like 1 big app, but at the same time need to be able to separate and work independently. Kind of like Voltron.



Please kill me.

Ashmaran
21-07-2009, 02:39 PM
Oh Stevo, say goodbye to your sanity.

I'm making a game with XNA, coding it in C#. It's been interesting so far, since before this I haven't coded since uni, just a bit of scripting here and there.

SOX
21-07-2009, 07:00 PM
The hardest part is finding the will to finish a project. I have no problem starting them..

Dust
21-07-2009, 08:35 PM
Just finished writing an algorithm to generate the Von Koch Snowflake [wish I had better math skills :confused:] and I'm currently working on building a landscape generator using fractals [well hopefully :p]

SOX
21-07-2009, 09:24 PM
and I'm currently working on building a landscape generator using fractals [well hopefully :p]

I had to do that for uni, looked pretty cool after I finished

Dust
21-07-2009, 10:00 PM
mind if I borrow it? :p

Fenrir
23-07-2009, 01:51 AM
Am currently building the engine for a 2D top-down shooter, codenamed "Vae", in VB.NET. The engine will go on to be the foundation of that game I started a thread for long ago.

Having implemented 90% of my projects in Java over the past year, VB.NET feels clumsy by comparison - writing a compiler for the language must be a nightmare. The syntax makes determining whether something's a method or a public variable or a property a nightmare; the language seems mostly strongly-typed, but either functions aren't fussed about return types, or the IDE isn't fussed about rattling you for one; I miss the C family's "==" comparer, too; and arrays are annoying **** out of me.

I'm only using VB.NET because getting up a GUI form and drawing rectangles to represent region borders is easy and something I'm familiar with. As soon as I bother to figure out graphics with Swing, I'm porting the whole thing over to Java - unless I start learning C#.NET first, which is tempting.

I have to combine 3 different web apps written by 3 different people with 3 different databases so that they use one common database and interact with each other like 1 big app, but at the same time need to be able to separate and work independently. Kind of like Voltron.
Haha, oh god. How different are the data models?

I'm making a game with XNA, coding it in C#. It's been interesting so far, since before this I haven't coded since uni, just a bit of scripting here and there.
What sort of game?

The hardest part is finding the will to finish a project. I have no problem starting them..
...finish? :confused: I only ever keep going with something long enough to prove a concept or bolster my ego, then drop it completely.



Maybe this is why I can't get employed. >_>

Ashmaran
23-07-2009, 02:18 PM
It's a puzzle game. The most complicated graphical thing I am doing is the line drawing, which I'm using someone else's class for anyway, to get nice rounded lines.

You can read more about it here (http://www.ashmaran.com/stargazer.htm)

Stevorooni
23-07-2009, 07:41 PM
Haha, oh god. How different are the data models?


There are vague similarities but they're different enough to make me it a nightmare.

Plus the apps are in .NET with one being written in VB and the other 2 in C# (which I can read and follow easily enough but haven't had much experience writing in) so rather than rewriting them I'm just kind of stapling them together >_>

Fenrir
24-07-2009, 01:59 AM
Actually, you might be able to help me with a problem I'm having in VB.NET.

Class System.Drawing.Pens contains a series of shared readonly properties representing common Pen instances, such as:

System.Drawing.Pens.AliceBlue
System.Drawing.Pens.AntiqueWhite
System.Drawing.Pens.Aqua
System.Drawing.Pens.Aquamarine
etc.

I want an array, or a Collection, or some sort of list I can iterate through programmatically, of all of these Pen instances, without manually typing out something like...

Dim pens(one quadrillion) As System.Drawing.Pen
pens(0) = System.Drawing.Pens.AliceBlue
pens(1) = System.Drawing.Pens.AntiqueWhite
'etc.

I tried getting at System.Drawing.Pens' property list with:

System.Type.GetType("System.Drawing.Pens").GetProperties()

...but that just served up a NullReferenceException. Got any ideas?

There are vague similarities but they're different enough to make me it a nightmare.
Yar, I can imagine. One guy representing contact details with three entities, while some other prick* does it with seven; a suburb name as a string attribute of an address entity in one database, while in the other an address entity has a many-to-many relationship with a city entity, etc.

You probably can't even just adapt the data access code once you've redesigned the database, because whole subsystems won't deal with data required in the new model. I imagine I'd profile the project as a rewrite. :p


*I'd probably be this prick. >_>

It's a puzzle game. The most complicated graphical thing I am doing is the line drawing, which I'm using someone else's class for anyway, to get nice rounded lines.

You can read more about it here (http://www.ashmaran.com/stargazer.htm)
It's great that you're getting into XNA for this, but I'd probably be doing it with GDI+ myself :P

Ashmaran
24-07-2009, 10:43 AM
You know I hadn't heard of that until now, and reading up on it I'm still happy I went with XNA lol. I'd much rather work with something I'd actually use again and has relevance in the industry.

Also I'm kinda surprised at why you guys are messing around with VB. I've never heard of anyone finding a decent job with it, it's always the hacky hair pulling dodgy in-house apps from years ago...

Fenrir
24-07-2009, 05:20 PM
You know I hadn't heard of that until now, and reading up on it I'm still happy I went with XNA lol. I'd much rather work with something I'd actually use again and has relevance in the industry.
Yeah, I encourage it. I'm only working with GDI+ because I'm more interested in getting logic up, and figuring out a more involved (or even different) graphics library is an interruption I don't want at the moment.

Also I'm kinda surprised at why you guys are messing around with VB. I've never heard of anyone finding a decent job with it, it's always the hacky hair pulling dodgy in-house apps from years ago...
To be fair, VB.NET is worlds beyond the likes of VB6 and prior, and there's little (if any) reason why systems developed using it can't be of the calibre of an equivalent done in C#.NET. That said, BASIC-derived languages tend to be seen as "easier" to grasp, and the industry would rather pay less for a VB guy than fork out for someone with an intricate knowledge of a curly-brace language.

Me? Like I said, I'm in it for the .NET encapsulation of GDI+, and haven't bothered to learn C#.NET yet.


Oh, and I figured out my problem, with some help from over at Whirlpool.

Dim pens() As Pen
Dim properties() As System.Reflection.PropertyInfo

properties = GetType(System.Drawing.Pens).GetProperties( _
Reflection.BindingFlags.Static + _
Reflection.BindingFlags.Public)
ReDim pens(properties.Length - 1)
For i = 0 To properties.Length - 1
pens(i) = properties(i).GetGetMethod().Invoke(New Object, Nothing)
Next

Dust
26-07-2009, 11:02 PM
you really should try getting into C# even I found it quite a nice change of pace, and I loves me some pointers...

but seriously, good easy integration of a graphics engine [that's also free] into C# can be found with Mogre and using WPF or Window Forms is fairly intuitive. I wonder if CEGUI plays nicely in C#? should check it out.

Stevorooni
27-07-2009, 10:12 AM
So what is everyone's opinion on Silverlight?

At work we're thinking about using it but I'm against it as to me it looks like Microsoft's ripoff of Flash which means it'll be a head**** to use and probably expensive and time consuming.

Fenrir
27-07-2009, 06:04 PM
Looks like Microsoft's answers to Flash and the Java Applet, bundled into one - not that I've used it.
I'd use it over Flash; but it's still another binary blob in the browser, so I'm not interested. That, and the web is being stretched like a $2 whore, to the point where I'm practically incapable of quantifying what it "is" outside of describing the tools it comprises. I'd rather see the sort of client-side apps Silverlight enables be developed on a managed app framework like .NET or Java SE, to run as individual processes with real GUIs.

you really should try getting into C# even I found it quite a nice change of pace, and I loves me some pointers...

but seriously, good easy integration of a graphics engine [that's also free] into C# can be found with Mogre and using WPF or Window Forms is fairly intuitive. I wonder if CEGUI plays nicely in C#? should check it out.
It's not really about the graphics tools for me, at the moment - I just don't want to battle the language while I'm trying to flesh out the logic. If I went over to C# right now, I'd probably keep going with System.Drawing.

Fenrir
30-07-2009, 03:01 AM
Am currently building the engine for a 2D top-down shooter, codenamed "Vae", in VB.NET. The engine will go on to be the foundation of that game I started a thread for long ago.
Working on the maths behind the collision detection at the moment, the following code is my working attempt to derive an a priori formula (or formulae) to determine when a moving line with intersect with a moving point.
'Time
Dim t As Double '= time
Dim tinc As Double '= t increment per frame
'Point P
Dim xP As Double '= original x coordinate of P
Dim yP As Double '= original y coordinate of P
Dim u As Double '= speed component of velocity of P, in displacement per increment of t
Dim θ As Double '= direction component of velocity of P, in degrees from the y axis
'Point A
Dim xA As Double '= horizontal displacement of A from P
Dim yA As Double '= vertical displacement of A from P
'Point B
Dim xB As Double '= horizontal displacement of B from P
Dim yB As Double '= vertical displacement of B from P

'Point Q
Dim xQ As Double '= original x coordinate of Q
Dim yQ As Double '= original y coordinate of Q
Dim v As Double '= speed component of velocity of Q, in displacement per increment of t
Dim φ As Double '= direction component of velocity of Q, in degrees from the y axis

'...

Private Function lineAB(ByVal x As Double, ByVal t As Double) As Double
Dim mAB As Double = (yB - yA) / (xB - xA)
Return (mAB * x - mAB * xP - mAB * xA - mAB * u * Math.Sin(θ) * t + yP + yA + u * Math.Cos(θ) * t)
End Function

Private Function trajectoryofQ(ByVal x As Double) As Double
Return ((1 / Math.Tan(φ)) * x + yQ - (1 / Math.Tan(φ)) * xQ)
End Function

Private Function lineABtrajectoryofQintersect(ByVal t As Double) As PointF
Dim mAB As Double = (yB - yA) / (xB - xA)
Dim x As Double = ((1 / Math.Tan(φ)) * xQ - yQ - mAB * xP - mAB * xA - mAB * u * Math.Sin(θ) * t + yP + yA + u * Math.Cos(θ) * t) / ((1 / Math.Tan(φ)) - mAB)
Return New PointF(x, trajectoryofQ(x))
End Function

Private Function currentP(ByVal t As Double) As PointF
Return New PointF((xP + u * Math.Sin(θ) * t), (yP + u * Math.Cos(θ) * t))
End Function
Private Function currentA(ByVal t As Double) As PointF
Return New PointF((xP + u * Math.Sin(θ) * t + xA), (yP + u * Math.Cos(θ) * t + yA))
End Function
Private Function currentB(ByVal t As Double) As PointF
Return New PointF((xP + u * Math.Sin(θ) * t + xB), (yP + u * Math.Cos(θ) * t + yB))
End Function

Private Function currentQ(ByVal t As Double) As PointF
Return New PointF((xQ + v * Math.Sin(φ) * t), (yQ + v * Math.Cos(φ) * t))
End Function
My baby will have a priori detection yet! :D

(and er, no, I haven't factored in rotation yet :( )

EDIT:
Private Function intersectionpoint() As PointF
Dim mAB As Double = (yB - yA) / (xB - xA)
Dim x As Double = (((1 / Math.Tan(φ)) * xQ - yQ - mAB * xP - mAB * xA + yP + yA) / ((1 / Math.Tan(φ)) - mAB) - xQ * ((u * Math.Cos(θ) - mAB * u * Math.Sin(θ)) / (((1 / Math.Tan(φ)) - mAB) * (v * Math.Sin(φ))))) / (1 - ((u * Math.Cos(θ) - mAB * u * Math.Sin(θ)) / (((1 / Math.Tan(φ)) - mAB) * (v * Math.Sin(φ)))))
Return New PointF(x, trajectoryofQ(x))
End Function
Er...needs a bit of factoring. But **** me, that's it! :D

Dust
08-08-2009, 08:45 PM
What do you mean a moving line?

Sorry, VB code makes my eyes go fuzzy :p which equations are you using? [I always love learning more maths]

Fenrir
09-08-2009, 06:40 AM
Moving line as in, edge of a moving polygon in 2D space.
The functions above are a fairly long way away from the equations I derived them from, bit it's essentially classical mechanics and line geometry. I'm thinking about writing a tutorial on this stuff once I've got the entire engine in a working state.

Also, I'll probably be moving away from VB.NET again soon, since System.Drawing is starting to become a bit resource-greedy. Considering XNA and JOGL.

SOX
10-08-2009, 02:17 PM
Could just go C++/OpenGL instead of proprietary MS - just saying..
Or even for ease of making a game, just use an existing engine (that's what I'm doing at the moment, using Quake 1's)

Fenrir
10-08-2009, 03:51 PM
I'm far too proud to use an existing engine :P

Anyway, JOGL (Java/OpenGL) is probably the least proprietary MS route available, in that it abstracts away the native Win32 API stuff (which I'm just guessing is still necessary in C++/OpenGL work). I'm also growing fond of managed code, even to the point of looking forward to the demise of native application development.

On that note, I'm probably going to port my work over to Java very soon, mainly because of a bizarre freak bug in the system at the moment that I can't make any sense of.

EDIT: I figured out said bug; a design decision bit me in the arse, basically. I've gotta stop implementing collision response like as if it were makeshift test code.

SOX
10-08-2009, 06:23 PM
in that it abstracts away the native Win32 API stuff (which I'm just guessing is still necessary in C++/OpenGL work).

Really depends on what API's you are using, but most things I did could be easily ported to my Mac just by changing the include path of OpenGL. Haven't really thought about using Java with OpenGL - seems kinda wrong for some reason..

Fenrir
16-08-2009, 09:52 AM
Ah, I didn't realize this (http://en.wikipedia.org/wiki/OpenGL_Utility_Toolkit) existed. My bad.
Yar, I'm not sure what to make of JOGL myself, either - I don't know how the JNI bindings work, or how the data types are mapped. It's not an OO library, just an exposure of the procedural calls in Java - an alternate library known as Java 3D (http://en.wikipedia.org/wiki/Java_3D) exists offering an OO-paradigm API.


Anyway, posting to ask what IDE(s) people here are using for their C++ work. I've used Visual Studio sparingly, installed DevC++ and Code::Blocks to have a look but never really did anything with them - in fact most of my C++ work (console and Win32) has been notepad (++ (http://notepad-plus.sourceforge.net/uk/site.htm)) and calling free compilers (mainly Digital Mars (http://www.digitalmars.com/)) via command prompt. I've been considering forking out the fifty bucks for the Digital Mars dev system, if out of nothing more than curiosity.
I'd mainly be looking for good flexible integration with cross-compiler/dev tools and third-party libraries, since I have in mind writing native code for a few non-Wintel platforms; but mainly I'm hoping for the definitive high-end IDE, and cbf delving too far into the features of any given compiler before abandoning it for something else.

I'm pretty happy with Netbeans for my Java, though I'm planning on giving Eclipse a shot soon. Both offer C++ packs, which I figure I should give a shot soon, too, but I gather both are biased in favour of Java development.
I've never felt the need to stray away from Visual Studio for .NET (VB currently, C# soon) work, and TAFE just gave me a full 2008 install disc, so I'm fine there. :cool: Planning on getting MonoDevelop working eventually, though, since non-Windows .NET antics interest me greatly.
I should probably also get an IDE together for PHP, since it's the other language I use a lot. I'm the sort to steer clear of Adobe products (ie Dreamweaver) though, and I'm not really interested in a system where the developers have based big design decisions around assumptions about the sorts of web apps I'm going to develop. Notepad++ does the basic syntax highlighting, so that's probably fine.

SOX
16-08-2009, 09:59 AM
I used glut when doing OpenGL programming.

As for IDE use Visual Studio 2008 (2005 is good too). Don't bother with the Express version.

Notepad++ is fine for procedural programming but u really need an IDE for OO programming and compiling.

Orrr alternatively you could use xCode which is a great free IDE for Macs.

Fenrir
16-08-2009, 10:27 AM
As for IDE use Visual Studio 2008 (2005 is good too). Don't bother with the Express version.
Yar, the Express edition required a whole shitheap of pre-configuration last time I used it, things like downloading the Windows SDK and integrating it with VC++ Express before you can do Win32 work. I'm not going back there. The VB.NET/C#.NET Express packages haven't let me down yet, though, and C++/CLI might've been similarly complete (I really didn't want to learn it, though >_>).

I'll install VS2008 soon. Would you use it for non-Wintel work?

Notepad++ is fine for procedural programming but u really need an IDE for OO programming and compiling.
Hmm, I didn't really have any problem with my OO C++ work with Notepad++. Being able to browse through class, method and property lists, etc at whim, using a high-end IDE, is pretty sweet, though.

Another question - as a game developer, what do you use for the design/modelling phase of the SDLC? I've been trained in UML, but use cases don't really seem to suit anything where a game loop is involved.

SOX
16-08-2009, 01:10 PM
We used ArgoUML

Fenrir
16-08-2009, 02:25 PM
Hmm,
ArgoUML does not yet completely implement the UML standard[2] and is lacking full support for some diagram types including sequence diagrams.[3]
"Undo" has been a perpetually requested feature since 2003.
http://en.wikipedia.org/wiki/ArgoUML

Alright, that last quote is a bit cheap. :P
Anyway, I more meant methodology, rather than software.

Halt, Hammerzeit
18-08-2009, 04:36 PM
I feel a bit like a kid asking a sporting superstar for help here, but I haven't done much programming for ages and need some help.

I'm update the intranet resourses for telecommunications and there's a resource I'm trying to translate into an interactive table. The menu system is for when people ring into my work's voicemail server and there's lots of different options and menus to navigate through and it's quite complex (for the people that work here anyway). I've found a quick reference card that explains the different menus and I'm trying to convert that into javascipt code.

I started by creating arrays for all the different menus and filling the arrays with the different options available. Eventually I'm going to program alerts to pop up explaining the function of each menu item (which is the easy part) but what I'm planning on doing is using tables to illustrate going between menus. For instance, when you first log into the voicemail server you get the main menu (which will be represented by a 3x4 table) and when you press '7' it takes you to a different menu (which I would like to pop up next to the current table with the options in the new menu).

The only way I can think of doing it at the moment is have a pre-defined table with empty text fields that you can change with an onMouseClick(document.write()) command, but ideally I'd like to have nothing there until the '7' button is clicked in the table.

This is the coding I have at the moment. I've defined the six menus as arrays already, but only have two menus coded in the body of the HTML file. Basically what I want is to click 7 of the first menu (labelled "Message Commands") and for the second menu to appear to the right of it.

<html>

<head>
<title>Voicemail Command Quick Reference</title>

<script type="text/javascript">
var mainmenu = new Array();
mainmenu[0] = "Skip Backwards";
mainmenu[1] = "Play";
mainmenu[2] = "Skip Forward";
mainmenu[3] = "Previous Message";
mainmenu[4] = "Record";
mainmenu[5] = "Next Message";
mainmenu[6] = "Message Commands";
mainmenu[7] = "Mailbox Commands";
mainmenu[8] = "Call Sender";
mainmenu[9] = "Help";
mainmenu[10] = "Attendant";
mainmenu[11] = "Stop/Exit";

var mescomm = new Array();
mescomm[0] = "Reply";
mescomm[1] = "Play envelope";
mescomm[2] = "Forward";
mescomm[3] = "Reply All";
mescomm[4] = "Compose";
mescomm[5] = "Delete/Restore";
mescomm[6] = "Nil";
mescomm[7] = "Nil";
mescomm[8] = "Send";
mescomm[9] = "Message Help";
mescomm[10] = "Message Options";
mescomm[11] = "Cancel/Exit";

var mesopt = new Array();
mesopt[0] = "Urgent";
mesopt[1] = "Standard";
mesopt[2] = "Economy";
mesopt[3] = "Private";
mesopt[4] = "Acknowledge";
mesopt[5] = "Timed Delivery";
mesopt[6] = "Nil";
mesopt[7] = "Nil";
mesopt[8] = "Nil";
mesopt[9] = "Options Help";
mesopt[10] = "Nil";
mesopt[11] = "Cancel/Exit";

var mailcomm = new Array();
mailcomm[0] = "Log In";
mailcomm[1] = "Greetings";
mailcomm[2] = "Log Off";
mailcomm[3] = "Password Change";
mailcomm[4] = "Distribution Lists";
mailcomm[5] = "Go To A Message";
mailcomm[6] = "Nil";
mailcomm[7] = "Nil";
mailcomm[8] = "Personal Verification";
mailcomm[9] = "Mailbox Help";
mailcomm[10] = "Mailbox Options";
mailcomm[11] = "Cancel/Exit";

var mailgreet = new Array();
mailgreet[0] = "External Greeting";
mailgreet[1] = "Internal Greeting";
mailgreet[2] = "Temporary Greeting";
mailgreet[3] = "Nil";
mailgreet[4] = "Nil";
mailgreet[5] = "Nil";
mailgreet[6] = "Nil";
mailgreet[7] = "Nil";
mailgreet[8] = "Nil";
mailgreet[9] = "Greeting Help";
mailgreet[10] = "Nil";
mailgreet[11] = "Cancel/Exit";

var mailopt = new Array();
mailopt[0] = "Changer Operator";
mailopt[1] = "Remote Notification";
mailopt[2] = "Nil";
mailopt[3] = "Nil";
mailopt[4] = "Nil";
mailopt[5] = "Nil";
mailopt[6] = "Nil";
mailopt[7] = "Nil";
mailopt[8] = "Nil";
mailopt[9] = "Options Help";
mailopt[10] = "Nil";
mailopt[11] = "Cancel/Exit";

</script>
</head>

<body>

<table border="1" width="33%" name=mainmenugrid>
<tr>
<td width="120" align="center">
<p align="center"><input type="submit" value="1" name="main1"></p>
<script type="text/javascript">document.write(mainmenu[0]);</script>
</td>
<td width="120" align="center">
<p align="center"><input type="submit" value="2" name="main2"></p>
<script type="text/javascript">document.write(mainmenu[1]);</script>
</td>
<td width="120" align="center">
<p align="center"><input type="submit" value="3" name="main3"></p>
<script type="text/javascript">document.write(mainmenu[2]);</script>
</td>
</tr>

<tr>
<td width="120" align="center">
<p align="center"><input type="submit" value="4" name="main4"></p>
<script type="text/javascript">document.write(mainmenu[3]);</script>
</td>
<td width="120" align="center">
<p align="center"><input type="submit" value="5" name="main5"></p>
<script type="text/javascript">document.write(mainmenu[4]);</script>
</td>
<td width="120" align="center">
<p align="center"><input type="submit" value="6" name="main6"></p>
<script type="text/javascript">document.write(mainmenu[5]);</script>
</td>
</tr>
<tr>
<td width="120" align="center">
<p align="center"><input type="submit" value="7" name="main7"></p>
<script type="text/javascript">document.write(mainmenu[6]);</script>
</td>
<td width="120" align="center">
<p align="center"><input type="submit" value="8" name="main8"></p>
<script type="text/javascript">document.write(mainmenu[7]);</script>
</td>
<td width="120" align="center">
<p align="center"><input type="submit" value="9" name="main9"></p>
<script type="text/javascript">document.write(mainmenu[8]);</script>
</td>
</tr>
<tr>
<td width="120" align="center">
<p align="center"><input type="submit" value="*" name="main10"></p>
<script type="text/javascript">document.write(mainmenu[9]);</script>
</td>
<td width="120" align="center">
<p align="center"><input type="submit" value="0" name="main11"></p>
<script type="text/javascript">document.write(mainmenu[10]);</script>
</td>
<td width="120" align="center">
<p align="center"><input type="submit" value="#" name="main12"></p>
<script type="text/javascript">document.write(mainmenu[11]);</script>
</td>
</tr>
</table><br>
<br>
<hr>
<br>
<table border="1" width="33%" name=mescommgrid>
<tr>
<td width="120" align="center">
<p align="center"><input type="submit" value="1" name="mescomm1"></p>
<script type="text/javascript">document.write(mescomm[0]);</script>
</td>
<td width="120" align="center">
<p align="center"><input type="submit" value="2" name="mescomm2"></p>
<script type="text/javascript">document.write(mescomm[1]);</script>
</td>
<td width="120" align="center">
<p align="center"><input type="submit" value="3" name="mescomm3"></p>
<script type="text/javascript">document.write(mescomm[2]);</script>
</td>
</tr>

<tr>
<td width="120" align="center">
<p align="center"><input type="submit" value="4" name="mescomm4"></p>
<script type="text/javascript">document.write(mescomm[3]);</script>
</td>
<td width="120" align="center">
<p align="center"><input type="submit" value="5" name="mescomm5"></p>
<script type="text/javascript">document.write(mescomm[4]);</script>
</td>
<td width="120" align="center">
<p align="center"><input type="submit" value="6" name="mescomm6"></p>
<script type="text/javascript">document.write(mescomm[5]);</script>
</td>
</tr>
<tr>
<td width="120" align="center">
<p align="center"><input type="submit" value="7" name="mescomm7"></p>
<script type="text/javascript">document.write(mescomm[6]);</script>
</td>
<td width="120" align="center">
<p align="center"><input type="submit" value="8" name="mescomm8"></p>
<script type="text/javascript">document.write(mescomm[7]);</script>
</td>
<td width="120" align="center">
<p align="center"><input type="submit" value="9" name="mescomm9"></p>
<script type="text/javascript">document.write(mescomm[8]);</script>
</td>
</tr>
<tr>
<td width="120" align="center">
<p align="center"><input type="submit" value="*" name="mescomm10"></p>
<script type="text/javascript">document.write(mescomm[9]);</script>
</td>
<td width="120" align="center">
<p align="center"><input type="submit" value="0" name="mescomm11"></p>
<script type="text/javascript">document.write(mescomm[10]);</script>
</td>
<td width="120" align="center">
<p align="center"><input type="submit" value="#" name="mescomm12"></p>
<script type="text/javascript">document.write(mescomm[11]);</script>
</td>
</tr>
</table>


</body>

</html>

SOX
18-08-2009, 05:58 PM
I'm currently having to deal with Javascript and CSS at work (never had to do it in my life before, but now - everyday!)

I'm pretty amateur at this, but I found this which should gives you some ideas how to solve your problem.

<script type="text/javascript">
<!--
function toggle_visibility(id) {
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}
//-->
</script>
Javascript to hide an object

<a href="#" onclick="toggle_visibility('foo');">Click here to toggle visibility of element #foo</a>
<div id="foo">This is foo</div>

You would just replace the <a href> with your 7 button code
and the <div> tags would go around your second dropbox

Halt, Hammerzeit
18-08-2009, 06:46 PM
You, sir, are a god amoungst men. It's moments like this I miss pep and, at the same time, wish there had been a double-pep option.

SOX
18-08-2009, 07:02 PM
So did it work? Just post ur pep message in my profile page!

Halt, Hammerzeit
18-08-2009, 07:07 PM
Just been testing it, it works when you click the link, but the text starts off visible. I've been trying varients to make it invisible on load, but I'm having some trouble. Any suggestions?

This is what I've sort of decided is the ebst way to do it, but it doesn't seem to work. I've tried substituting 'block' with 'none' to see if I had the commands around the wrong way, but it doesn't work.

<html>
<head>

<script type="text/javascript">
<!--
function startInvisible()
{
var a = document.getElementById('foo)
a.style.display = 'block';
}


function toggle_visibility(id)
{
var e = document.getElementById(id);
if(e.style.display == 'block')
e.style.display = 'none';
else
e.style.display = 'block';
}

//-->
</script>

</head>

<body onLoad="startInvisible()>

<a href="#" onclick="toggle_visibility('foo');">Click here to toggle visibility of element #foo</a>
<div id="foo">This is foo</div>
</body>
</html>

Fenrir
18-08-2009, 07:30 PM
Hmm,
function startInvisible()
{
var a = document.getElementById('foo)
a.style.display = 'block';
}

If that's how it appears in your code, you're missing an end-quote and a semicolon.

Set it with CSS to begin with, though.
<style type="text/css">
#foo
{
display: none;
}
</style>
More info: http://www.devx.com/tips/Tip/13638
(I haven't read through the entire article, so forgive me if it's tangential/inaccurate in any way)

Also, if you're getting more involved with JavaScript (which it looks like you probably will be), start reading up on DOM scripting. I'll dig up some more links soon, but for now, the W3Schools tutorial (http://www.w3schools.com/htmldom/default.asp) should be a good start. In particular, you can read about changing the structure of a HTML page by altering node (elements, text, etc) properties, such as innerHTML, nodeValue, etc, here (http://www.w3schools.com/htmldom/dom_methods.asp).

The document node's write() method would be a really cumbersome way of altering page content, if it works at all, so I'd advise against it. The display and visibility style properties are probably the easiest way to do what you're doing, though, so I'd probably stick with SOX's idea.

EDIT: <style> tags generally belong in the <head> of your document, btw.

SOX
18-08-2009, 07:32 PM
<div id="foo" style="visibility:hidden">

Try that

EDIT: display is different from visibility, in this case I think visibility is the better choice - just google to see the difference

Fenrir
18-08-2009, 07:39 PM
http://www.devx.com/tips/Tip/13638

*taps the sign* >_>

SOX
18-08-2009, 07:41 PM
Or click that link as it turns out

Halt, Hammerzeit
18-08-2009, 09:59 PM
My head hurts. Now I remember why I stopped doing programming, and this is basic stuff. I think I'm going to want to have it disappear and be activated by a visible button because there's more than one additional menu, so having the secondary table hold its position but not be visible would displace the other secondary table.

Thanks for your help guys. I'll have a play at work tomorrow and see how I go.

Fenrir
18-08-2009, 10:59 PM
My head hurts. Now I remember why I stopped doing programming, and this is basic stuff.
The thing is, most of this isn't a priori (http://en.wiktionary.org/wiki/a_priori) knowledge. If you're looking at the "display" style and thinking the meanings of the values "block", "inline" and "none" should be self-evident, and that your lack of understanding is due to your failure to logically deduce on face value, then you're making a huge mistake.

Halt, Hammerzeit
19-08-2009, 08:00 AM
It's not just my lack of understanding (I have worked with javascript before, but we're talking 7 or 8 years ago now), but one of the reasons I gave up on programming was the fact that you could write hundreds of lines of code, but put a full stop in the wrong place (like the end-quote and semi colon before) and have to trawl through the code finding the error. I know there's debug options that let you see which line the error's on, but it still annoys me. I'm glad most of this intranet resource can be written in HTML, it's just this bit that I want interactive.

Fenrir
19-08-2009, 09:25 AM
Oh, there are many, many integrated development environments (IDEs) which will cater exactly to your needs there; but firstly, download and install the latest stable version of Notepad++ (http://notepad-plus.sourceforge.net/uk/site.htm). This one probably won't help you track semicolons, but you'll know all about missing end-quotes thanks to syntax-highlighting.

I don't actually use an IDE for my HTML/JavaScript work, but there are plenty of them out there. An IDE will do the syntax-highlighting Notepad++ does, as well as highlight errors, provide information like function/property lists and descriptions dynamically whilst you type, generate some code for you, etc.
I'll see what I can find if you're interested.

Halt, Hammerzeit
19-08-2009, 09:30 AM
Nah, that's ok. My work has locked out the installation of new programs on their computers. My work computer has a copy of Frontpage 2003 (not the best, but it does have a little bit of what you describe), so I'll keep using that. I could work on this at home, but then I don't get paid for it, and I'm not that keen to get this done.

Fenrir
19-08-2009, 11:29 AM
Oh dear god, Frontpage? If they expect you at all to develop a system for them, they should be lenient about installing basic tools for the purpose.

If installation isn't an option, though, Notepad++ can be configured for use without an install. The PortableApps.com (http://portableapps.com/) implementation might be easiest for you.

Ashmaran
19-08-2009, 11:59 AM
Yeah I'm a fan of notepad++ and I use it for all my scripting stuff. I'm using VS2008 Express for my development because I'm a cheap bastard, and it seems to do the job fine (for XNA at least).

SOX
19-08-2009, 12:25 PM
Also a fan of Notepad++, but our work doesn't have it installed on the Development VMs so I have to use UltraEdit (which is shit) half the time :(

Halt, Hammerzeit
19-08-2009, 12:59 PM
I should probably explain what I'm doing so you guys understand where I'm coming from.

My job involves looking after all the mobile and desk phones throughout Swan TAFE. This involves various other systems like an Email SMS service we run as well as coordinating when people want to move and add extension numbers and maintaining our online internal directory. Currently we have a place on our college intranet that explains a bit about how to use the phones and what to do if you need help, but it is woefully inadequate and I'm updating it. For the most part, Frontpage (while terrible) serves my needs, as most of the pages can be written and maintained in basic HTML. What I've been trying to program (which you guys have been helping with) is actually only one small part.

When I was going through some documentation I had lying around, I came across a small voicemail reference card which explains really well how the different voicemail menus work and I'm trying to convert that to a web resource using Javascript (pretty much because I've had a bit of experience using it and it won't require me to learn an entirely new language, since this is probably out of the scope of my job anyway).

I've simplified the code a heap to try and get it working. Now it looks like this:


<html>
<head>

<script type="text/javascript">
<!--
function startInvisible()
{
var b = document.getElementById('button3');
var c = document.getElementById('button4');
var d = document.getElementById('button5');
b.style.display = 'none';
c.style.display = 'none';
d.style.display = 'none';
}

//***************************************

function toggle_visibility(id)
{
var e = document.getElementById(id);
var f = document.getElementById('button5');
var g = document.getElementById('button3');
var h = document.getElementById('button4');

if(id == 'button4')
{
f.style.display = 'none';
g.style.display = 'none';
}

if(id == 'button3')
{
h.style.display = 'none';
}


if(e.style.display == 'block')
{
e.style.display = 'none';
}
else
{
e.style.display = 'block';
}
}

//****************************************
//-->
</script>

</head>

<body onLoad="startInvisible()">

<table border="1" width="100%">
<tr>
<td width="33%">
<div id="button1"><input type="button" value="1" name="buttonone" onclick="toggle_visibility('button3');"></div>
<div id="button2"><input type="button" value="2" name="buttontwo" onclick="toggle_visibility('button4');"></div>
</td>
<td width="33%">
<div id="button3"><input type="button" value="3" name="buttonthree" onclick="toggle_visibility('button5');"></div>
<div id="button4"><input type="button" value="4" name="buttonfour"></div>
</td>
<td width="33%">
<div id="button5"><input type="button" value="5" name="buttonfive"></div>
</td>
</tr>
</table>
</body>
</html>


Bascially, Button 1 toggles Button 3 visable, Button 2 toggles Button 4 visible and Button 3 toggles Button 5 visable. I now have it working so that if Button 3 and Button 5 are visable and Button 4 is activated, Button 3 and 5 disappear, and if Button 4 is visable when Button 3 is activated, Button 4 disappears (Button 5 also remains invisable until it is activated).

Awesome! Thanks for all your help guys. Now all I need to do is make each of the buttons look like a telephone pad :P

Halt, Hammerzeit
19-08-2009, 04:11 PM
Hey guys, just a quick question. I'm trying to make a button that, when clicked, will print text into a text box. I've got the code in the body of the HTML document and I'm not using form tags (just the textbox tag), but I don't seem to be able to write to it. 'booyeah' is the name and id of my text box.

I've tried:
document.booyeah.value='test';
document.booyeah.write='test';

but neither works. I know I can write a function to do that, but I've got 50 buttons that I want to program and I've rather have 50 'onClick' tags than writing 50 separate functions. What am I doing wrong?

Fenrir
19-08-2009, 04:25 PM
Either wrap form tags around the textbox and address it via document.form.booyeah, or get to it via document.getElementById('booyeah'). Value is the right property, though.

Halt, Hammerzeit
19-08-2009, 05:03 PM
Working now. Thanks again.

Halt, Hammerzeit
20-08-2009, 02:33 PM
I've finished the whole thing now. Thanks for your help with everything. Here (http://members.iinet.net.au/~acdcmac/Voicemail Command Quick Reference.htm) is the finished product. I think the code is a bit long, but it serves my purpose.

Fenrir
12-09-2009, 01:40 PM
Hmm, there're a few game programmers around here - how do you guys handle kinematic (motion physics) integration?

Numerical methods seem to be the norm, particularly Verlet; I'm planning on looking through these (http://wiki.vdrift.net/Numerical_Integration) in more detail when I have time. I figure it'd be a good idea to get some input from here, too, though.

Most people seem to shy away from analytical integration - and it's quickly becoming obvious why. I produced the following formulae for linear kinematics factoring in gravity and linear drag:

Constants:

t = time
F(t) = net force at t
a(t) = acceleration at t
v(t) = velocity at t
y(t) = position at t
m = mass
g = acceleration due to gravity
b = air friction coefficient

Net Force:

F(t) = - m*g - b*v(t)

Acceleration:

a(t) = - g - b*v(t)/m

Velocity:

v(t) = (v(0) + g*m/b)*e^(-b*t/m) - g*m/b

Position:

y(t) = y(0) + (v(0) + g*m/b)*(1 - e^(-b*t/m))*m/b - g*m*t/b

...yeah, collision detection with these is going to be hard. I'm using these formulae to solve a problem over at GameDev.net, and ran into Lambert W problem I brought up in the random question thread in OT.

I'll probably get a numerical system going first, and come back when I have enough of an understanding of other factors (angular momentum, dynamics, etc) to determine whether an analytical system is viable - I'd really, really prefer an analytical system, and would especially like to get it done in time for consideration in my Uni applications. ;)

So, thoughts?

Dust
15-09-2009, 09:42 PM
ah, it's been awhile since I've actually written any physics; became lazy and using PhysX/Havok, so can't really help you there sorry. But what's the problem you're trying to work out, can you post up the GameDev thread? I'd be interested to see how it pans out..

Do you usually do much physics, I've got a couple of really good reference books I could probably check for you if you want...?

Fenrir
16-09-2009, 04:10 AM
GameDev.net thread:
http://www.gamedev.net/community/forums/topic.asp?topic_id=546793

The analytical route is, once again, probably major overkill, but I went with it anyway because I'm interested in it. I'm not sure whether the OP or anyone else over there is going to show further interest, but now I'm just determined to solve the problem for my own sake.

I'm doubtful that your reference books will have the answer to this problem; but as I said before, I'll have to start dabbling in numerical integration methods, soon, so any advice there would be good as well.

Stevorooni
25-09-2009, 09:45 AM
I'm currently resurrecting one of the first major projects I worked on at my job, it was written about 4 years ago in the original asp (not even .NET!), where I was learning as I did it.

At the moment I'm just trying to get it running again, but I'm looking at the code going "OMG who wrote this shit?" and it was me!

ahhh memories

fishfishmonkeyhat
05-12-2009, 01:02 AM
Can anyone help me with some actionscript 2 in flash?

The short version is it was all working until I added a second scene to it (intro movie) and now some of it broke.

This code is from the second scene in the order list.

on(release){
if(_root.title02._currentframe != 15){
_root.title02.gotoAndPlay(2);
_root.ht1.gotoAndPlay(2);
}
if(_root._currentframe == 5){
_root.main_menu_mc1.gotoAndPlay("menu_large")
}
_root.gotoAndStop("about");
}

Basically I think it's the "_root" part that's stuffing me up, as it will work fine when testing the scene, but testing the movie breaks it. I'm thinking _root is looking for menu_large in the intro movie scene.

So what do I replace _root with to get it to look in the current scene, and should I replace all instances of it?

I've tried a few things (parent, _parent, this) but I don't know what I'm doing.

Fenrir
05-12-2009, 01:09 PM
I don't know ActionScript per se, but the language is just another ECMAScript (aka JavaScript) dialect. Guess that means I *might* be able to help. >_>

Firstly, what are you trying to do with this code?

Basically I think it's the "_root" part that's stuffing me up, as it will work fine when testing the scene, but testing the movie breaks it. I'm thinking _root is looking for menu_large in the intro movie scene.

So what do I replace _root with to get it to look in the current scene, and should I replace all instances of it?

I've tried a few things (parent, _parent, this) but I don't know what I'm doing.
Adobe documentation on _root (http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary633.html), if it helps.

The this keyword is the handle to whatever object the function is a property of.

fishfishmonkeyhat
05-12-2009, 02:36 PM
I have a menu for the page that will shrink out of the way when one of the options is clicked, but return to it's normal size if any of the other options are clicked.

Like I said, it works until it's loaded with the first scene.

I bet stevo will know how to fix it!

Stevorooni
06-12-2009, 11:55 AM
Can anyone help me with some actionscript 2 in flash?

The short version is it was all working until I added a second scene to it (intro movie) and now some of it broke.

This code is from the second scene in the order list.

on(release){
if(_root.title02._currentframe != 15){
_root.title02.gotoAndPlay(2);
_root.ht1.gotoAndPlay(2);
}
if(_root._currentframe == 5){
_root.main_menu_mc1.gotoAndPlay("menu_large")
}
_root.gotoAndStop("about");
}

Basically I think it's the "_root" part that's stuffing me up, as it will work fine when testing the scene, but testing the movie breaks it. I'm thinking _root is looking for menu_large in the intro movie scene.

So what do I replace _root with to get it to look in the current scene, and should I replace all instances of it?

I've tried a few things (parent, _parent, this) but I don't know what I'm doing.


I know jack shit about flash and I'm a little hungover so I can only guess, but at first glance, something that might be wrong with your code is that you're missing a semi-colon after: _root.main_menu_mc1.gotoAndPlay("menu_large")

fishfishmonkeyhat
06-12-2009, 04:01 PM
That didn't help at all.

Stevo you are terrible.

Stevorooni
06-12-2009, 04:06 PM
http://img686.imageshack.us/img686/6513/readbetweenthelines.jpg

Fenrir
24-12-2009, 02:25 PM
Bumpeth.

I've just started working my way through Project Euler (http://projecteuler.net/) as of last night, using Java. I've only knocked over the first four problems so far.

Also, I'm considering switching to Java for the website I'm working on, mainly because the minister wants security, and PHP just encourages letting shit slip; but also because Java's more structured, advanced, and generally shinier and less hacky than PHP, and I use it more in general. I don't have much code up yet, so now's probably the best time to switch; but they want something fast, so I've been thinking I should knock out something that works with PHP now and then do a full-blown CMS and trust model with Java later.

And finally, any idea what uni professors like to see in CS undergrad application portfolios? I'm thinking about doing some sort of classical mechanics simulation.

Halt, Hammerzeit
31-08-2010, 11:46 AM
Back to my favourite intranet page!

We have an online contact directory that already has a few defined functions in JavaScript that lets you search via a drop down box labelled Department. I've got it working for one Department (Security), but when I try to change the parameters for another Department it doesn't work.

This is the function in the head of the HTML document.



function goShowDepartment(strDepartment)
{
var objForm = document.forms['PhoneDirectory'];
if (objForm != 'undefined')
{
objForm['Function'].value = strDepartment;
objForm.submit();
}
return;
}



These are the buttons that call the above function. For some reason it will only work for 'Security'.


<input type="button" onclick="goShowDepartment('Security');" value="Security Officers" name="btnShowSecurity">

<input type="button" onclick="goShowDepartment('Portfolio Administrative Assistants');" value="PAAs" name="btnShowPAA">

<input type="button" onclick="goShowDepartment('Portfolio Administrative Support Officers');" value="PASOs" name="btnShowPASO">



I've done some basic troubleshooting via alerts to find out what's going on and in all cases the right string is being passed to the function, and the string exists in the Department list, but when the button is clicked it returns nothing. I've also tried changing the Department I'm searching for to a different 1 word department, but I still get the same error. It doesn't even throw up a message to say that no results were found.

Can you guys see anything that I'm doing wrong?

Halt, Hammerzeit
01-09-2010, 03:16 PM
Don't worry, got it sorted. It was to do with the link between the page and the SQL database that it was trying to get the information from.