Unofficial Programming Thread IV

Post » Tue Jun 18, 2013 2:47 am

Try https://www.google.com/search?q=binary&pws=0.
User avatar
christelle047
 
Posts: 3407
Joined: Mon Apr 09, 2007 12:50 pm

Post » Tue Jun 18, 2013 3:19 pm

Would anyone be able to help me fix a module I wrote in Python 3? When I wrote it I meant for it to only be used for the application I originally wrote it for but now I am using it for another and it was not designed to be reusable in this way. I have no idea where to start with it to get it usable by other applications. If anyone is interested let me know and I can pass along the file rather than post the full source in a single post.
User avatar
Isabella X
 
Posts: 3373
Joined: Sat Dec 02, 2006 3:44 am

Post » Tue Jun 18, 2013 11:30 am

Note to self: don't add semicolons after if statements. /facepalm.gif' class='bbc_emoticon' alt=':facepalm:' />

Haven't done that in two years, took me ~two hours to find out why nothing was working the way it should... /wallbash.gif' class='bbc_emoticon' alt=':wallbash:' />
User avatar
Rudi Carter
 
Posts: 3365
Joined: Fri Sep 01, 2006 11:09 pm

Post » Tue Jun 18, 2013 4:15 am

I am in need of assistance. /ohmy.png' class='bbc_emoticon' alt=':ohmy:' />

There is this game programming class I can take, but it teaches Python. I've been learning C++ already, and I want to continue learning C++. There are no C++ classes I can take. I don't really want to learn Python, but it's the only programming class available to me. Should I learn Python?
User avatar
Jani Eayon
 
Posts: 3435
Joined: Sun Mar 25, 2007 12:19 pm

Post » Tue Jun 18, 2013 3:33 am


Most languages are the same at their core, so learning concepts in one will certainly help in another, especially when they are as conceptually close as Python and C++. And while C++ is almost always used for game engines, the gameplay itself is very often implemented using a scripting language like Python (Vampire: Bloodlines) or Lua (WoW, HoMM, lots of other).
User avatar
(G-yen)
 
Posts: 3385
Joined: Thu Oct 11, 2007 11:10 pm

Post » Tue Jun 18, 2013 10:21 am

Alright. I'll probably take the class then. /user.gif' class='bbc_emoticon' alt=':user:' />
User avatar
Natalie Taylor
 
Posts: 3301
Joined: Mon Sep 11, 2006 7:54 pm

Post » Tue Jun 18, 2013 12:44 am

Plus, Python is a far better choice of language to write small - medium games in as it has a far faster development time, far less subtle issues and you don't have the pain of manual memory management. C++ is only really good if you need the potential performance a that only languages designed with performance in mind and 30 years of compiler development gives (And note it is only potential, badly written C++ can be slow* and half the time you probably get better performance by reducing your batch count rather than optimizing any of your own code). The other plus of C++ over other fast compiled languages is if it is open source and you want other developers (Because there are a lot of people out there who know C++ compared to language with a saner design like D or Haskell)

What I am try to say is that for writing smaller games, I wouldn't use C++ anyway. If I were going for oo/procedural I would use Python, functional Haskell and if I wanted something faster than Python but still OO/Procedural I would probably try D (again).



*Part of a program I was writing was taking far longer than expected. From looking at the code I couldn't see the issue or why it would take so long. Broke out the profiler and found that 90% of the time was being spent copying vectors. Turned out I had missed out an & in a function definition and so was passing by value rather than by reference. Took at least half an hour to get to the bottom of it. In Python it wouldn't have happened and I could have written another feature in that time.
User avatar
Laura Richards
 
Posts: 3468
Joined: Mon Aug 28, 2006 4:42 am

Post » Tue Jun 18, 2013 10:52 am

If anyone is interested I am going to be starting a decent sized project in C# to finally get myself back into writing programs that will require alot of research and effort on my part since it is probably beyond my skill level. I would be willing to work on it with others to help speed up development and learn directly from other people since that seems to work out far better than just reading examples and MSDN for me. I will probably be doing it using WPF though I would have preferred some sort of web based version of it, but I think to get started a client application will be fine, plus I do not have spare servers to test on and I know doing something like ASP.NET is much different and I am not ready to learn that quite yet.

