Sign in to follow this  
Followers 0
Diana (Cda)

[Resolved] Script that tells me how many DVD-Rs/-RWs I'll need ...

5 posts in this topic

#1 ·  Posted (edited)

Hi,

Long time no hear ... I've been doing quite well in AI on my own lately, thank goodness <g>. 'bout time, too. But I did run into problems with a script this morning. I just can't figure out where the problem is. You guys of the sharper scripting eyes will see it in a flash, I'm sure <g>.

;===========================================================
$DVDtotalSize = "4480"     ; Size in MB.
;===========================================================

;InputBox features: Title=Yes, Prompt=Yes, Default Text=Yes
If Not IsDeclared("sInputBoxAnswer") Then Local $sInputBoxAnswer
$sInputBoxAnswer = InputBox("Total size of all files to transfer to DVD(s) in GB?", _
                            "What is the combined size -- IN GIGABYTES -- of the files you wish to transfer to a standard DVD of ±4480 MB size?","3"," ","-1","-1","-1","-1")
Select
    Case @Error = 0 ;OK - The string returned is valid
        ;========================================================================================================
        $SizeValue = Round($sInputBoxAnswer*1024/$DVDtotalSize, -1)     ; -1 rounds answer down to the nearest 10
        ;========================================================================================================
        Sleep(100)
        MsgBox(262208,"# of DVD±Rs/DVD±RWs:","You will need " & $SizeValue & " DVD disks ...               ")
        ;========================================================================================================
    Case @Error = 1 ;The Cancel button was pushed
        Exit     ; finished
    Case @Error = 3 ;The InputBox failed to open
        Exit     ; finished
EndSelect

No matter what number I put in in GB, I get "You will need 0 DVD disks ...". <shrug>

Can anyone see where the error lies above? I know that the 10.9 gigabytes I need to burn so far will fit on about 3 disks (2 and a bit) but just curious to see a more precise figure. Also, this will be handy when I've finished ripping my boxed sets to see how many disks my AVIs will need in total in the end. Also good when I need to backup part of some of my drives to disk.

Thanks! :D

Edited by Diana (Cda)

Share this post


Link to post
Share on other sites



Change line 12 to $SizeValue = 1 + Floor($sInputBoxAnswer*1024/$DVDtotalSize).

Calculation should work now.

Regards,

UEZ


Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

UEZ, thanks! Finally, a number result greater than "0"! <lol>

I was wondering how to get a bit more precise, though. When I do the calculation for the 10.9 gigs manually, I get this:

10.9

× 1024

= 11161.6

11161.6

÷ 4480

= 2.491428571429, which should be rounded up, I think to 2 decimal places, so that 2.5 disks would be result. ...

= 2.50

How can the above be fine-tuned to get this type of result?

Thanks! :D

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

UEZ, thanks! Finally, a number result greater than "0"! <lol>

I was wondering how to get a bit more precise, though. When I do the calculation for the 10.9 gigs manually, I get this:

10.9

× 1024

= 11161.6

11161.6

÷ 4480

= 2.491428571429, which should be rounded up, I think to 2 decimal places, so that 2.5 disks would be result. ...

= 2.50

How can the above be fine-tuned to get this type of result?

Thanks! :D

I found a better function for calculating: Ceiling

Just replace the line again with this: $SizeValue = Ceiling($sInputBoxAnswer*1024/$DVDtotalSize)

In my opinion it makes no sense to get result like 2.50 DVD because you will need at least 3 DVDs.

Anyway, try $SizeValue = Round($sInputBoxAnswer*1024/$DVDtotalSize, 1) to get the 2.5

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Share this post


Link to post
Share on other sites

Anyway, try $SizeValue = Round($sInputBoxAnswer*1024/$DVDtotalSize, 1) to get the 2.5

Okay, my line was wrong in that I had -1 instead of 1. No wonder! I think I need to work with Round, Floor and Ceiling some more! <g>

In my opinion it makes no sense to get result like 2.50 DVD because you will need at least 3 DVDs.

Ah, that's because you're looking at this from your own unique perspective of what you perceive as the sole use for this script. On the surface at least, it would be seem that this is just to advise the total number of disks needed for a given job. That's only part of it. I need to also know how much free space is left; with the result, I can then calculate how to optimally use up that space. I _always_ need to make backups. In fact, I don't back up often enough. <g> One of these days, I'm going to get a super-large external hdd for that purpose. <g>

Anyway, just a thought but ... the obvious is hardly ever what one might think <g>.

Thanks! Gotta practice some more with the terms above and getting the target result. :D

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0