[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Atishoo

8/27/2010 4:33:00 PM

Hi
Am trying to convert a vbscript programme i wrote in javascript with little
success!!

can anyone help?

script as follows

function calculatecluster()

{

var bestmatchedcluster;
var secondbestmatchedcluster;
var clusterdefarray(21)

clusterdefarray(0) = ("CARE CLUSTER 0: Variance");
clusterdefarray(1) = ("CARE CLUSTER 1: Common Mental Health Problems (Low
Severity)");
clusterdefarray(2) = ("CARE CLUSTER 2: Common Mental Health Problems (Low
Severity with greater need)");
clusterdefarray(3) = ("CARE CLUSTER 3: Non Psychotic (Moderate Severity)");
clusterdefarray(4) = ("CARE CLUSTER 4: Non-psychotic (Severe)");
clusterdefarray(5) = ("CARE CLUSTER 5: Non-psychotic Disorders (Very
Severe)");
clusterdefarray(6) = ("CARE CLUSTER 6: Non-psychotic Disorder of Over-valued
Ideas");
clusterdefarray(7) = ("CARE CLUSTER 7: Enduring Non-psychotic Disorders
(High Disability)");
clusterdefarray(8) = ("CARE CLUSTER 8: Non-Psychotic Chaotic && Challenging
Disorders");
clusterdefarray(9) = ("CARE CLUSTER 9: Blank Cluster");
clusterdefarray(10) = ("CARE CLUSTER 10: First Episode Psychosis");
clusterdefarray(11) = ("CARE CLUSTER 11: Ongoing Recurrent Psychosis (Low
Symptoms)");
clusterdefarray(12) = ("CARE CLUSTER 12: Ongoing || recurrent Psychosis
(High Disability)");
clusterdefarray(13) = ("CARE CLUSTER 13: Ongoing || Recurrent Psychosis
(High Symptom + Disability)");
clusterdefarray(14) = ("CARE CLUSTER 14: Psychotic Crisis.");
clusterdefarray(15) = ("CARE CLUSTER 15: Severe Psychotic Depression");
clusterdefarray(16) = ("CARE CLUSTER 16: Dual Diagnosis");
clusterdefarray(17) = ("CARE CLUSTER 17: Psychosis && Affective Disorder â??
Difficult to Engage");
clusterdefarray(18) = ("CARE CLUSTER 18: Cognitive Impairment (Low Need)");
clusterdefarray(19) = ("CARE CLUSTER 19: Cognitive Impairment || Dementia
Complicated (Moderate Need)");
clusterdefarray(20) = ("CARE CLUSTER 20: Cognitive Impairment || Dementia
Complicated (High Need)");
clusterdefarray(21) = ("CARE CLUSTER 21: Cognitive Impairment || Dementia
(High Physical || Engagement)")


if(document.getElementByid ("HO_HONOS_NPPN").value = "Non-psychotic"){
clusterno= 1;
endclusterno= 8;
}

if(document.getElementByid ("HO_HONOS_NPPN").value = "Psychosis"){
clusterno= 10;
endclusterno= 17;
}

if(document.getElementByid ("HO_HONOS_NPPN").value = "Organic"){
clusterno= 18;
endclusterno= 21;
}


highestclusterscore = -100;
bestmatchedcluster = 0;
secondhighestclusterscore = -100;
secondbestmatchedcluster = 0

do

cbox = 2;
quesno = 2;
clustertotal = 0

do;
cCont= document.getElementByid ("HO_HONOS_" + cbox).value


var CN;
var RS;

CN = new ActiveXObject("ADODB.Connection")
RS = new ActiveXObject("ADODB.RecordSet")

CN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=Y:\My
Documents\PBR\Clusterdatabase.mdb" ;
RS.CursorLocation = 1;
RS.Open "SELECT * FROM Cluster" + clusterno,CN


data = rs.GetRows(5);
element = data(quesno, cCont)

clustertotal = clustertotal + element


cbox=cbox+1;
quesno=quesno+1


loop until cbox = 19

if(clusterno == 10){

if(document.getElementByid ("HO_HONOS_FE").value = "No"){
clustertotal = clustertotal - 1000;
}

if(document.getElementByid ("HO_HONOS_FE").value = "Yes"){
clustertotal = clustertotal + 20;
}

}



LOER = data(20, 0);
range = data(19, 0)

clustertotal = ((clustertotal + LOER)/range) *100





if(clustertotal => highestclusterscore){
secondbestmatchedcluster = bestmatchedcluster;
secondhighestclusterscore = highestclusterscore;
highestclusterscore = clustertotal;
bestmatchedcluster = clusterno;
}

if(clustertotal < highestclusterscore){
if(clustertotal => secondhighestclusterscore){
secondbestmatchedcluster = clusterno;
secondhighestclusterscore = clustertotal;
}
}

RS.Close;
clusterno = clusterno + 1

loop until clusterno = endclusterno + 1

document.getElementByid ("TextBox11").value = (clusterdefarray
(bestmatchedcluster));
document.getElementByid ("TextBox1").value = (clusterdefarray
(secondbestmatchedcluster));
document.getElementByid ("Label1").caption = (round (highestclusterscore));
document.getElementByid ("Label2").caption = (round
(secondhighestclusterscore));
document.getElementByid ("Label3").caption = (bestmatchedcluster);
document.getElementByid ("Label4").caption = (secondbestmatchedcluster)

RS.Close

CN.Close;

CN = null
RS = null


}
6 Answers

Mike Scirocco

8/27/2010 5:42:00 PM

0

On 8/27/2010 9:33 AM, Atishoo wrote:
> Hi
> Am trying to convert a vbscript programme i wrote in javascript with little
> success!!
>
> can anyone help?
>
> script as follows
>
> function calculatecluster()
>
> {
>
> var bestmatchedcluster;
> var secondbestmatchedcluster;
> var clusterdefarray(21)
>
> clusterdefarray(0) = ("CARE CLUSTER 0: Variance");
> clusterdefarray(1) = ("CARE CLUSTER 1: Common Mental Health Problems (Low
> Severity)");
> clusterdefarray(2) = ("CARE CLUSTER 2: Common Mental Health Problems (Low
> Severity with greater need)");
> clusterdefarray(3) = ("CARE CLUSTER 3: Non Psychotic (Moderate Severity)");
> clusterdefarray(4) = ("CARE CLUSTER 4: Non-psychotic (Severe)");
> clusterdefarray(5) = ("CARE CLUSTER 5: Non-psychotic Disorders (Very
> Severe)");
> clusterdefarray(6) = ("CARE CLUSTER 6: Non-psychotic Disorder of Over-valued
> Ideas");
> clusterdefarray(7) = ("CARE CLUSTER 7: Enduring Non-psychotic Disorders
> (High Disability)");
> clusterdefarray(8) = ("CARE CLUSTER 8: Non-Psychotic Chaotic&& Challenging
> Disorders");
> clusterdefarray(9) = ("CARE CLUSTER 9: Blank Cluster");
> clusterdefarray(10) = ("CARE CLUSTER 10: First Episode Psychosis");
> clusterdefarray(11) = ("CARE CLUSTER 11: Ongoing Recurrent Psychosis (Low
> Symptoms)");
> clusterdefarray(12) = ("CARE CLUSTER 12: Ongoing || recurrent Psychosis
> (High Disability)");
> clusterdefarray(13) = ("CARE CLUSTER 13: Ongoing || Recurrent Psychosis
> (High Symptom + Disability)");
> clusterdefarray(14) = ("CARE CLUSTER 14: Psychotic Crisis.");
> clusterdefarray(15) = ("CARE CLUSTER 15: Severe Psychotic Depression");
> clusterdefarray(16) = ("CARE CLUSTER 16: Dual Diagnosis");
> clusterdefarray(17) = ("CARE CLUSTER 17: Psychosis&& Affective Disorder â??
> Difficult to Engage");
> clusterdefarray(18) = ("CARE CLUSTER 18: Cognitive Impairment (Low Need)");
> clusterdefarray(19) = ("CARE CLUSTER 19: Cognitive Impairment || Dementia
> Complicated (Moderate Need)");
> clusterdefarray(20) = ("CARE CLUSTER 20: Cognitive Impairment || Dementia
> Complicated (High Need)");
> clusterdefarray(21) = ("CARE CLUSTER 21: Cognitive Impairment || Dementia
> (High Physical || Engagement)")
>
>
> if(document.getElementByid ("HO_HONOS_NPPN").value = "Non-psychotic"){
> clusterno= 1;
> endclusterno= 8;
> }
>
> if(document.getElementByid ("HO_HONOS_NPPN").value = "Psychosis"){
> clusterno= 10;
> endclusterno= 17;
> }
>
> if(document.getElementByid ("HO_HONOS_NPPN").value = "Organic"){
> clusterno= 18;
> endclusterno= 21;
> }
>
>
> highestclusterscore = -100;
> bestmatchedcluster = 0;
> secondhighestclusterscore = -100;
> secondbestmatchedcluster = 0
>
> do
>
> cbox = 2;
> quesno = 2;
> clustertotal = 0
>
> do;
> cCont= document.getElementByid ("HO_HONOS_" + cbox).value
>
>
> var CN;
> var RS;
>
> CN = new ActiveXObject("ADODB.Connection")
> RS = new ActiveXObject("ADODB.RecordSet")
>
> CN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=Y:\My
> Documents\PBR\Clusterdatabase.mdb" ;
> RS.CursorLocation = 1;
> RS.Open "SELECT * FROM Cluster" + clusterno,CN
>
>
> data = rs.GetRows(5);
> element = data(quesno, cCont)
>
> clustertotal = clustertotal + element
>
>
> cbox=cbox+1;
> quesno=quesno+1
>
>
> loop until cbox = 19
>
> if(clusterno == 10){
>
> if(document.getElementByid ("HO_HONOS_FE").value = "No"){
> clustertotal = clustertotal - 1000;
> }
>
> if(document.getElementByid ("HO_HONOS_FE").value = "Yes"){
> clustertotal = clustertotal + 20;
> }
>
> }
>
>
>
> LOER = data(20, 0);
> range = data(19, 0)
>
> clustertotal = ((clustertotal + LOER)/range) *100
>
>
>
>
>
> if(clustertotal => highestclusterscore){
> secondbestmatchedcluster = bestmatchedcluster;
> secondhighestclusterscore = highestclusterscore;
> highestclusterscore = clustertotal;
> bestmatchedcluster = clusterno;
> }
>
> if(clustertotal< highestclusterscore){
> if(clustertotal => secondhighestclusterscore){
> secondbestmatchedcluster = clusterno;
> secondhighestclusterscore = clustertotal;
> }
> }
>
> RS.Close;
> clusterno = clusterno + 1
>
> loop until clusterno = endclusterno + 1
>
> document.getElementByid ("TextBox11").value = (clusterdefarray
> (bestmatchedcluster));
> document.getElementByid ("TextBox1").value = (clusterdefarray
> (secondbestmatchedcluster));
> document.getElementByid ("Label1").caption = (round (highestclusterscore));
> document.getElementByid ("Label2").caption = (round
> (secondhighestclusterscore));
> document.getElementByid ("Label3").caption = (bestmatchedcluster);
> document.getElementByid ("Label4").caption = (secondbestmatchedcluster)
>
> RS.Close
>
> CN.Close;
>
> CN = null
> RS = null
>
>
> }

I can't test this but I think it will get you close. If it doesn't work
feel free to email me, as well as posting to alt.comp.lang.javascript.

<script type="text/javascript">
function calculatecluster(){
var adOpenDynamic = 2;
var adLockOptimistic = 3;
var cbox, quesno, clustertotal, cCont;
var clusterdefarray = new Array()
clusterdefarray[0] = "CARE CLUSTER 0: Variance";
clusterdefarray[1] = "CARE CLUSTER 1: Common Mental Health Problems
(Low Severity)";
clusterdefarray[2] = "CARE clusTER 2: Common Mental Health Problems
(Low Severity with greater need)";
clusterdefarray[3] = "CARE clusTER 3: Non Psychotic (Moderate Severity)";
clusterdefarray[4] = "CARE clusTER 4: Non-psychotic (Severe)";
clusterdefarray[5] = "CARE clusTER 5: Non-psychotic Disorders (Very
Severe)";
clusterdefarray[6] = "CARE clusTER 6: Non-psychotic Disorder of
Over-valued Ideas";
clusterdefarray[7] = "CARE clusTER 7: Enduring Non-psychotic
Disorders (High Disability)";
clusterdefarray[8] = "CARE clusTER 8: Non-Psychotic Chaotic &&
Challenging Disorders";
clusterdefarray[9] = "CARE clusTER 9: Blank cluster";
clusterdefarray[10] = "CARE clusTER 10: First Episode Psychosis";
clusterdefarray[11] = "CARE clusTER 11: Ongoing Recurrent Psychosis
(Low Symptoms)";
clusterdefarray[12] = "CARE clusTER 12: Ongoing || recurrent
Psychosis (High Disability)";
clusterdefarray[13] = "CARE clusTER 13: Ongoing || Recurrent
Psychosis (High Symptom + Disability)";
clusterdefarray[14] = "CARE clusTER 14: Psychotic Crisis.";
clusterdefarray[15] = "CARE clusTER 15: Severe Psychotic Depression";
clusterdefarray[16] = "CARE clusTER 16: Dual Diagnosis";
clusterdefarray[17] = "CARE clusTER 17: Psychosis && Affective
Disorder â?? Difficult to Engage";
clusterdefarray[18] = "CARE clusTER 18: Cognitive Impairment (Low Need)";
clusterdefarray[19] = "CARE clusTER 19: Cognitive Impairment ||
Dementia Complicated (Moderate Need)";
clusterdefarray[20] = "CARE clusTER 20: Cognitive Impairment ||
Dementia Complicated (High Need)";
clusterdefarray[21] = "CARE clusTER 21: Cognitive Impairment ||
Dementia (High Physical || Engagement)";

var clusterno;
var endclusterno;

var ho_honos_nppn=document.getElementById("HO_HONOS_NPPN").value);
switch (ho_honos_nppn){
case "Non-psychotic" : { clusterno= 1; endclusterno= 8; break; }
case "Psychosis" : { clusterno= 10; endclusterno= 17; break; }
case "Organic" : { clusterno= 18; endclusterno= 21; break; }
}

var highestclusterscore = -100;
var bestmatchedcluster = 0;
var secondhighestclusterscore = -100;
var secondbestmatchedcluster = 0

clusterno = endclusterno + 1

for (var n=clusterno; n<endclusterno+1; n++){
quesno = 2;
clustertotal = 0;
for (cbox=; cbox<19; cbox++){
cCont= document.getElementByid ("HO_HONOS_" + cbox).value;
var CN = new ActiveXObject("ADODB.Connection")
CN.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=Y:\My
Documents\PBR\clusterdatabase.mdb" ;
var RS = new ActiveXObject("ADODB.RecordSet")
RS.Open "SELECT * FROM cluster" + clusterno,CN, adOpenDynamic,
adLockOptimistic)
RS.CursorLocation = 1;
if(!rs.bof) {
//rs.MoveFirst() //not sure if this is needed
if(!rs.eof) {
var myData = RS.GetRows(5).toArray();
//var data = rs.GetRows(5);
element = data[quesno, cCont];
clustertotal = clustertotal + element;
quesno=quesno+1
}
}
} //loop until cbox = 19
if(clusterno == 10){
var ho_honos_fe=document.getElementById("HO_HONOS_FE").value
if (ho_honos_fe == "No"){
clustertotal = clustertotal - 1000;
}elseif(ho_honos_fe) == "Yes"){
clustertotal = clustertotal + 20;
}
}
var LOER = data[20, 0];
var range = data[19, 0];
clustertotal = ((clustertotal + LOER)/range)*100;
if(clustertotal >= highestclusterscore){
secondbestmatchedcluster = bestmatchedcluster;
secondhighestclusterscore = highestclusterscore;
highestclusterscore = clustertotal;
bestmatchedcluster = clusterno;
}else{
//if (clustertotal < highestclusterscore){
if(clustertotal >- secondhighestclusterscore){
secondbestmatchedcluster = clusterno;
secondhighestclusterscore = clustertotal;
}
}
RS.Close;
} //loop until clusterno = endclusterno + 1

document.getElementByid ("TextBox11").value = (clusterdefarray
[bestmatchedcluster]);
document.getElementByid ("TextBox1").value = (clusterdefarray
[secondbestmatchedcluster]);
document.getElementByid ("Label1").caption =
(Math.round(highestclusterscore));
document.getElementByid ("Label2").caption =
(Math.round(secondhighestclusterscore));
document.getElementByid ("Label3").caption = (bestmatchedcluster);
document.getElementByid ("Label4").caption = (secondbestmatchedcluster)
RS.Close();
RS = null;
CN.Close();
CN = null;
}
</script>

Kevin Provance

8/27/2010 5:48:00 PM

0

You would be better served to post this in a javascript forum, whereever
that might be.

Mike Scirocco

8/27/2010 5:53:00 PM

0

On 8/27/2010 10:42 AM, Mike S wrote:

Sorry, I posted too quickly, corrections:

> var ho_honos_nppn=document.getElementById("HO_HONOS_NPPN").value);
var ho_honos_nppn=document.getElementById("HO_HONOS_NPPN").value;

> var LOER = data[20, 0];
> var range = data[19, 0];

var LOER = myData[20, 0];
var range = myData[19, 0];

remove enclosing parentheses on right side of equal sign;

document.getElementByid ("TextBox11").value = (clusterdefarray
[bestmatchedcluster]);
document.getElementByid ("TextBox1").value = (clusterdefarray
[secondbestmatchedcluster]);
document.getElementByid ("Label1").caption =
(Math.round(highestclusterscore));
document.getElementByid ("Label2").caption =
(Math.round(secondhighestclusterscore));
document.getElementByid ("Label3").caption = (bestmatchedcluster);
document.getElementByid ("Label4").caption = (secondbestmatchedcluster)

Apologies,
Mike

Davo

8/27/2010 9:58:00 PM

0

Hi Mike
Thanks for your reply I am however having a lot of trouble with ms discussion groups and cant get back into my posted question to see your reply only got your corrections.
is there any chance you could email me your response?
Many Thanks
John
alexanderjohnsalter@hotmail.com


Kevin Provance

8/27/2010 10:47:00 PM

0

Mike = pwned.

Now you're in it for the long haul.


"atishoo" <user@msgroups.net/> wrote in message
news:%2326NjLjRLHA.4960@TK2MSFTNGP05.phx.gbl...
: Hi Mike
: Thanks for your reply I am however having a lot of trouble with ms
discussion groups and cant get back into my posted question to see your
reply only got your corrections.
: is there any chance you could email me your response?
: Many Thanks
: John
: alexanderjohnsalter@hotmail.com
:
:

Mike Scirocco

8/28/2010 2:14:00 AM

0

On 8/27/2010 3:46 PM, Kevin Provance wrote:
> Mike = pwned.
> Now you're in it for the long haul.

Haha, no worries, it's fun sorting this stuff out.