If anyone is interested let me know. The project is basically an IP address manager. I got the idea from work since we have too many spreadsheets and random papers to keep track of addresses, though they are all quite logical so it isn't a huge issue, but having something more automated would be nice. Plus I was thinking of doing this for my own network which is quite small and I will never even come close to filling to subnet I am using.

I did think about Python but I have a difficult time with GUIs, especially with Python 3, and I at least have some idea beyond basics about what I am doing if I use C#.
User avatar
Danel
 
Posts: 3417
Joined: Tue Feb 27, 2007 8:35 pm

Post » Tue Jun 18, 2013 4:37 am

http://www.mssqltips.com/sqlservertip/1236/avoid-sql-server-functions-in-the-where-clause-for-performance/
performance booster for anyone using SQL
User avatar
Heather Dawson
 
Posts: 3348
Joined: Sun Oct 15, 2006 4:14 pm

Post » Tue Jun 18, 2013 3:10 am

I have on my web page 3 labels, 3 textboxes and a DropDown List...

When I select one of the options from the DDL I want 2 labels and textboxes to vanish...

Now this was simple enough [See following]
If ddlTypeID.SelectedIndex = 4 Then			    txtPollingInterval.Visible = False			    lblPollingInterval.Visible = False			    txtBatchSize.Visible = False			    lblBatchSize.Visible = False Else			    txtPollingInterval.Visible = True			    lblPollingInterval.Visible = True			    txtBatchSize.Visible = True			    lblBatchSize.Visible = True

Now when I select another option from the DDL, both labels stay hidden whereas the textboxes return as expected.
How is it this happens?

- I managed to fix the problem by turn EnableViewState to false for the labels.
What significance does this have in bringing the labels onto the page?
User avatar
Sanctum
 
Posts: 3524
Joined: Sun Aug 20, 2006 8:29 am

Post » Tue Jun 18, 2013 12:53 pm

At what point would you guys consider charging for software? I am still learning to program and do not do it often but I am finally working on a large project* and feel it would be useful enough to charge even a small amount for it. It willnto be as feature rich as some other commercial products nor as professionally writen but I feel for the amount of time I will be putting into it I would like to see some sort of return. I am thinking maybe also accepting donations by posting it to sites such as CodePlex or SourceForge and am not sure how long it will be maintained.

I am nowhere near the best coder in the world and I am sure there will be better way to do what I did so I am really unsure. I may end up just open sourcing the whole project when I get it far enough along but I was considering potentially selling it as well, or at the very least asking for certain donation amounts for it.

* Large compared to other private projects I have worked on for my own needs.
User avatar
Alycia Leann grace
 
Posts: 3539
Joined: Tue Jun 26, 2007 10:07 pm

Post » Tue Jun 18, 2013 2:30 am

Spoiler
			Dim PID As Integer = TestUtils.GetPID(MERGE_A_Forename, MERGE_A_Surname, MERGE_A_DOB)			Assert.Greater(PID, 0, "P ID not returned from saved p as expected")			Dim mergeHlpr As New MergeTestHelper			Dim reportHlpr As New ResultTestsHelper			_service.UserCredentials.Token = _token			Dim findResultInfo As FindResultCriteria = New FindResultCriteria			findResultInfo.PID = Convert.ToString(PID)						Dim findInfo As FindMerge = mergeHlpr.BuildMergeCriteria()			findInfo.PrimaryPId = PID.ToString			Dim reply As FindMergeResponse = _service.FindMerge(findInfo)			For Each mergeItem As FindMergeItem In reply.P				Dim Detail As GetP = mergeHlpr.BuildGetCriteria()				Detail.PID = mergeItem.PrimaryID			Next			Dim serviceObj As New ServicesPort			Dim findResp As FindResultResponse = _service.FindResult(findResultInfo)			reportHlpr.GetResultForReportID(CStr(Merge_A_TestReportID), _token, serviceObj)


So I run the above test and I get the most annoying error message ever; "Object reference not set to an instance of an object".
I've had to deal with this before and usually have after sometime, but now I'm looking at a brickwall as everything there is doing something, as far as I can tell and brings back the results I need.
Any suggestions on how to fix this test?


