PDA

View Full Version : retrieving data


dazpearce
02-23-2003, 05:04 PM
i have a value (q) which varies from 1 to 6, this value is then assigned 7 angle coefficients, this is what i have, but it doesnt work:
var equatorQValue = q;{
if (equatorQValue == 1) {
b1 = 18.66;
b2 = 3.90;
b3 = 3.37;
b4 = 0.16;
b5 = 2.55;
b6 = -0.13;
b7 = 0.96;
}
else if (equatorQValue == 2) {
b1 = 19.73;
b2 = 4.69;
b3 = 3.34;
b4 = -0.57;
b5 = -1.41;
b6 = -0.07;
b7 = 0.75;
}
else if (equatorQValue == 3) {
b1 = 20.63;
b2 = 4.95;
b3 = 3.31;
b4 = -0.66;
b5 = -1.28;
b6 = 0.30;
b7 = -0.58;
}
else if (equatorQValue == 4) {
b1 = 21.56;
b2 = 4.93;
b3 = 3.31;
b4 = -0.44;
b5 = -0.81;
b6 = -0.07;
b7 = -0.75;
}
else if (equatorQValue == 5) {
b1 = 22.32;
b2 = 4.96;
b3 = 3.29;
b4 = -0.39;
b5 = -0.72;
b6 = -0.16;
b7 = -0.52;
}
else if (equatorQValue == 6) {
b1 = 23.18;
b2 = 4.85;
b3 = 3.34;
b4 = -0.38;
b5 = -0.62;
b6 = -0.53;
b7 = -0.16;
}
trace ("equator angles " + equatorQValue);
}

Ricod
02-23-2003, 05:48 PM
The only thing I'm seeing whats weird is that the close bracket and the else if statement aren't on the same line, but I doubt thats causing the unexpected results. What results do you get anyway ? Do you get coordiantes ? Or do you get an 'undefined' ? :confused:

Also, in situations like this, if you have MX that is, it might be a good idea to use switch / case statements. I have no experience with them though, but since everybody keeps telling others to use them, I guess they are cleaner, eh ? ;)

