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

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

Hoborg posted:

Redownload it: http://bit.ly/mivMXz

This version has two Zip files within that zip you downloaded. One labelled "Source" and the other "Binaries". Just extract the Binaries zip and run the program within. Report back any findings and please post any screenshots of error messages.


"URI" is actually the correct technical term. The set of URIs encompasses the set of URLs, but also the set of URNs.

error msg: sorry about photobucket, i will remove pic when we get this fixed.

foundtomorrow fucked around with this message at 20:39 on May 14, 2011

Adbot
ADBOT LOVES YOU

Vykk.Draygo
Jan 17, 2004

I say salesmen and women of the world unite!
I have a simple but very specific app request for a file renaming and file moving app. I have a bunch of audio files from a podcast, 16 (usually) per day every weekday. Each filename has a date at the beginning; for example, today might be "05-12-11 - Segment 13.mp3". I've gotten as far as putting them in folders by month but I'm trying to find an app that will put them in folders by day; specifically in the format "May 12 2011, Thu" or "May 11 2011, Wed". This can be as simple as a batch file that I toss in a folder full of MP3 files and it just sorts them out. I just need to get these more organized than they are currently. The only part that seems like it could be difficult is putting the day of the week in the folder name but maybe that's really easy and I don't know it.

To recap: all filenames start with a date in the format mm-dd-yy and need to be moved into folders with a name format of "May 12 2011, Thu" or "Jan 05 2011, Wed". There are multiple files moving to each folder.

If anybody knows of an existing app that would do this, please let me know. Otherwise any help would be greatly appreciated.

Hoborg
Oct 19, 2006

by T. Mascis

foundtomorrow posted:

error msg: sorry about photobucket, i will remove pic when we get this fixed.
http://i18.photobucket.com/albums/b110/sowarrior/eorr/errormsg.jpg

The generic "Failure sending mail" error means that the SMTP server you're connecting to rejected the mail being sent. There are further details that need to be displayed.

Redownload the zip, you'll find a text file within saying "Release 4" (so you know that's the one). Rerun the program, and the next time you get that error message you'll be presented with more details that should be able to tell you how to fix the problem yourself (i.e. a misconfiguration of the SMTP config), failing that post the screenshot of the error message in this thread and I'll pick it up in the morning.

http://bit.ly/mivMXz

Hoborg
Oct 19, 2006

by T. Mascis

Vykk.Draygo posted:

To recap: all filenames start with a date in the format mm-dd-yy and need to be moved into folders with a name format of "May 12 2011, Thu" or "Jan 05 2011, Wed". There are multiple files moving to each folder.

If anybody knows of an existing app that would do this, please let me know. Otherwise any help would be greatly appreciated.

Untested, use at your own risk and modify as appropriate. Save this text to a file with a .vbs extension. Double-click to run.

code:
Option Explicit

Main

Dim fso
Dim dir

Sub Main
	
	Set fso = CreateObject("Scripting.FileSystemObject")
	Set dir = fso.GetFolder(".")
	
	Dim file
	For Each file in dir.Files
		
		ProcessFile file
		
	Next
	
End Sub

Sub ProcessFile(file)
	
	Dim fName
	fName = file.Name
	
	Dim year, month day
	month = Mid( fName, 0, 2 )
	day   = Mid( fName, 3, 2 )
	year  = Mid( fName, 6, 2 )
	
	Dim dtStr
	dtStr = month & "/" & day & "/" & year
	Dim dt
	dt = CDate( dtStr )
	
	Dim folderName
	folderName = MonthName( month ) & " " & day & " " & year & ", " & WeekdayName( WeekDay( dt ), True )
	
	folderName = dir.Path & "\" & folderName
	
	file.Move folderName
	
End Sub
you could save yourself a lot of trouble by simply adopting ISO-8601 and leaving behind rear end-backward "human" date formats. It makes no sense to store dates month first.

foundtomorrow
Feb 10, 2007

Hoborg posted:

