Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print Using?
#40
(11-03-2022, 05:17 PM)mnrvovrfc Wrote: It's the way I was taught originally by QB64 Wiki. Go ahead and try to write it as a function; the way I write it works for me.

Another way. First this C header file called "strf.h":

Code: (Select All)
#include <string.h>
#include <time.h>

void getstrftime(short h, short m, short s, char * sout)
{
    struct tm tthis;
    size_t fret, soutlen;
    tthis.tm_sec = s;
    tthis.tm_min = m;
    tthis.tm_hour = h;
    soutlen = strlen(sout);
    fret = strftime(sout, soutlen, "%H:%M:%S", &tthis);
}

Then this BASIC file which must be in the same directory as the header file and QB64PE executable:

Code: (Select All)
declare library "strf"
    sub getstrftime(byval h as integer, byval m as integer, byval s as integer, soutput as string)
end declare

dim sout$
dim as integer hh, mm, ss

hh = 4
mm = 1
ss = 5
sout$ = space$(20)
getstrftime hh, mm, ss, sout$
print sout$
end

Use if it you want, but this was for showing off. My first attempt was to declare "strftime()" directly in "DECLARE" block but kept getting a C++ compilation error about the type of the last parameter. It looks like the C++ compiler expected a "double pointer" which is constant or something like that.

This duo could be customized even further, such as adding another string argument for the "format", to be able to get "2022-Nov-03" as well as the time, or something else with the date and time.

Try "Declare CustomType Library" instead of "Declare Library"
The noticing will continue
Reply


Messages In This Thread
Print Using? - by james2464 - 11-01-2022, 11:39 PM
RE: Print Using? - by bplus - 11-01-2022, 11:45 PM
RE: Print Using? - by mnrvovrfc - 11-01-2022, 11:49 PM
RE: Print Using? - by Pete - 11-01-2022, 11:51 PM
RE: Print Using? - by james2464 - 11-02-2022, 12:03 AM
RE: Print Using? - by Kernelpanic - 11-02-2022, 12:23 AM
RE: Print Using? - by PhilOfPerth - 11-02-2022, 12:26 AM
RE: Print Using? - by justsomeguy - 11-02-2022, 12:36 AM
RE: Print Using? - by james2464 - 11-02-2022, 12:54 AM
RE: Print Using? - by Kernelpanic - 11-02-2022, 01:03 AM
RE: Print Using? - by PhilOfPerth - 11-02-2022, 01:33 AM
RE: Print Using? - by justsomeguy - 11-02-2022, 01:55 AM
RE: Print Using? - by SMcNeill - 11-02-2022, 02:51 PM
RE: Print Using? - by james2464 - 11-02-2022, 03:37 PM
RE: Print Using? - by mdijkens - 11-02-2022, 06:04 PM
RE: Print Using? - by bplus - 11-02-2022, 06:16 PM
RE: Print Using? - by james2464 - 11-02-2022, 06:22 PM
RE: Print Using? - by bplus - 11-02-2022, 06:25 PM
RE: Print Using? - by james2464 - 11-02-2022, 06:33 PM
RE: Print Using? - by Pete - 11-02-2022, 06:33 PM
RE: Print Using? - by james2464 - 11-02-2022, 06:43 PM
RE: Print Using? - by mnrvovrfc - 11-02-2022, 06:48 PM
RE: Print Using? - by Pete - 11-02-2022, 06:54 PM
RE: Print Using? - by TerryRitchie - 11-02-2022, 09:22 PM
RE: Print Using? - by james2464 - 11-02-2022, 06:51 PM
RE: Print Using? - by Kernelpanic - 11-02-2022, 10:36 PM
RE: Print Using? - by SMcNeill - 11-03-2022, 12:11 AM
RE: Print Using? - by Kernelpanic - 11-03-2022, 12:47 AM
RE: Print Using? - by mnrvovrfc - 11-03-2022, 12:07 PM
RE: Print Using? - by Kernelpanic - 11-03-2022, 03:26 PM
RE: Print Using? - by SpriggsySpriggs - 11-03-2022, 03:44 PM
RE: Print Using? - by bplus - 11-03-2022, 03:53 PM
RE: Print Using? - by Kernelpanic - 11-03-2022, 03:59 PM
RE: Print Using? - by SpriggsySpriggs - 11-03-2022, 04:36 PM
RE: Print Using? - by mnrvovrfc - 11-03-2022, 05:17 PM
RE: Print Using? - by SpriggsySpriggs - 11-03-2022, 05:59 PM
RE: Print Using? - by mnrvovrfc - 11-03-2022, 09:16 PM
RE: Print Using? - by bplus - 11-03-2022, 05:22 PM
RE: Print Using? - by mnrvovrfc - 11-03-2022, 05:32 PM
RE: Print Using? - by bplus - 11-03-2022, 05:57 PM
RE: Print Using? - by SMcNeill - 11-03-2022, 05:58 PM
RE: Print Using? - by Kernelpanic - 11-04-2022, 12:57 AM
RE: Print Using? - by mnrvovrfc - 11-04-2022, 03:47 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Mac print #file crlf? BlameTroi 5 342 02-16-2026, 08:42 PM
Last Post: BlameTroi
  Print strings with accents and special chars Ikerkaz 8 711 12-20-2025, 09:28 PM
Last Post: TempodiBasic
  blue circle isn't drawing and print isn't working? madscijr 12 2,351 09-21-2024, 06:13 PM
Last Post: madscijr
  Assign print using to a string. eoredson 10 1,970 04-02-2024, 02:56 AM
Last Post: SMcNeill
  If Print Dimster 13 2,636 03-06-2023, 05:07 PM
Last Post: James D Jarvis

Forum Jump:


Users browsing this thread: 1 Guest(s)