dazpearce
02-23-2003, 07:12 PM
im not getting anything, this is how it is attached to the function that makes the q value:
function ConvertKPtoQ(kpvaluesAr) {
var i = Math.floor(kpvaluesAr / 10);
var d = Math.round(kpvaluesAr % 10 / 3);
var kp = i + Math.round((d / 3) * 10) * .1;
var q = (kp == 0) ? 1 : Math.floor(kp + 2);
trace ("kp value = " + kpvaluesAr);
trace ("q value = " + q);
trace ("--------------------");
return (q > 6) ? 6 : q;

var equatorQValue = q;{
if (equatorQValue == 1) {
b1 = 18.66;
b2 = 3.90;
b3 = 3.37;
b4 = 0.16;
b5 = 2.55;
b6 = -0.13;
b7 = 0.96;
}
else if (equatorQValue == 2) {
b1 = 19.73;
b2 = 4.69;
b3 = 3.34;
b4 = -0.57;
b5 = -1.41;
b6 = -0.07;
b7 = 0.75;
}
else if (equatorQValue == 3) {
b1 = 20.63;
b2 = 4.95;
b3 = 3.31;
b4 = -0.66;
b5 = -1.28;
b6 = 0.30;
b7 = -0.58;
}
else if (equatorQValue == 4) {
b1 = 21.56;
b2 = 4.93;
b3 = 3.31;
b4 = -0.44;
b5 = -0.81;
b6 = -0.07;
b7 = -0.75;
}
else if (equatorQValue == 5) {
b1 = 22.32;
b2 = 4.96;
b3 = 3.29;
b4 = -0.39;
b5 = -0.72;
b6 = -0.16;
b7 = -0.52;
}
else if (equatorQValue == 6) {
b1 = 23.18;
b2 = 4.85;
b3 = 3.34;
b4 = -0.38;
b5 = -0.62;
b6 = -0.53;
b7 = -0.16;
}
trace ("equator angles " + equatorQValue);
}

i dont need to show b1-b7, just the numbers, can anyone help??

CyanBlue
02-23-2003, 07:30 PM
I have no idea what you are doing there, partner... I just checked syntax error and found that you had excessive bracket like Ricod mentioned...function ConvertKPtoQ(kpvaluesAr)
{
var i = Math.floor(kpvaluesAr / 10);
var d = Math.round(kpvaluesAr % 10 / 3);
var kp = i + Math.round((d / 3) * 10) * .1;
var q = (kp == 0) ? 1 : Math.floor(kp + 2);
trace("kp value = " + kpvaluesAr);
trace("q value = " + q);
trace("--------------------");
return (q > 6) ? 6 : q;
var equatorQValue = q;
if (equatorQValue == 1)
{
b1 = 18.66;
b2 = 3.90;
b3 = 3.37;
b4 = 0.16;
b5 = 2.55;
b6 = -0.13;
b7 = 0.96;
}
else if (equatorQValue == 2)
{
b1 = 19.73;
b2 = 4.69;
b3 = 3.34;
b4 = -0.57;
b5 = -1.41;
b6 = -0.07;
b7 = 0.75;
}
else if (equatorQValue == 3)
{
b1 = 20.63;
b2 = 4.95;
b3 = 3.31;
b4 = -0.66;
b5 = -1.28;
b6 = 0.30;
b7 = -0.58;
}
else if (equatorQValue == 4)
{
b1 = 21.56;
b2 = 4.93;
b3 = 3.31;
b4 = -0.44;
b5 = -0.81;
b6 = -0.07;
b7 = -0.75;
}
else if (equatorQValue == 5)
{
b1 = 22.32;
b2 = 4.96;
b3 = 3.29;
b4 = -0.39;
b5 = -0.72;
b6 = -0.16;
b7 = -0.52;
}
else if (equatorQValue == 6)
{
b1 = 23.18;
b2 = 4.85;
b3 = 3.34;
b4 = -0.38;
b5 = -0.62;
b6 = -0.53;
b7 = -0.16;
}
trace("equator angles " + equatorQValue);
}

for (i = 1 ; i <= 6 ; i++)
ConvertKPtoQ(i);and the output iskp value = 1
q value = 1
--------------------
kp value = 2
q value = 2
--------------------
kp value = 3
q value = 2
--------------------
kp value = 4
q value = 2
--------------------
kp value = 5
q value = 2
--------------------
kp value = 6
q value = 2
--------------------I don't know if that's what you are looking for or not though...

Next time when you post your code, please use code formatting (http://www.actionscript.org/forums/misc.php3?action=bbcode#buttons) so that it could be more readable and clean... :)

dazpearce
02-23-2003, 07:49 PM
not quite, but im nearly there, a 2 figure value called a kp value, goes into the convert function, this will produce a number (q value) between 1 and 6, what im trying to do is then take that q value and then match it with that list of angle coefficients, so for example
kp value of 47 will produce a q value of 6, i have this working fine
what i need is for an output of 23.18,4.85,-0.38,-0.62,-0.53, and -0.16, these angle coefficients will then go into another equation.
ive changed the brackets around and i get the trace equator angles, but blank after that

ive just realised, the trace is blank cos its calling the equator trace before the q value is produced, thats why its coming up blank, i think!, could that be right?

CyanBlue
02-23-2003, 08:27 PM
Basically you were not getting anything below your return function since Flash will stop running the function after it met the return statement...

Try this...function ConvertKPtoQ(kpvaluesAr)
{
var i = Math.floor(kpvaluesAr / 10);
var d = Math.round(kpvaluesAr % 10 / 3);
var kp = i + Math.round((d / 3) * 10) * .1;
var q = (kp == 0) ? 1 : Math.floor(kp + 2);
// trace("kp value = " + kpvaluesAr);
// trace("q value = " + q);
q = (q > 6) ? 6 : q;
var equatorQValue = q;
if (equatorQValue == 1)
{
b1 = 18.66;
b2 = 3.90;
b3 = 3.37;
b4 = 0.16;
b5 = 2.55;
b6 = -0.13;
b7 = 0.96;
}
else if (equatorQValue == 2)
{
b1 = 19.73;
b2 = 4.69;
b3 = 3.34;
b4 = -0.57;
b5 = -1.41;
b6 = -0.07;
b7 = 0.75;
}
else if (equatorQValue == 3)
{
b1 = 20.63;
b2 = 4.95;
b3 = 3.31;
b4 = -0.66;
b5 = -1.28;
b6 = 0.30;
b7 = -0.58;
}
else if (equatorQValue == 4)
{
b1 = 21.56;
b2 = 4.93;
b3 = 3.31;
b4 = -0.44;
b5 = -0.81;
b6 = -0.07;
b7 = -0.75;
}
else if (equatorQValue == 5)
{
b1 = 22.32;
b2 = 4.96;
b3 = 3.29;
b4 = -0.39;
b5 = -0.72;
b6 = -0.16;
b7 = -0.52;
}
else if (equatorQValue == 6)
{
b1 = 23.18;
b2 = 4.85;
b3 = 3.34;
b4 = -0.38;
b5 = -0.62;
b6 = -0.53;
b7 = -0.16;
}
// trace("equator angles " + equatorQValue);
tempArray = new Array();
for (i = 1; i <= 7; i++)
{
tempArray.push(this["b" + i]);
}
tempArray.unshift(q);
// trace("tempArray = " + tempArray);
// trace("--------------------");
return tempArray;
}
for (i = 1; i <= 47; i++)
{
trace(ConvertKPtoQ(i));
}1,18.66,3.9,3.37,0.16,2.55,-0.13,0.96
2,19.73,4.69,3.34,-0.57,-1.41,-0.07,0.75
2,19.73,4.69,3.34,-0.57,-1.41,-0.07,0.75
2,19.73,4.69,3.34,-0.57,-1.41,-0.07,0.75
2,19.73,4.69,3.34,-0.57,-1.41,-0.07,0.75
2,19.73,4.69,3.34,-0.57,-1.41,-0.07,0.75
2,19.73,4.69,3.34,-0.57,-1.41,-0.07,0.75
3,20.63,4.95,3.31,-0.66,-1.28,0.3,-0.58
3,20.63,4.95,3.31,-0.66,-1.28,0.3,-0.58
3,20.63,4.95,3.31,-0.66,-1.28,0.3,-0.58
3,20.63,4.95,3.31,-0.66,-1.28,0.3,-0.58
3,20.63,4.95,3.31,-0.66,-1.28,0.3,-0.58
3,20.63,4.95,3.31,-0.66,-1.28,0.3,-0.58
3,20.63,4.95,3.31,-0.66,-1.28,0.3,-0.58
3,20.63,4.95,3.31,-0.66,-1.28,0.3,-0.58
3,20.63,4.95,3.31,-0.66,-1.28,0.3,-0.58
3,20.63,4.95,3.31,-0.66,-1.28,0.3,-0.58
4,21.56,4.93,3.31,-0.44,-0.81,-0.07,-0.75
4,21.56,4.93,3.31,-0.44,-0.81,-0.07,-0.75
4,21.56,4.93,3.31,-0.44,-0.81,-0.07,-0.75
4,21.56,4.93,3.31,-0.44,-0.81,-0.07,-0.75
4,21.56,4.93,3.31,-0.44,-0.81,-0.07,-0.75
4,21.56,4.93,3.31,-0.44,-0.81,-0.07,-0.75
4,21.56,4.93,3.31,-0.44,-0.81,-0.07,-0.75
4,21.56,4.93,3.31,-0.44,-0.81,-0.07,-0.75
4,21.56,4.93,3.31,-0.44,-0.81,-0.07,-0.75
4,21.56,4.93,3.31,-0.44,-0.81,-0.07,-0.75
5,22.32,4.96,3.29,-0.39,-0.72,-0.16,-0.52
5,22.32,4.96,3.29,-0.39,-0.72,-0.16,-0.52
5,22.32,4.96,3.29,-0.39,-0.72,-0.16,-0.52
5,22.32,4.96,3.29,-0.39,-0.72,-0.16,-0.52
5,22.32,4.96,3.29,-0.39,-0.72,-0.16,-0.52
5,22.32,4.96,3.29,-0.39,-0.72,-0.16,-0.52
5,22.32,4.96,3.29,-0.39,-0.72,-0.16,-0.52
5,22.32,4.96,3.29,-0.39,-0.72,-0.16,-0.52
5,22.32,4.96,3.29,-0.39,-0.72,-0.16,-0.52
5,22.32,4.96,3.29,-0.39,-0.72,-0.16,-0.52
6,23.18,4.85,3.34,-0.38,-0.62,-0.53,-0.16
6,23.18,4.85,3.34,-0.38,-0.62,-0.53,-0.16
6,23.18,4.85,3.34,-0.38,-0.62,-0.53,-0.16
6,23.18,4.85,3.34,-0.38,-0.62,-0.53,-0.16
6,23.18,4.85,3.34,-0.38,-0.62,-0.53,-0.16
6,23.18,4.85,3.34,-0.38,-0.62,-0.53,-0.16
6,23.18,4.85,3.34,-0.38,-0.62,-0.53,-0.16
6,23.18,4.85,3.34,-0.38,-0.62,-0.53,-0.16
6,23.18,4.85,3.34,-0.38,-0.62,-0.53,-0.16
6,23.18,4.85,3.34,-0.38,-0.62,-0.53,-0.16I still don't know if the output is supposed to be like that though...

dazpearce
02-23-2003, 08:38 PM
nearly!, i only want one output, if you takeout the kpValuesAr and submit it for a number, say 47, you will get back a value of 6, i then need the angle coefficients under equatorQValue == 6 to be traced, geddit?
im sorry for confusing you, but im terrible at explaining myself

CyanBlue
02-23-2003, 08:51 PM
Well... If that's what you want, why not try to edit it yourself??? All you need is to return one value back and have other variables to be traced not pushed into an array...

The only reason why I am helping you to do this is not to do your homework for you, but to help you learn how to do things... Know what I mean??? ;)

dazpearce
02-23-2003, 09:20 PM
i am trying to learn but its very difficult, i have found that if i try stuff without knowing what im doing, i end up wasting days which i cant afford to waste, i just wish i wasnt so thick!
showing these values for instance, its now 9.37 pm, i started this morning a 10 am trying to get it to work, a whole day for something that would prob take mins for someone like yourself, its no excuse i know, its just frustrating
i will have a look at it tomorrow and try and work out how to do it, am i right in saying that i will have to make an array of my numbers in order to trace them?

CyanBlue
02-23-2003, 10:53 PM
Yes... I do understand what you mean by that... But you gotta understand why I am doing it... Right??? :)

Okay... You gotta tell me what you want to do with that function... Do you want the function return only 'q' or 'b1' to 'b7'??? Here is the reason behind it... When you use trace() function, it will trace out the data back to output panel... But it won't really be doing to the actual movie... It's fine if you just need those as a reference, but if you need to utilize those values in your main movie, you will have to return them as a result of the function execution... That's why I have used array as a return type... So, back to your question... No... You don't have to have them in the array just to trace them... They are there to return the value back...

Why don't you try it yourself, and see how it goes... And you are welcome to come back and knock the door anytime when you have problem... :D

dazpearce
02-24-2003, 01:09 PM
i will put it in an array because these angle coefficients will be input into another equation.
i will try and sort it out, thank you for your help and patience