The generic "Failure sending mail" error means that the SMTP server you're connecting to rejected the mail being sent. There are further details that need to be displayed.

Redownload the zip, you'll find a text file within saying "Release 4" (so you know that's the one). Rerun the program, and the next time you get that error message you'll be presented with more details that should be able to tell you how to fix the problem yourself (i.e. a misconfiguration of the SMTP config), failing that post the screenshot of the error message in this thread and I'll pick it up in the morning.

http://bit.ly/mivMXz

Ok, I've pinged the gmail smtp from the command prompt and I can access it just fine.

So now the sound option works though! But the run a batch option and the email option generate a windows generic error upon the counter hitting :00 as before.

Vykk.Draygo
Jan 17, 2004

I say salesmen and women of the world unite!

Hoborg posted:

Code

code:
Line: 27
Char: 18
Error: Expected end of statement
Code: 800A0401
Source: Microsoft VBScript Compilation Error
I tried to figure this error out on my own but I couldn't. Obviously I can see where the error is but I don't know what is causing it.

saintonan
Dec 7, 2009

Fields of glory shine eternal

Vykk.Draygo posted:


I tried to figure this error out on my own but I couldn't. Obviously I can see where the error is but I don't know what is causing it.

Put a comma between month and day.

Vykk.Draygo
Jan 17, 2004

I say salesmen and women of the world unite!

saintonan posted:

Put a comma between month and day.

That was the first thing I tried. The error then became
code:
Line: 28
Char: 2
Error: Invalid procedure call or argument: 'Mid'
Code: 800A0005

Hoborg
Oct 19, 2006

by T. Mascis

foundtomorrow posted:

So now the sound option works though! But the run a batch option and the email option generate a windows generic error upon the counter hitting :00 as before.

Can you send me an email with the exact details you're entering in the Action window, including SMTP username and password? Email it here: tinyapp.10.jeff-k@spamgourmet.com

If I end up hacking your gmail feel free to petition Lowtax into banning me :), alternatively just temporarily change your details or something.

saintonan
Dec 7, 2009

Fields of glory shine eternal

Vykk.Draygo posted:

That was the first thing I tried. The error then became
code:
Line: 28
Char: 2
Error: Invalid procedure call or argument: 'Mid'
Code: 800A0005

Try this:

code:
Option Explicit

Main

Dim fso
Dim dir

Sub Main

	Set fso = CreateObject("Scripting.FileSystemObject")
	Set dir = fso.GetFolder(".")

	Dim file
	For Each file in dir.Files

		If Instr(file, ".vbs") = 0 then ProcessFile file

	Next

End Sub

Sub ProcessFile(file)

        dim filesys, newfolder
        set filesys=CreateObject("Scripting.FileSystemObject")

	Dim fName
	fName = file.Name

	Dim year, month, day

	month = Mid(fName, 1, 2)
	day = Mid(fName, 4, 2)
	year = Mid(fName, 7, 2)

	Dim dtStr
	dtStr = month & "/" & day & "/" & year
	Dim dt
	dt = CDate( dtStr )

	Dim folderName, fullpath
	folderName = dir.Path & "\" & MonthName( month ) & " " & day & " " & year & ", " & WeekdayName( WeekDay( dt ), True )

	If Not filesys.FolderExists(folderName) Then newfolder = filesys.CreateFolder (folderName)

        file.Move folderName & "\" & file.Name

End Sub

foundtomorrow
Feb 10, 2007

Hoborg posted:

Can you send me an email with the exact details you're entering in the Action window, including SMTP username and password? Email it here: tinyapp.10.jeff-k@spamgourmet.com

If I end up hacking your gmail feel free to petition Lowtax into banning me :), alternatively just temporarily change your details or something.

Sent, man. Thanks!

Vykk.Draygo
Jan 17, 2004

I say salesmen and women of the world unite!

saintonan posted:

Try this:

