Seite 1 von 1

Convert to outputsturing

Verfasst: Dienstag 10. Juli 2018, 09:53
von PowerSoft
Hello,

I need some help with the next type conversion.
I need output the date and time in a string, so I can write it to POutput[].
Use the code as below. But how can I convert it to the right output format for PL.
Try a lot of things but always a type conversion error.

Thanks for any help ;)

Code: Alles auswählen

char buffer[25];
sprintf(buffer, "%02d-%02d-%02d  %02d:%02d:%02d", dag, maand, jaar, uur, minuut, int(seconde));

Re: Convert to outputsturing

Verfasst: Dienstag 10. Juli 2018, 10:54
von IKT
Why program a DLL, for such a simple problem?
Use PL-E for that type of thing. That is, what it was made for! (there is even an example, for Date/Time etc.)

Sorry, I don't speak C (only: PL-E / BASIC / Assembly).

If you don't want to learn, how things are done in PL-E, then it would be better for you, to join a C language Forum.
(In PL-E a DLL is considered to be a: "last resort" only, everyting else: is done, in PL-E itself!)

Re: Convert to outputsturing

Verfasst: Dienstag 10. Juli 2018, 14:04
von PowerSoft
Thanks for your comment. For my regular projects I use only PL, but in this case I'm working on a satellite tracer.
Special for fellowing the International Station ISS.
To calculate all relevant information I needed to write a dll. This one is working fine.

One thing gives me an enormous problem that is converting the time string into the right format needed for PL.
Thus still open the question to help me to convert this one.

Kindly regards,

Jan

Schermafbeelding 2018-07-10 om 14.57.38.png
Schermafbeelding 2018-07-10 om 14.57.38.png (220.9 KiB) 5680 mal betrachtet

Re: Convert to outputsturing

Verfasst: Dienstag 10. Juli 2018, 14:25
von IKT
In DLL's for PL, String outputs must be "labeled" with a $ sign, prepending the Pin-Name:
Not: "T", but: "$T" ... this is equally true, for String inputs.

You might want to use a "static String" to keep the string, until the next CLK.
(you have to, however, copy it on every occasion, the dll code is executed,
independent of CLK state)

Then the created String in DLL must be copied to "PStrings", not "POutput".
Use only CCalculateEx(), whenever you're dealing with Strings.

Re: Convert to outputsturing

Verfasst: Dienstag 10. Juli 2018, 18:37
von Müllmann
You also can expand the POutput "T" to 6 different POutputs for dag, maand …
Then format all values with internal string functions of PLE and add to one string.
It is not difficult to create something as "12:34 01.02.2018"

Re: Convert to outputsturing

Verfasst: Donnerstag 12. Juli 2018, 11:30
von PowerSoft
Thanks for all help,
found this simple solution.

Code: Alles auswählen

/*string handling */	
char buffer1[25];
char buffer2[25];
int jaar,maand,dag,uur,minuut;
double seconde;
invjday(satrec.jdsatepoch, jaar,maand,dag,uur,minuut,seconde);
sprintf(buffer1, "%02d-%02d-%02d  %02d:%02d:%02d", dag, maand, jaar, uur, minuut, int(seconde));
invjday(next_visual_pass+(2.0/24), jaar,maand,dag,uur,minuut,seconde);
sprintf(buffer2, "%02d-%02d-%02d  %02d:%02d:%02d", dag, maand, jaar, uur, minuut, int(seconde));
/*output dates into string*/
strcpy(PChar(PStrings[17]),buffer1);
strcpy(PChar(PStrings[18]),buffer2);/code]

Re: Convert to outputsturing

Verfasst: Donnerstag 12. Juli 2018, 12:24
von Mike D
and what does invjday?

Re: Convert to outputsturing

Verfasst: Donnerstag 12. Juli 2018, 12:58
von IKT
Mike D hat geschrieben:
Donnerstag 12. Juli 2018, 12:24
and what does invjday?
Looking at the code:
it seems to exchange the Day/Year, within the data ... which appears to be ISO.

ISO-Date: Year-Month-Day