- Fixed it, for anyone that's remotely interested it was the last line;
"reportHlpr.GetResultForReportID(CStr(Merge_A_TestReportID), _token, serviceObj)"
That was the problem /rolleyes.gif' class='bbc_emoticon' alt=':rolleyes:' />
User avatar
Eric Hayes
 
Posts: 3392
Joined: Mon Oct 29, 2007 1:57 am

Post » Tue Jun 18, 2013 6:21 am


Personally, I don't charge for software. I prefer my stuff being free. In this case, I'm using both definitions of the word "free". /wink.png' class='bbc_emoticon' alt=':wink:' />

However, donations are fine. And when I say donation, I'm not referring to money specifically. I'd be fine with getting a week's worth of meals or something. I'm not picky. ^^

I'm of the philosophy that you should get paid what people think your effort is worth and support you if they choose to and not get paid for the result as such and force it on people. Probably not worded too well, but I tend to be bad at wording. >.>

It really is a bit hard to explain things like this properly without knowing me very well, methinks. But I gave it a shot. /tongue.png' class='bbc_emoticon' alt=':tongue:' />

Hope it helps some. /smile.png' class='bbc_emoticon' alt=':smile:' />
User avatar
Juan Suarez
 
Posts: 3395
Joined: Sun Nov 25, 2007 4:09 am

Post » Tue Jun 18, 2013 3:38 pm

Hello,

I'd like to use Python to make a video-file-to-playable-video-DVD-on-TV program (so, a program that takes a video file on a computer, burns it to a DVD, and so the DVD can play the movie on any old TV). For example, like those free programs that burn your video file to a DVD and you can then play it on a TV, except it has a watermark, *shakes fist.*

Now, I really don't know how I would do this. I've searched on the internets, but I can't really find anything. I am still sort of a beginner at Python and programming still (I've taken a intro. course in programming and comp. science at university level that both used Python as the programming medium), and I do have the feeling that this is actually something way beyond my abilities. If that's the case, it would be great if I could get some pointers to other projects that could set me on the road to being able to actually do this project, if not advice on the project itself.

EDIT: At another round of searches, it seems PyMedia might be very useful. Specifically, it seems it can take any video file format and make it mpeg 1 or 2, which I think Windows DVD Maker can use. But, how would I code a program to do what Windows DVD Maker does?
User avatar
Vicky Keeler
 
Posts: 3427
Joined: Wed Aug 23, 2006 3:03 am

Post » Tue Jun 18, 2013 1:29 pm

Well, I'm officially stuck.

I'm working on a PowerShell script that finds all the files with PATTERN within a given DIRECTORY, prints out the relevant lines of the document with the PATTERN highlighted, and then replaces the PATTERN with a provided REPLACE word, then saves the file back. So it actually edits the file.

Except I can't get it to alter the file, because Windows complains about the file already being open. I tried several methods to solve this, but keep running into the issue. Perhaps someone can help:
Spoiler

param(	[string] $pattern = ""	,[string] $replace = ""	,[string] $directory ="."	,[switch] $recurse = $false	,[switch] $caseSensitive = $false)if($pattern -eq $null -or $pattern -eq ""){	Write-Error "Please provide a search pattern." ; return}if($directory -eq $null -or $directory -eq ""){	Write-Error "Please provide a directory." ; return}if($replace -eq $null -or $replace -eq ""){	Write-Error "Please provide a string to replace." ; return}$regexPattern = $patternif($caseSensitive -eq $false) { $regexPattern = "(?i)$regexPattern" }$regex = New-Object System.Text.RegularExpressions.Regex $regexPatternfunction Write-HostAndHighlightPattern([string] $inputText){	$index = 0	$length = $inputText.Length	while($index -lt $length)	{		$match = $regex.Match($inputText, $index)		if($match.Success -and $match.Length -gt 0)		{			Write-Host $inputText.SubString($index, $match.Index) -nonewline			Write-Host $match.Value.ToString() -ForegroundColor Red -nonewline			$index = $match.Index + $match.Length		}		else		{			Write-Host $inputText.SubString($index) -nonewline			$index = $inputText.Length		}	}}Get-ChildItem $directory -recurse:$recurse |	Select-String -caseSensitive:$caseSensitive -pattern:$pattern |		foreach {		$file = ($directory + $_.FileName)		Write-Host "$($_.FileName)($($_.LineNumber)): " -nonewline		Write-HostAndHighlightPattern $_.Line		%{ Set-Content $file ((Get-Content $file) -replace ([Regex]::Escape("[$pattern]")),"[$replace]")}		Write-Host "`n"		Write-Host "Processed: $($file)"	}