code:
Line: 39
Char: 2
Error: Type mismatch 'CDate'
Code: 800A000D
:(

saintonan
Dec 7, 2009

Fields of glory shine eternal

Are you sure all your filenames start with mm-dd-yy (that precise series of 8 characters)? You'd only get that error if it can't figure out what the month, day, or year is.

My assumption is that all your files are something like 05-12-11 - Segment 13.mp3, like you mentioned in your post.

Also, I'm assuming that all your unsorted files are in the root of the tree, and that this VBScript is also in that same directory. For example, if all the unsorted segments are in C:\files, then this script should be there as well, and it will move the entry to C:\files\May 12 11, Thu\05-12-11 - Segment 13.mp3 .

If this is not how you have it, let me know. If it is how you have it, then scan the directory and make sure all your entries match the mm-dd-yy - something.mp3 pattern.

saintonan fucked around with this message at 23:17 on May 13, 2011

Vykk.Draygo
Jan 17, 2004

I say salesmen and women of the world unite!

saintonan posted:

Are you sure all your filenames start with mm-dd-yy (that precise series of 8 characters)? You'd only get that error if it can't figure out what the month, day, or year is.

My assumption is that all your files are something like 05-12-11 - Segment 13.mp3, like you mentioned in your post.

Also, I'm assuming that all your unsorted files are in the root of the tree, and that this VBScript is also in that same directory. For example, if all the unsorted segments are in C:\files, then this script should be there as well, and it will move the entry to C:\files\May 12 11, Thu\05-12-11 - Segment 13.mp3 .

If this is not how you have it, let me know. If it is how you have it, then scan the directory and make sure all your entries match the mm-dd-yy - something.mp3 pattern.

I neglected to mention (because it didn't seem important) that the file names have segment descriptions after the segment number, but yes, they are all in that format and all in a single folder with the script file.

edit: line 37 seems like it's looking for mm/dd/yy but changing it didn't fix anything so I dunno.

Vykk.Draygo fucked around with this message at 00:36 on May 14, 2011

saintonan
Dec 7, 2009

Fields of glory shine eternal

Vykk.Draygo posted:

edit: line 37 seems like it's looking for mm/dd/yy but changing it didn't fix anything so I dunno.

Line 37 is creating mm/dd/yy, because that's a format CDate recognizes. The mm comes from the first two characters of the filename, dd from the fourth and fifth characters, and yy from the 7th and 8th characters of the filename.

Find the line just under "Dim dt" and add this line (i.e. this should go between "Dim dt" and "dt = CDate( dtStr )":

code:
MsgBox dtStr, IsDate(dtStr)
This will pop up a message box that displays the value and whether your system can parse the value into a date. Let me know what the message box displays.

saintonan fucked around with this message at 01:48 on May 14, 2011

Vykk.Draygo
Jan 17, 2004

I say salesmen and women of the world unite!

saintonan posted:

Line 37 is creating mm/dd/yy, because that's a format CDate recognizes. The mm comes from the first two characters of the filename, dd from the fourth and fifth characters, and yy from the 7th and 8th characters of the filename.

Find the line just under "Dim dt" and add this line (i.e. this should go between "Dim dt" and "dt = CDate( dtStr )":

code:
MsgBox dtStr, IsDate(dtStr)
This will pop up a message box that displays the value and whether your system can parse the value into a date. Let me know what the message box displays.

7B/96/B0

saintonan
Dec 7, 2009

Fields of glory shine eternal

Vykk.Draygo posted:

7B/96/B0

Okay, that's pretty bizarre. Change the MsgBox line to:

code:
MsgBox (dtStr & " " & file.Name)
There's something really weird going on with your file names. Hopefully this will give me a better clue.

Vykk.Draygo
Jan 17, 2004

I say salesmen and women of the world unite!

saintonan posted:

Okay, that's pretty bizarre. Change the MsgBox line to:

code:
MsgBox (dtStr & " " & file.Name)
There's something really weird going on with your file names. Hopefully this will give me a better clue.

This is going to be really difficult to type, but here it goes.
code:
7B/96/B0
7B296FB0-376B-497e-B012-9C450E1B7327-5P-0.C7483456-A289-439d-8115-60163
2D005A0

saintonan
Dec 7, 2009

Fields of glory shine eternal

Vykk.Draygo posted:

This is going to be really difficult to type, but here it goes.
code:
7B/96/B0
7B296FB0-376B-497e-B012-9C450E1B7327-5P-0.C7483456-A289-439d-8115-60163
2D005A0

That long string is what your system thinks the file name is. That isn't really the file name, is it? What system is this running on?

Vykk.Draygo
Jan 17, 2004

I say salesmen and women of the world unite!

saintonan posted:

That long string is what your system thinks the file name is. That isn't really the file name, is it? What system is this running on?

Windows 7 x64.

saintonan
Dec 7, 2009

Fields of glory shine eternal

Vykk.Draygo posted:

Windows 7 x64.

Hmm, that's the same system I've been testing this on.

Here's the complete script once again, make sure yours looks exactly like this, especially the two Set lines at the top (lines 10 and 11) and further down where it creates and assigns the fName variable. Make sure there's not a weird typo in your script.

code:
Option Explicit

Main

Dim fso
Dim dir

Sub Main

	Set fso = CreateObject("Scripting.FileSystemObject")
	Set dir = fso.GetFolder(".")

	Dim file
	For Each file in dir.Files

		If Instr(file, ".vbs") = 0 then ProcessFile file

	Next

End Sub

Sub ProcessFile(file)

        dim filesys, newfolder
        set filesys=CreateObject("Scripting.FileSystemObject")

	Dim fName
	fName = file.Name

	Dim year, month, day

	month = Mid(fName, 1, 2)
	day = Mid(fName, 4, 2)
	year = Mid(fName, 7, 2)

	Dim dtStr
	dtStr = month & "/" & day & "/" & year
	Dim dt
	MsgBox (dtStr & " " & file.Name)
	dt = CDate( dtStr )

	Dim folderName, fullpath
	folderName = dir.Path & "\" & MonthName( month ) & " " & day & " " & year & ", " & WeekdayName( WeekDay( dt ), True )

	If Not filesys.FolderExists(folderName) Then newfolder = filesys.CreateFolder (folderName)

        file.Move folderName & "\" & file.Name

End Sub

Vykk.Draygo
Jan 17, 2004

I say salesmen and women of the world unite!

saintonan posted:

Hmm, that's the same system I've been testing this on.

Here's the complete script once again, make sure yours looks exactly like this, especially the two Set lines at the top (lines 10 and 11) and further down where it creates and assigns the fName variable. Make sure there's not a weird typo in your script.

I deleted the original script and copy/pasted that into a new document called script.vbs. Still getting the same problem. Out of curiosity I copied a file into a new folder with the script and renamed the file 05-12-11.mp3 and it still gave the same error.

saintonan
Dec 7, 2009

Fields of glory shine eternal

Vykk.Draygo posted:

I deleted the original script and copy/pasted that into a new document called script.vbs. Still getting the same problem. Out of curiosity I copied a file into a new folder with the script and renamed the file 05-12-11.mp3 and it still gave the same error.

I'm not sure how your filenames are getting munged.

Stick this line on line 15 (right above the "If Instr..." line):

code:
MsgBox file
When you run it, the first messagebox you see should be the full pathname to the file it's considering. If it's giving you that long string of jibberish there, that means one of the lines in the script above line 15 is wrong. If it gives you the actual filename, but the second messagebox still gives you jibberish, then the filename isn't being passed properly, and I'll have to figure out why that would be happening on your system.

Vykk.Draygo
Jan 17, 2004

I say salesmen and women of the world unite!

saintonan posted:

I'm not sure how your filenames are getting munged.

Stick this line on line 15 (right above the "If Instr..." line):

code:
MsgBox file
When you run it, the first messagebox you see should be the full pathname to the file it's considering. If it's giving you that long string of jibberish there, that means one of the lines in the script above line 15 is wrong. If it gives you the actual filename, but the second messagebox still gives you jibberish, then the filename isn't being passed properly, and I'll have to figure out why that would be happening on your system.

C:\Windows\System32\[big string of gibberish]
second window is the same gibberish.
Meanwhile, these files are saved on the F drive so certainly not in System32.

saintonan
Dec 7, 2009

Fields of glory shine eternal

Vykk.Draygo posted:

C:\Windows\System32\[big string of gibberish]
second window is the same gibberish.
Meanwhile, these files are saved on the F drive so certainly not in System32.

Find the line (line 11) that reads 'Set dir = fso.GetFolder(".")' and change what's in the parentheses to the base directory where the files are stored. For example, if the unsorted files are in F:\files, make the line look like:

code:
Set dir = fso.GetFolder("F:\files")
Then re-run the script and let me know what you get.

Vykk.Draygo
Jan 17, 2004

I say salesmen and women of the world unite!

saintonan posted:

Find the line (line 11) that reads 'Set dir = fso.GetFolder(".")' and change what's in the parentheses to the base directory where the files are stored. For example, if the unsorted files are in F:\files, make the line look like:

code:
Set dir = fso.GetFolder("F:\files")
Then re-run the script and let me know what you get.

It popped up a dialog box for every single file and one for each time it moved each file (boy was that a chore to click through) but it worked :)

Now that the problem is narrowed down, is there a way to make it folder independent so I don't have to add the directory to the script every time?

saintonan
Dec 7, 2009

Fields of glory shine eternal

Vykk.Draygo posted:

It popped up a dialog box for every single file and one for each time it moved each file (boy was that a chore to click through) but it worked :)

Now that the problem is narrowed down, is there a way to make it folder independent so I don't have to add the directory to the script every time?

Let me try something a little more indirect. Replace the top of your script with this:

code:
Option Explicit

Main

Dim fso
Dim dir
Dim oShell

Sub Main

	Set fso = CreateObject("Scripting.FileSystemObject")
	Set oShell = CreateObject("WScript.Shell")

        oShell.CurrentDirectory = fso.GetParentFolderName(Wscript.ScriptFullName)

        MsgBox oShell.CurrentDirectory

	Set dir = fso.GetFolder(OShell.CurrentDirectory)

	Dim file
	For Each file in dir.Files

		If Instr(file, ".vbs") = 0 then ProcessFile file

	Next

End Sub
The rest of the file from "Sub ProcessFile(file)" on down should stay the same, although you can remove the "MsgBox (dtStr & file.Name)" line.

This is a long way around figuring out where your current directory is. Hopefully when you run this, you'll get a message box that returns the current path. Move the script around into different directories to verify that it changes with you.

If the script starts returning "C:\windows\system32" + gibberish again, then I'll have to come up with an even more convoluted solution.

Vykk.Draygo
Jan 17, 2004

I say salesmen and women of the world unite!

saintonan posted:

:words:

Works perfectly. Thank you very much.

Hoborg
Oct 19, 2006

by T. Mascis

Vykk.Draygo posted:

Works perfectly. Thank you very much.

I just got back to this thread. I salute saintonan for dealing with the fallout from my program there :)

Back to dealing with foundtomorrow. I've received his email and found a couple of bugs that I've fixed in the latest version that's now available for download: http://bit.ly/mivMXz (identified as Release 5).

However whenever I sent emails via Gmail's SMTP servers I get timeouts. I can't see any obvious reason for this, and I have no problems when using my own SMTP server. You should try your ISP's SMTP servers or another server.

foundtomorrow
Feb 10, 2007

Hoborg posted:

I just got back to this thread. I salute saintonan for dealing with the fallout from my program there :)

