forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Javascript ---> VDS

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Scheben
Newbie


Joined: 09 Apr 2002
Posts: 9
Location: Stuttgart,Germany

PostPosted: Sun Jan 09, 2005 11:45 am    Post subject: Javascript ---> VDS Reply with quote

Hi there, long time not seen Wink

Well, ive got a little prob. I want to convert a javascript to VDS source, but this script seems to be complex, its confusing me. This script calculates sea water salinity but i want my own little tool to calculate it Wink

Any ideas how to convert the maths? Thanks Smile

The script was found here:
http://home.arcor.de/chronz/aquaristik/tips_tricks/berechnungen.htm
(the first calculator at top)

Code:

<SCRIPT language=JavaScript>
<!--
function dichte(form) {
   var temp=parseFloat(form.temp.value);
   var sal=parseFloat(form.sal.value);
   var dens= - 0.157406 + temp*(6.793952E-2 - temp*(9.095290E-3 - temp*(1.001685E-4 - temp*(1.120083E-6 - temp *6.536332E-9)))) + sal*(8.24493E-1 - temp*(4.0899E-3 - temp*(7.6438E-5 - temp*(8.2467E-7 - temp*5.3875E-9))) - Math.sqrt(sal)*(5.72466E-3 - temp*(1.0227E-4 - temp*1.6546E-6)) + sal*4.8314E-4);
   var dens= dens+1000
   var dens25= - 0.157406 + 25*(6.793952E-2 - 25*(9.095290E-3 - 25*(1.001685E-4 - 25*(1.120083E-6 - 25 *6.536332E-9)))) + sal*(8.24493E-1 - 25*(4.0899E-3 - 25*(7.6438E-5 - 25*(8.2467E-7 - 25*5.3875E-9))) - Math.sqrt(sal)*(5.72466E-3 - 25*(1.0227E-4 - 25*1.6546E-6)) + sal*4.8314E-4);
   var dens25= dens25+1000

   form.dens.value= Math.round(10*dens)/10;
   form.dens25.value= Math.round(10*dens25)/10;
   form.tempe.value=(Math.round(10*temp)/10)+"°C";
   form.temp25.value="25.0°C";
}

function salinitaet(form) {
   var temps=parseFloat(form.temps.value);
   var denss=parseFloat(form.denss.value);
   denss= denss-999.96;
   var limit = 10000;
   var salmin = 0.0;
   var salmax = 100.0;
   var fehler = 1.0;
   var densNeu;
   var i = 0;
       
   while( (Math.abs(fehler) > 0.00001) && (i < limit) ) {
       sals = (salmin+salmax) / 2.0;
       densNeu = - 0.157406 + temps*(6.793952E-2 - temps*(9.095290E-3 - temps*(1.001685E-4 - temps*(1.120083E-6 - temps *6.536332E-9)))) + sals*(8.24493E-1 - temps*(4.0899E-3 - temps*(7.6438E-5 - temps*(8.2467E-7 - temps*5.3875E-9))) - Math.sqrt(sals)*(5.72466E-3 - temps*(1.0227E-4 - temps*1.6546E-6)) + sals*4.8314E-4);
       fehler = (densNeu-denss) / denss;
       if (fehler > 0.0)
           salmax = sals;
       else
           salmin = sals;
       ++i;
   }
   if ( i >= limit )
       form.sals.value= "ERROR";
   else
       form.sals.value= "Salinität = "+Math.round(100*sals)/100+" psu";
    }
---->
</SCRIPT>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group