The issue is located within the final block of code, right at the Get-ChildItem call. Of course, some of the code in that block is now a bit mangled due to me trying to fix the problem then stopping, but keep in mind the intent of that part of the script. I want to get the content, replace the words, then save the altered text back to the file I got it from.

Any help at all would be greatly appreciated.
User avatar
michael danso
 
Posts: 3492
Joined: Wed Jun 13, 2007 9:21 am

Post » Tue Jun 18, 2013 12:53 am

I'm not familiar with that language, but it looks and sounds like you never close the file.
User avatar
LADONA
 
Posts: 3290
Joined: Wed Aug 15, 2007 3:52 am

Post » Tue Jun 18, 2013 4:32 am

You don't really open files exactly, you just use them. You just extract what you need then you're done, but depending on how your order your operations, you could still be technically extracting stuff. I suspect my issue has to do with pipelines, since they just pipe the info down as it comes, which means the file could still be in use.
User avatar
Mashystar
 
Posts: 3460
Joined: Mon Jul 16, 2007 6:35 am

Post » Tue Jun 18, 2013 1:07 pm

Can someone please help me with my C# code in Unity 3.5? I keep getting this error Cannot convert type ModifiedStat to ModifyingAttribute.

using System.Collections.Generic;
public class ModifiedStat : BaseStat {

private List _mods; // A list of attributes that modify this stat
private int _modValue;// The amount added to the baseValue from the modifiers

public ModifiedStat(){
_mods = new List();
_modValue = http://forums.bethsoft.com/topic/1322056-unofficial-programming-thread-iv/0;
}

public void addModifier(ModifyingAttribute mod){
_mods.Add(mod);// Cannot convert type ModifiedStat to ModifyingAttribute
}
private void CalculateModValue(){
_modValue = http://forums.bethsoft.com/topic/1322056-unofficial-programming-thread-iv/0;

if(_mods.Count > 0)
foreach(ModifyingAttribute att in _mods) // Cannot convert type ModifiedStat to ModifyingAttribute
_modValue += (int)(att.Attribute.AdjustedBaseValue * att.Ratio);// Cannot convert type ModifiedStat to ModifyingAttribute
}
public new int AdjustedBaseValue(){
return BaseValue + BuffValue + _modValue;
}
public void Update(){
CalculateModValue();
}
}


public struct ModifyingAttribute{
public Attribute attribute;
public float Ratio;
}
User avatar
Joe Alvarado
 
Posts: 3467
Joined: Sat Nov 24, 2007 11:13 pm

Post » Tue Jun 18, 2013 1:26 am

Over the past few weeks I've branched out from c# and decided to experiment with game development using java and c++.

I started with java and LWJGL and found that it was about as easy to program with as c# and XNA. Unfortunately java has one major drawback that made me abandon it. I couldn't find a reliable way to make an executable with it. The kind that uses the .exe extension and scrambles your code so people can't steal your hard work. Apparently there's some work arounds people use, like using a program to give the variables and stuff random names but that's just not good enough for me.

From there I decided to look into c++ and opengl. Holy crap! Both of these are way overly complicated. LWJGL is apparently a simplified version of (or library for) opengl, so I didn't have quite as much trouble with it as I did with straight up opengl. So many gl functions that I barely understand what they do and it takes a lot of them just to do something simple like drawing a stationary cube. As for c++... well the syntax is very similar to java and c#, except they threw all these *s and &s and ::s around everything. I understand in theory what most of those do but I just don't understand why or where you would want to use them. And apparently everyone uses them so they must all know something I don't. I did like the way you're able to overload classes in c++, which is a bit different than c#'s method and c++'s was actually slightly easier for me to understand for some reason.