Back to dealing with foundtomorrow. I've received his email and found a couple of bugs that I've fixed in the latest version that's now available for download: http://bit.ly/mivMXz (identified as Release 5).

However whenever I sent emails via Gmail's SMTP servers I get timeouts. I can't see any obvious reason for this, and I have no problems when using my own SMTP server. You should try your ISP's SMTP servers or another server.

Everything works perfectly now, Hoborg.

Thanks very much, sir.

Jihad Me At Hello
Apr 23, 2002

by FactsAreUseless
Fun Shoe
Looking for an app that calculates barbell weight for lifting. Similar to this:
http://www.appsfuze.com/applications/windowsphone.fitness/barbell-calculator,5546

Taking into account the bar is 45 lbs. I want to be able to enter in 285 and see what weights are needed to put on the bar. Increments are 2.5lbs, 5, 10, 25, 35, 45.

Corla Plankun
May 8, 2007

improve the lives of everyone

Jihad Me At Hello posted:

Looking for an app that calculates barbell weight for lifting. Similar to this:
http://www.appsfuze.com/applications/windowsphone.fitness/barbell-calculator,5546

Taking into account the bar is 45 lbs. I want to be able to enter in 285 and see what weights are needed to put on the bar. Increments are 2.5lbs, 5, 10, 25, 35, 45.

