Author Topic: Astrobasic script to generate excel with planetary days and hours?  (Read 8430 times)

0 Members and 1 Guest are viewing this topic.

ABer

  • Administrator
  • Hero Member
  • *****
  • Posts: 1255
    • View Profile
Re: Astrobasic script to generate excel with planetary days and hours?
« Reply #15 on: December 08, 2020, 08:04:46 AM »
Thanks Jean - that's good news. Astrobasic really makes some amazing things possible.

It's great that new coders are joining in with the development of Planetdance.

Thanks Vivian.

Ed

Jean

  • Administrator
  • Hero Member
  • *****
  • Posts: 1313
    • View Profile
Re: Astrobasic script to generate excel with planetary days and hours?
« Reply #16 on: December 08, 2020, 06:10:30 PM »
Hi Vivian,

Finally found the time to have a decent look at your code. First i wasn't sure which planet you wanted the houseposition of but then it became clear finally. :)
I am very pleased to see your code, using switch() and things like if (P2[k] = map1[n] and P1[k] in map1 and (As[k]=3 or As[k]=1))
My compliments!

This may be what you want?

Code: [Select]
real jd, lon, lat, zone, jd0, jd1, jd2, v, houses[HOUSES], planet[PLANETS];
int i, w,  time[6], n, m, p, map[7] = { MOON, MARS, MERCURY, JUPITER, VENUS, SATURN, SUN }, map1[7] = { SATURN, JUPITER, MARS, SUN, VENUS, MERCURY, MOON };
char pos[PLANETS], place[99], s[256], wala[600]="", csv[600], csv2[600], ds[22], ts[22], timestr[22], center = 1, inifile[256] = "planhour.ini", textonly;
window(380, 600);
menu(0, "Close", close);
menu(0, "Go", go);
menu(0, "Place", place);
menu(0, "Help", NULL);
menu(0, "csv", csv);
menu(4, "English", help);
menu(4, "Nederlands", helpnl);
jd = getsystemtime(time);
getdefaultplace(place, lon, lat, 0); ` 0 returns code, needed for gettimezone
timetostring(time, timestr, ts, 0);
@load;
onclose(save);
edit(10, 0, 100, timestr, NULL);
checkbox(150, 0, "Center", center, go);
checkbox(250, 0, "Text only", textonly, go);
text(0, 50, width, height - 50, 0, 0, NULL);
texttab(0, 0, 20);
@putplace;
@go;
run;

:putplace;
  strcpy(s, place);
  strcmd(5, ',', s);
  putstring(5, 30, s);
  return;
 
:place;
  if (getplace(place, lon, lat, 1) = 1)
    {
    zone = gettimezone(place, jd, 1);
    @putplace;
    @go;
    }
  return;

:go;
  set(time, 0);
  timefromstring(timestr, time[0], time[1], time[2], 0);
  jd = timetojulian(time);                                  ` start search for sunrise at midnight
  n = @dayofweek(jd);                                       ` monday = 0

  zone = gettimezone(place, jd, 1);                         ` timezone for start of day
  jd -= zone;                                               ` convert to ut
  jd0 = getriseset(jd, SUN, 1, lon, lat, center, "");                ` sunrise in ut
  jd1 = getriseset(jd0, SUN, 0, lon, lat, center, "");               ` next sunset
  jd2 = getriseset(jd1, SUN, 1, lon, lat, center, "");              ` sunrise next day
  zone = gettimezone(place, jd0, 0);                                ` take zone at sunrise
  p = map[n];
  n = 0; for (n < 7)
    {
    if (p = map1[n]) break;
    }
  m = 1;
  textclear(0);

  int sign, n2, n3, hows;
  char rango[5];
  move(wala, csv, 599);
  move(wala, csv2, 599);
  strset(csv, "Day time%n%s",timestr);
 
  command(FUNCTION, 49, textonly, 0);
  v = (jd1 - jd0) / 12;                                  ` daytime
  i = 0; for (i < 12)
    {
    jd = jd0 + i * v;
    calculate(0, jd, lon, lat, -1);              ` calculate horoscope using jd
                 char t[99], u[99];
               n2=n;
          @hanapsign;                          `get sign of planet n; check if Ruler, Exalted, Detriment, Fall
               n3=n;
          @hanaphouse;                          `get house of planet n
          @hanapaspects;                          `get aspects of planet n
gethousepos(0, pos);
    juliantotime(jd + zone, time);                        ` report local time
    timetostring(time, ds, ts, 0);
    strset(s, "%2d,%t%s,%s,%p,%d,%i,%s, - %s", m, ds, ts, map1[n], pos[map1[n]] + 1, sign, rango, t);
    strset(csv,"%s%n%s,%2d,%p,%i,%s,h,-%s",csv,ts,m,map1[n],sign,rango,t);
    strset(t, "");
    textadd(0, s);
    strset(s, "");

    m += 1;
    n = (n + 1) % 7;
    }
  strset(csv2,"%nNight time");
  v = (jd2 - jd1) / 12;                                   ` nighttime
  i = 0; for (i < 12)
    {
    jd = jd1 + i * v;
    calculate(0, jd, lon, lat, -1);              ` calculate horoscope using jd
               n2=n;
          @hanapsign;                             `get sign of planet n
          @hanaphouse;                            `get house of planet n
               strset(t," ");
          @hanapaspects;                          `get aspects of planet n
                 
    juliantotime(jd + zone, time);                        ` report local time
    timetostring(time, ds, ts, 0);
    strset(s, "%2d,%t%s,%s,%p,%i,%s, - %s", m, ds, ts, map1[n], sign, rango, t);
    strset(csv2,"%s%n%s,%2d,%p,%i,%s,h,-%s",csv2,ts,m,map1[n],sign,rango,t);
    strset(t, "");
    textadd(0, s);
    strset(s, "");
   
    m += 1;
    n = (n + 1) % 7;
    }

  textshow(0);
  return;

#dayofweek(real jd)
{
return (((jd - 2433282 - 1.5) % 7) + 7) % 7;
}


:hanapsign;
  getplanets(0, planet);
  int sign2;
  switch(n2)
           {
           :0;
              sign=planet[6]/30;
                    if (sign=9 or sign=10) {strset(rango, "R");}
                    else {if (sign=3 or sign=4) {strset(rango, "D");}
                    else {if (sign=6) {strset(rango, "E");}
                    else {if (sign=0) {strset(rango, "F");}
                    else {strset(rango, " -");  }}}}
              break;
           :1;
              sign=planet[5]/30;
                    if (sign=11 or sign=0) {strset(rango, "R");}
                    else {if (sign=5 or sign=2) {strset(rango, "D");}
                    else {if (sign=3) {strset(rango, "E");}
                    else {if (sign=9) {strset(rango, "F");}
                    else {strset(rango, " -");  }}}}
              break;
           :2;
              sign=planet[4]/30;
                    if (sign=0 or sign=7) {strset(rango, "R");}
                    else {if (sign=6 or sign=1) {strset(rango, "D");}
                    else {if (sign=9) {strset(rango, "E");}
                    else {if (sign=3) {strset(rango, "F");}
                    else {strset(rango, " -");  }}}}
              break;
           :3;
              sign=planet[0]/30;
                    if (sign=4) {strset(rango, "R");}
                    else {if (sign=10) {strset(rango, "D");}
                    else {if (sign=0) {strset(rango, "E");}
                    else {if (sign=6) {strset(rango, "F");}
                    else {strset(rango, " -");  }}}}
              break;
           :4;
              sign=planet[3]/30;
                    if (sign=1 or sign=6) {strset(rango, "R");}
                    else {if (sign=7 or sign=0) {strset(rango, "D");}
                    else {if (sign=11) {strset(rango, "E");}
                    else {if (sign=5) {strset(rango, "F");}
                    else {strset(rango, " -");  }}}}
              break;
           :5;
              sign=planet[2]/30;
                    if (sign=2 or sign=5) {strset(rango, "R");}
                    else {if (sign=8 or sign=11) {strset(rango, "D");}
                    else {if (sign=5) {strset(rango, "E");}
                    else {if (sign=11) {strset(rango, "F");}
                    else {strset(rango, " -");  }}}}
              break;
           :6;
              sign=planet[1]/30;
              if (sign=3) {strset(rango, "R");}
                    else {if (sign=9) {strset(rango, "D");}
                    else {if (sign=1) {strset(rango, "E");}
                    else {if (sign=7) {strset(rango, "F");}
                    else {strset(rango, " -");  }}}}
              break;
           }
  return;

:hanaphouse;
$
  gethousepos(0, houses);
  char hows2[99];
  switch(n3)
           {
           :0;hows=houses[6]; break;              `ngek :(
           :1;hows=houses[5]; break;
           :2;hows=houses[4]; break;
           :3;hows=houses[0]; break;
           :4;hows=houses[3]; break;
           :5;hows=houses[2]; break;
           :6;hows=houses[1]; break;
           }
  strset(hows2, "%d", house);
$
  return;

:hanapaspects;
              char P1[256], P2[256], As[256];                   ` get aspects
                 int total = getaspects(0, P1, P2, As), k, p1, p2, as;
                 k = 0; for (k < total)
                 {
                     p1 = P1[k];   ` first planet
                     p2 = P2[k];   ` second planet
                     as = As[k];   ` aspect

                     if (P1[k] = map1[n] and P2[k] in map1 and (As[k]=3 or As[k]=1))
                        {
                        strset(u, ",%e,%p", as, p2);
                        strcat(u, t);
                        strcpy(t,u);
                        }
                     if (P1[k] = map1[n] and P2[k] in map1 and As[k]!=3 and As[k]!=1)
                        {
                        strset(u, ",%e,%p", as, p2);
                        strcat(t, u);
                        }
                     if (P2[k] = map1[n] and P1[k] in map1 and (As[k]=3 or As[k]=1))
                        {
                        strset(u, ",%e,%p", as, p1);
                        strcat(u, t);
                        strcpy(t,u);
                        }
                     if (P2[k] = map1[n] and P1[k] in map1 and As[k]!=3 and As[k]!=1)
                        {
                        strset(u, ",%e,%p", as, p1);
                        strcat(t, u);
                        }
                 }
  return;
 
:close;
  quit;

:load;
  fileopen(inifile, FILEREADAB);
  fileread(center);
  fileread(textonly);
  fileread(place);
  fileread(lon);
  fileread(lat);
  fileclose;
  return;

:save;
  fileopen(inifile, FILEWRITEAB);
  filewrite(center);
  filewrite(textonly);
  filewrite(place);
  filewrite(lon);
  filewrite(lat);
  fileclose;
  return;

:csv;
  fileopen("receptionist.csv", FILEWRITE);
  filewrite(csv);
  filewrite(csv2);
  fileclose;
  return;
 
:help;
  help("Help Planetary hours", "Lists Planetary hours, enter a date and press Go.
'Center' means rising or setting of disc center, else rising or setting of lower limb of disc.

Export to MsExcel:
1. Click on 'csv'.
2. File will be created - C:\planetdance\receptionist.csv.
3. Open file C:\planetdance\receptionist.csv using MsExcel.
4. (ctrl+A) change font to planetdance
   or
4. Select all (ctrl+A), copy(ctrl+c).
5. Open another file C:\planetdance\rsked.xltm
      (macro enabled template file for stored formats).
6. Paste special - values (paste values)
7. 'Save as' to save changes.
8. 'csv' will not export to file C:\planetdance\receptionist.csv while the file is currently open in MsExcel.
9. Close the file first, then click 'csv'.

To do list:
1. done - add sign
2. done - evaluate if ruler, exalted, detriment or fall
3. add house - ngek :(
4. done - add aspects
5. sort aspect trine, sextine, conjunct, square, opposition
6. done - export to csv (MsExcel)
7. done - create template rsked.xltm to store formatting.


"
);
  return;

:helpnl;
  help("NL Help Planetaire uren", "Geeft Planetaire uren weer, voer een datum in en druk op Start.
'Center' betekent stijgen of ondergaan van het midden van de schijf, anders stijgen of ondergaan van het onderste deel van de schijf.");
  return;
Greetings from Groningen Netherlands.

VivianV

  • Guest
Re: Astrobasic script to generate excel with planetary days and hours?
« Reply #17 on: December 13, 2020, 07:57:49 AM »
Hello Jean, Hello Ed,

I got the "gethousepos(0, pos)" to work, whoooopie!

If I use it inside a function ":searchhouse" it gets confused, like me hehehe. So I just used it within the body of  ":go" and it worked.
I've done initial checking of the data and so far I am getting the right info.

Thank you so much, both of you, for helping and the encouragement was what really kept me going :)

Vivian




VivianV

  • Guest
Re: Astrobasic script to generate excel with planetary days and hours?
« Reply #18 on: December 13, 2020, 08:06:26 AM »
I don't mind sharing the codes but it's messy inside hahaha which was why Jean had a difficult time figuring out what I was trying to do  ;D ;D ;D


Jean

  • Administrator
  • Hero Member
  • *****
  • Posts: 1313
    • View Profile
Re: Astrobasic script to generate excel with planetary days and hours?
« Reply #19 on: December 13, 2020, 09:35:55 AM »
That is why planetdance is no open source, people could get hurt reading all my code haha.

Congrats Vivian, for me this is a gift, other people making scripts for themselves.

What error did you get when using :searchhouse ? Maybe 'nested if'?

I don't mind sharing the codes but it's messy inside hahaha which was why Jean had a difficult time figuring out what I was trying to do  ;D ;D ;D
Greetings from Groningen Netherlands.

ABer

  • Administrator
  • Hero Member
  • *****
  • Posts: 1255
    • View Profile
Re: Astrobasic script to generate excel with planetary days and hours?
« Reply #20 on: December 13, 2020, 09:46:00 AM »
Great news Vivian - I'm glad you sorted this out and you have a working script. Don't worry too much about perfect code. I'm getting better at ab but a lot of the time my code is pretty amateur. If it works, it's ok!

Keep coding and let us know how you get on.

Ed

VivianV

  • Guest
Hello Jean, Hello Ed,

I had to set astrology aside for the past several months. I had to attend to a lot of urgent demands of the physical world.

I just updated my Planetdance. When I ran receptionist, it notified me of errors.

I saw you've been quite busy with updates. No worries. I was able to fix the problem  ;D. My receptionist is running again.

Per day, it calculates the :
1. ruling planet of every hour
2. sign where the ruling planet is located
3. planetary power - Ruler, Detriment, Exalted, Fall
4. house where the ruling planet is located
5. other planets that are aspected to the ruling planet

Many, many thanks for creating Planetdance and astrobasic  :)

VivianV

  • Guest
Additional:

it also exports to .csv file which can be opened using excel.

Just an after thought coz the topic indicates "generate excel".   ::) ;D

Jean

  • Administrator
  • Hero Member
  • *****
  • Posts: 1313
    • View Profile
Great to see you're having fun with astrobasic Vivian, makes my day.

Good you could fix the errors, hope it wasn't too bad, sometimes i change  the syntax of a command, however i try to document any changes in the help.
I'm curious, could you post a screenshot or maybe mail the script to have a look?
Greetings from Groningen Netherlands.

VivianV

  • Guest
I used gettimezone which I saw was modified april 2021. But the modification reflected a few days ago when I updated my planetdance.

I will try to send receptionist.ab to your email, in case you're interested. But I haven't checked it thoroughly. I just needed data quickly for something else. Once I had the data, I went on to doing "the something else" hehehe.

Like I've been hinting at before  ;D your program is so useful and I am sooo grateful that you spent so much time and effort creating it. Thank you  :) :) :)