# ncc1701d

Members

11

0 Neutral

• Rank
Newbie
1. ## how can i make my loop start at certain time?

Foxy Mod...Ya .. without going into to much detail... stellarium has its own time function.....core.setDate("+1 hours");... but it has a bug or something going on where when you use it in a loop it looses acuracy over time. I tryed to get them to look at but they dont seem interested in doing much about. if your interested I brought up subject originally here https://sourceforge.net/p/stellarium/discussion/278769/thread/6de51bae/ "malformatted string" was brought up as the problem in their function and direction to javascripts tutorials to help with alternatives etc lead me here. dsonesuk..I have not tryed your idea yet. Thats still above my capabiliites but food for thought.
2. ## how can i make my loop start at certain time?

Thanks that is good and tested well. I dont understand math.floor and % yet. I may post a follow up question here soon dealing with expanding my program to include days, months and years. I have added that to my method and am stuck on integrating concepts of leap year and dealing with the fact that some months have 30 days and some having 31 days and feb having 29 or 28 days. Because i added days and months and years as the time increments increase I have to make sure it skips over generating days that dont exist for certain months.
3. ## how can i make my loop start at certain time?

ok this worked.thanks everyone for your input. var minutes = 0 var seconds = 50 var hours = 7 while (seconds < 100000) { seconds++; if (seconds > 59) { seconds = 0 //resets seconds counter to 0 minutes++; } if (minutes > 59) { minutes = 0 //resets seconds counter to 0 hours++; } //core.output("minutes " + minutes +" seconds " + seconds ); core.output("hours " + hours + "minutes " + minutes +" seconds " + seconds ); core.wait(.4); }
4. ## how can i make my loop start at certain time?

this is my first attempt at it using while but not working out so well. Iam a beginner programmer so i could be missing some very basic things thing. var minutes = 0 var seconds = 50 while (seconds < 100000) { if (seconds > 59) { var minutes = 0 //resets seconds counter to 0 var seconds = 0 //resets seconds counter to 0 minutes++; } seconds++; core.output("minutes " + minutes +" seconds " + seconds ); core.wait(1); } output looks like: minutes 0 seconds 51 minutes 0 seconds 52 minutes 0 seconds 53 minutes 0 seconds 54 minutes 0 seconds 55 minutes 0 seconds 56 minutes 0 seconds 57 minutes 0 seconds 58 minutes 0 seconds 59 minutes 0 seconds 60 //error should say minutes 1 seconds 0 minutes 1 seconds 1 minutes 1 seconds 2 minutes 1 seconds 3 minutes 1 seconds 4 minutes 1 seconds 5 minutes 1 seconds 6 minutes 1 seconds 7 minutes 1 seconds 8 minutes 1 seconds 9 minutes 1 seconds 10 minutes 1 seconds 11 etc etc moving downward minutes 1 seconds 55 minutes 1 seconds 56 minutes 1 seconds 57 minutes 1 seconds 58 minutes 1 seconds 59 minutes 1 seconds 60 //problem again minutes 1 seconds 1 //other problem is the minute counter wont advance anymore Dont know why. minutes 1 seconds 2 minutes 1 seconds 3 minutes 1 seconds 4
5. ## how can i make my loop start at certain time?

Its for a script in "Stellarium" Astronomy program. That program uses javascript language but doesnt recognise lots of time functions that javascript has. When i run the program in stellariums really basic editor i can stop the script from running manually and i can add "waits" to slow down how fast each line is output to text file. Thats why Iam not too worried about crashes from while loops that go on forever. As far as when the text file is done being generated i dont care much at this point since i can stop the program manually but Ultimatly I need to generate a text file that is probably no more than like 36 hours but still greater that 24 hours but i would like to keep the ending "open ended" at this point. The counter per line would increment would work like any digital clock. Iam mainly only interested at this point of the basic counting and looping of numbers per text line using javascript.
6. ## how can i make my loop start at certain time?

My goal is to output line by line in a text file over and over again with the time increasing by 1 second as i go, from a time of my choosing, looking like the example below. (Right now what i have posted only works if i start at hour=0 minute=0 and sec =0) As it increases the seconds change and eventually the minutes and then hours Example below just shows what the format would look like when its output. If there is another way besides loops i am open to it but i cant use the time related functions that come wth javascript. I canNOT use any functions from here though..http://www.w3schools.com/js/js_date_methods.asp Example of what I would like it to look like is below but I want it to continue indefinatly. Iam not worried about it if it crashes from running indefinatly hours = 1 minutes =1 seconds =57 //starting point of my choosing like this line i cant do. thats my problem. hours = 1 minutes =1 seconds =58 hours = 1 minutes =1 seconds =59 hours = 1 minutes =2 seconds =0 hours = 1 minutes =2 seconds =1 hours = 1 minutes =2 seconds =2
7. ## how can i make my loop start at certain time?

I have a nested "for loop below. It nicely cycles through displaying like clock. Every count of 60 seconds ups the minute and every 60 minutes ups the hour. The question I have is. How can make it so that I can start the count out at say hour = 5 minutes = 24 seconds = 30 ? but not have the for loop affected. Like for Example..I could just change say s = 0 to s = 5 but when it starts to loop again seconds doesnt start out at 0 but starts at 5 which is not what I want. for example I only want to start out the program at 5 seconds or some moment in time not loop every 5 seconds. cuurent code is: for (var h = 0; h < 24; h++) { for (var m = 0; m < 60; m++) { for (var s = 0; s < 60; s++) { core.debug("hours = " + h + " minutes =" + m + " seconds =" + s); core.output("hours = " + h + " minutes =" + m + " seconds =" + s); } } } sample of output looks like this and works but only if var s=0 and var m = 0 and var h = 0 hours = 0 minutes =0 seconds =0 hours = 0 minutes =0 seconds =1 hours = 0 minutes =0 seconds =2 etc What I want to do is just start right in with counting that would output like this if I started with hours=1,minute=1 and seconds =57 but not screw up my counting clock for loops. hours = 1 minutes =1 seconds =57 hours = 1 minutes =1 seconds =58 hours = 1 minutes =1 seconds =59 hours = 1 minutes =2 seconds =0 hours = 1 minutes =2 seconds =1 hours = 1 minutes =2 seconds =2 Iam hoping there is an if then statement to solve my problem I dont have usage available to me using any javascript date functions that come with javascript like setMinutes() etc. thanks
8. ## how do I add more than one condition to an "if " statement ?

thanks iam sure that works for web page but i was hoping for something more simple in the way it was worded like the way i wrote it so i can incorporate it with my project which uses javascript script language in limited ways but is not for a webpage or browser. Iam a beginner. return ((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0);// like i have no idea what this line is even saying. maybe you can translate it in english?
9. ## how do I add more than one condition to an "if " statement ?

how do I add more than one condition to an "if " statement? for example i want to say if i < 42 and i is multple of 4 and is an odd number then print? how do i write that in javascript? or say i have i = 1951 // i would change value for i around to test if leap year or not if (i=1952 or 1956 or 1960 or 1964) //this does not work though { core.debug("oops this is leap year"); } else { core.debug("this is not leap year"); } thanks.
10. ## how can i make sequence of numbers repeat?

thank you Devoted and FoxyMod Devoted..yes yours did crash but was still helpful FoxyMod yours worked as expected Foxy Mod I would be interested in the nested version to see how that is done as well if you would like to share that with me that would be helpfull as well. Thank you.
11. ## how can i make sequence of numbers repeat?

I am total beginner so please dont be mean or make fun but i am having dificulty understanding this i have this basic script I run in Stellatium that uses some javascripts functions but not all of them for scripting. for (i = 0; i < 5; i++) { core.debug( + i) } it produces: 0 1 2 3 4 using only for loops or while loops how can I make it repeat over and over indefinatly ? 1 2 3 4 0 1 2 3 4 0 1 2 3 4
×