Can you honestly not figure that out in your head? Maybe you should spend less time lifting weight and more time practicing elementary math.

Factory Factory
Mar 19, 2010

This is what
Arcane Velocity was like.
Oh come on, I wrote a program to do this when I was twelve, the least-coins-to-make-change problem. It's simple and useful. Don't be a yutz about it.

Jihad Me At Hello
Apr 23, 2002

by FactsAreUseless
Fun Shoe

Factory Factory posted:

Oh come on, I wrote a program to do this when I was twelve, the least-coins-to-make-change problem. It's simple and useful. Don't be a yutz about it.

There are lots of numbers to add here. Sure adding 10 to 10 is easy, beyond that? I'm no mathematicion.

Hoborg
Oct 19, 2006

by T. Mascis

Jihad Me At Hello posted:

Looking for an app that calculates barbell weight for lifting. Similar to this:
http://www.appsfuze.com/applications/windowsphone.fitness/barbell-calculator,5546

Taking into account the bar is 45 lbs. I want to be able to enter in 285 and see what weights are needed to put on the bar. Increments are 2.5lbs, 5, 10, 25, 35, 45.

You can solve this with Javascript. Copy and paste the following into a new bookmark on your browser (including your browser on your phone). Just tap the bookmark and you'll get a prompt and you can use it from there:

