Planetdance forum

Board index => Astrobasic => Topic started by: oneirich on August 20, 2020, 07:32:24 AM

Title: Astrobasic script to generate excel with planetary days and hours?
Post by: oneirich on August 20, 2020, 07:32:24 AM
Someone skilled with Planetdance's scripting language?

Would like to have something that can make an Excel with: date, time, planet of the day and planet time. If that's possible with the scripting language, at least, but I'm guessing so?
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: Jean on August 20, 2020, 07:47:44 AM
If you have programming knowledge take a look at c:\planetdance\ab\Excel.ab, it im/exports to/from .csv files.
Maybe you can start with Application - Edit, give your script a name, now you have an empty window, do in the editor application - templates and use 'horoscope', that will give you something to start with.
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: oneirich on August 20, 2020, 10:25:32 AM
Programming knowledge have, but it's time that is scarce, well it was worth the shot! Thx for your reply !
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: ABer on August 20, 2020, 06:15:34 PM
HI - I have developed Jean's script with additional features, can you describe what you want. All I ask is that if you use this and modify it you let me have your code so that we can continue to improve the features of PD. I don't release this generally as it is a very specialist script for research purposes. Ed
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: oneirich on August 21, 2020, 06:03:11 AM
The two options Planetary Day & Planetary Hour if I like at your screenshot. If the moon sign of that day can be added too that would be perfect...

Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: ABer on August 21, 2020, 06:26:44 AM
Hi - you can get sign positions for each of the planets using checkbox Planet Signs (column two, list item two). This will output all the basic planetary listings by Sign (Sun-Pluto, Fortune, Lilith, Asc, MC, Node, Chiron etc). You would then be able to work with the spreadsheet to identify the Moon sign column in particular. The script is a beta really, and needs a bit of understanding to work, so this is why I don't publish it, but release it for researchers if they express an interest. It's not complicated, but needs some knowledge of research/data manipulation.

You can see the output below. The data you want is outputted as integers.

Aries = 1
Taurus = 2
Gemini = 3 etc

The hour and day rulers are:

Sun = 0
Moon =  1
Mercury = 2
Venus = 3
Mars = 4
Jupiter = 5
Saturn = 6

Ed

Ed
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: oneirich on August 24, 2020, 04:14:34 PM
Apologies for the late reply...

If you can share the script that would be more then welcome... If I make any changes I'll submit the endresult.

Thank you for your time
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: ABer on September 23, 2020, 07:30:13 AM
Hi there - could you PM me with your email address and I will send you this file. Thanks. Ed
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: VivianV on December 06, 2020, 07:35:39 AM
Hello  :)

Hoping that someone could help me with what code to use. I modified planetaryhour.ab to show additional data that I need but I can't get the house to show up. I used :

1. calculate(0, jd, lon, lat, -1)
2. getplanets(0, planet)" and "sign=planet[6]/30 - to get the sign of a particular planet
3. total = getaspects(0, P1, P2, As) - to get aspect

I tried gethousepos but I can't get it to work. I need to get the house of a particular planet.

Thank you :)
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: ABer on December 06, 2020, 08:57:58 AM
Hi there - you might need to use:

getlonlat

Syntax: getlonlat(char Index, real *Lon, real *Lat)

Action: gets the longitude and latitude of the place from horoscope 'Index'.

Please note: PlanetDance follows the convention of the Swiss Ephemeris calculation routines. Western longitudes are negative, Eastern are positive.

You don't mention if you have filled lon and lat. I think this would be needed to calculate the houses. You could then use gethousepos().

It might be easier if you post the code lines you are using.

To create an array with the longitudes of house cusps use gethouses().

From the help:

gethouses

Syntax gethouses(char Index, real houses[12]);

Action: Gets the houses from internal horoscope 'Index' and puts them into the array 'houses'

Note, the constant 'HOUSES' equals 12.

Example

real houses[HOUSES];
gethouses(0, houses);

If this doesn't work, let me know. Ed
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: Jean on December 06, 2020, 09:52:24 AM
Hi Vivian

Here's a gethousepos() example, i added it to the help.

Code: [Select]
window(333, 333);
gettransit(0, -1);
char pos[PLANETS], s[99];
gethousepos(0, pos);
int i = 0; for (i < ASCENDANT)
  {
  strset(s, "%s is in house %d", planetname[i], pos[i] + 1);
  putstring(0, i * 20, s);
  }
run;
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: ABer on December 06, 2020, 09:58:17 AM
Thanks Jean - that'll be a good addition to the help.

Ed
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: VivianV on December 08, 2020, 02:23:58 AM
Thank you ABer and Jean  ;D for the guidance.

I copied the codes and I will try them over the weekend.

Thank you for creating Planetdance  :) :) :)
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: ABer on December 08, 2020, 07:11:19 AM
Hi - no problem - happy to help. If you have added functionality to the script, it would be really helpful to share the code. It might be something that can be added back into the script for others to benefit from.

Glad that you are enjoying Planetdance.

Ed
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: Jean on December 08, 2020, 07:58:23 AM
@Ed, Vivian already sent me some code.
@Vivian, I'll be happy to help too if you're stuck.
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: ABer 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
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: Jean 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;
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: VivianV 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



Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: VivianV 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

Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: Jean 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
Title: Re: Astrobasic script to generate excel with planetary days and hours?
Post by: ABer 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