Convert to outputsturing

Antworten
PowerSoft
Beiträge: 22
Registriert: Samstag 8. Oktober 2011, 12:43
Wohnort: Hellevoetsluis-NL

Convert to outputsturing

Beitrag von PowerSoft » Dienstag 10. Juli 2018, 09:53

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));
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........

IKT
Beiträge: 515
Registriert: Mittwoch 4. November 2009, 18:32

Re: Convert to outputsturing

Beitrag von IKT » Dienstag 10. Juli 2018, 10:54

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!)
++++++
Gruss/regards IKT

PowerSoft
Beiträge: 22
Registriert: Samstag 8. Oktober 2011, 12:43
Wohnort: Hellevoetsluis-NL

Re: Convert to outputsturing

Beitrag von PowerSoft » Dienstag 10. Juli 2018, 14:04

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) 162 mal betrachtet
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........

IKT
Beiträge: 515
Registriert: Mittwoch 4. November 2009, 18:32

Re: Convert to outputsturing

Beitrag von IKT » Dienstag 10. Juli 2018, 14:25

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.
++++++
Gruss/regards IKT

Müllmann
Beiträge: 17
Registriert: Sonntag 2. Februar 2014, 10:53

Re: Convert to outputsturing

Beitrag von Müllmann » Dienstag 10. Juli 2018, 18:37

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"
Ich bin der Müllmann und räume nur auf.

PowerSoft
Beiträge: 22
Registriert: Samstag 8. Oktober 2011, 12:43
Wohnort: Hellevoetsluis-NL

Re: Convert to outputsturing

Beitrag von PowerSoft » Donnerstag 12. Juli 2018, 11:30

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]
MacBook Pro Mac OSX El-Captain, Parallels 11, Windows-7 Professional ........

Mike D
Beiträge: 492
Registriert: Dienstag 14. Oktober 2008, 14:48
Wohnort: Elbe- Weser-Dreieck

Re: Convert to outputsturing

Beitrag von Mike D » Donnerstag 12. Juli 2018, 12:24

and what does invjday?

IKT
Beiträge: 515
Registriert: Mittwoch 4. November 2009, 18:32

Re: Convert to outputsturing

Beitrag von IKT » Donnerstag 12. Juli 2018, 12:58

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
++++++
Gruss/regards IKT

Antworten

Zurück zu „Thema: Compiler“