I had to insert manual new-lines so this wouldn't break the table. I suggest copying this into notepad (or some other text editor or the Notes app on iPhone) to remove the new-lines and then pasting into your bookmarks.

code:
javascript:(function(){var%20w%20=%20new%20Array(45.0,35.0,25.0,10.0,5.0,2.5);
var%20s%20=%20new%20Array(0.0,0.0,0.0,0.0,0.0,0.0);var%20t;while(true)%20{t%20=%20parseFloat(%20prompt("Total%20mass%20in%20lbs:")%20);
if(%20!isNaN(%20t%20)%20)%20break;}var%20u%20=%200;while(%20u%20!=%20t%20)%20{var%20f%20=%20false;
for(var%20i=0;i<w.length;i++)%20{if(%20w[i]%20+%20u%20<=%20t%20)%20{s[i]++;u%20+=%20w[i];f%20=%20true;
break;}}if(%20!f%20)%20{
alert("There%20is%20no%20combination%20of%20weights%20that%20matches%20your%20input.%20The%20next%20popup%20will%20be%20the%20closest%20solution.");
break;}}var%20msg%20=%20"";for(var%20i=0;i<w.length;i++)%20{if(%20s[i]%20>%200%20)%20{if(%20i%20!=%200%20)%20msg%20+=%20"\n";
msg%20+=%20s[i]%20+%20"x%20"%20+%20w[i]%20+%20"%20lbs";}}alert(msg);})();
Tested and works in Firefox and my iPhone.