But in the end c++ gives a little too much control for my taste, making even programming simple things a pain in the ass, requiring a lot more code than you would use in most other modern languages. Well I managed to get a textured square spinning around and fading in and out with this setup. I think that's about as far as I want to waste my life with c++. Don't get me wrong, it's obviously an excellent language, especially if you want absolute control over what your program can do. But I would end up spending months trying to figure out how everything works and writing my own libraries before I felt comfortable enough to make a full blown game with it.

If I find a library for opengl that works with some other language I might give it another shot. But for now, I think I'll go back to what I know with c# and XNA. At least this has been a good learning experience and I have a better understanding of the differences between all the languages and a better appreciation of the capabilities of c#.
User avatar
Margarita Diaz
 
Posts: 3511
Joined: Sun Aug 12, 2007 2:01 pm

Post » Tue Jun 18, 2013 4:46 am

I'm a big fan of & and *; they're particularly handy from the point of view of efficiency as well as gnarly situations where the size of something isn't yet known, e.g. a variable length string or array, or if you want a function to return multiple values: yeah, you can do it as a structure, but often it's easier to pass parameters by address and modify them directly. Sometimes it gets a bit over the top and even after all these years, things like passing a function as an address can still do my head in (and that's far from the most complicated example) but from their most basic point of view, they're incredibly useful.
User avatar
Da Missz
 
Posts: 3438
Joined: Fri Mar 30, 2007 4:42 pm

Post » Mon Jun 17, 2013 11:54 pm


Yeah, overall it sounds like other languages sacrifice efficiency for usability. My opinion is c++ would be more reliable for doing stuff like file compression or image enhancement. You know, stuff that is really processor intensive that can use all the optimizations they can get. For relatively simpler applications, any other language would work fine and would make development a lot easier.
User avatar
An Lor
 
Posts: 3439
Joined: Sun Feb 18, 2007 8:46 pm

Post » Tue Jun 18, 2013 2:44 pm


The C-related languages do tend to be aimed at stuff that requires either high performance or low-level fiddling; I guess it figures since C was originally designed for writing operating systems with. I've found myself highly resistant to using anything else, though as time's gone on I must admit I'm getting increasingly fed up with every task being quite so laborious!
User avatar
Alan Whiston
 
Posts: 3358
Joined: Sun May 06, 2007 4:07 pm

Post » Tue Jun 18, 2013 1:28 pm


It seems every language has it's pros and cons. What drew me to java and c++ was the idea of making my games more portable. I would love nothing more than for people to download a zip of my game, extract it, double click the exe and be up and running. Turns out I can't do that with java and c++ is so difficult to work with it takes all the fun out of making a game. C# and XNA require .net framework, directx and XNA framework to be installed before the programs can run. There's other options. I still gaze longingly at open euphoria but it's such an obscure language I feel like I'd get laughed at if I tried to make anything with it and most graphics libraries for it aren't well documented.

That brings up a minor rant from me. Why the hell is the documentation for all these languages so hard to understand? Every time I try to figure out what something does I end up having to google every other word in the documentation just to understand what I'm reading. Half the tutorials, even for beginners, aren't much better.
User avatar
Adam Baumgartner
 
Posts: 3344
Joined: Wed May 30, 2007 12:12 pm

Post » Tue Jun 18, 2013 12:12 am

Does anyone know of a decent D (D2) tutorial? I'd like to learn a bit about the language before programming with it, but I can't find any tutorials for it!
User avatar
Queen Bitch
 
Posts: 3312
Joined: Fri Dec 15, 2006 2:43 pm

Post » Tue Jun 18, 2013 11:36 am

I am trying to decide what language to use for a Windows only program. I know a bit of C# and started to try and learn Python. However I want to have a GUI and I never really found an easy to use GUI library for Python 3 which is what I worked with before. I know it doesn't matter in the long run but I just can't decide as I want to try and start moving away from Microsoft only stuff. Does anyone know of an easy to use GUI library that may work with Python 3 or for this application should I just stick with C# to make it much faster and simpler to write?
User avatar
Allison C
 
Posts: 3369
Joined: Mon Dec 18, 2006 11:02 am

PreviousNext

Return to Othor Games