The trick to getting it working on your iPhone (assuming you're an apostle of Steve Jobs, as opposed to Steve Ballmer) is a bit convoluted:

  1. Copy the contents of the Code block above (be careful not to select the text reading "Code:")
  2. Paste it into a new empty note in the Notes app
  3. Carefully identify all of the new-lines. Insert the caret (insertion pointer) at the beginning of the line and tap backspace once. Do this 7 times for each new-line.
  4. Re-select the whole note and copy it to the clipboard
  5. Go to Safari and visit a random webpage. Click the "Add Bookmark" button and change the name to "Weights Calculator", note that you cannot change the bookmark's URL at this point
  6. Open up the Bookmarks window and click Edit, then tap on the new Weights Calculator item
  7. Clear the existing and irrelevant URL and paste the clipboard contents into the field, then click Done
  8. Go to any web-page and open the Bookmark you just created. You'll get a prompt.
  9. Enjoy, and whenever you use your custom-made-just-for-you-bookmarklet remember that you provided 15 minutes' challenge to a undergrad who should be revising for finals.

EDIT2:

For future reference, below is the non-condensed "source" version in case you ever want to make any changes (be sure to condense it afterwards):

code:
function dumbdumbbel() {

	var weights  = new Array(45.0, 35.0, 25.0, 10.0,  5.0,  2.5);
	var solution = new Array( 0.0,  0.0,  0.0,  0.0,  0.0,  0.0);
	
	var total = getTotal();
	var soFar = 0;
	while( soFar != total ) {
		
		var found = false;
		
		for(var i=0;i<weights.length;i++) {
			if( weights[i] + soFar <= total ) {
				solution[i]++;
				soFar += weights[i];
				found = true;
				break;
			}
		}
		
		if( !found ) {
			alert("There is no combination of weights that matches your input. The next popup will be the closest solution.");
			displaySolution(solution, weights);
			return;
		}
	}
	
	displaySolution(solution, weights);
}

function displaySolution(solution, weights) {
	
	var msg = "";
	
	for(var i=0;i<weights.length;i++) {
		
		if( solution[i] > 0 ) {
			if( i != 0 ) msg += "\n";
			msg += solution[i] + "x " + weights[i] + " lbs";
		}
	}
	
	alert(msg);
}

function getTotal() {
	
	while(true) {
		
		var total = parseFloat( prompt("Total mass in lbs:") );
		if( !isNaN( total ) ) return total;
	}
}

Hoborg fucked around with this message at 01:01 on May 16, 2011

Factory Factory
Mar 19, 2010

This is what
Arcane Velocity was like.

Jihad Me At Hello posted:

There are lots of numbers to add here. Sure adding 10 to 10 is easy, beyond that? I'm no mathematicion.

I was telling off the guy who posted above me, not you. :)

Jihad Me At Hello
Apr 23, 2002

by FactsAreUseless
Fun Shoe

Factory Factory posted:

I was telling off the guy who posted above me, not you. :)

You rule, Hoborg rules. Awesome.

Hoborg
Oct 19, 2006

by T. Mascis

Jihad Me At Hello posted:

Hoborg rules.

He does.

Red_Mage
Jul 23, 2007
I SHOULD BE FUCKING PERMABANNED BUT IN THE MEANTIME ASK ME ABOUT MY FAILED KICKSTARTER AND RUNNING OFF WITH THE MONEY
I hate to ask because I feel like there should be one and I just don't know where it is, but could someone make or point me to an app/webpage that could combine a large (1000 page) somethingawful thread into one large text file?

Adbot
ADBOT LOVES YOU

ephphatha
Dec 18, 2009




Red_Mage posted:

I hate to ask because I feel like there should be one and I just don't know where it is, but could someone make or point me to an app/webpage that could combine a large (1000 page) somethingawful thread into one large text file?

Might be worth having a look in the Lets Play subforum. They've got a script used to prepare threads for hosting on the Lets Play Archive which pulls posts by a specific author or authors into an HTML file with images/quotes etc. preserved. I can't find the link to it though.

  • Locked thread