Print Using? - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://staging.qb64phoenix.com/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://staging.qb64phoenix.com/forumdisplay.php?fid=10) +---- Thread: Print Using? (/showthread.php?tid=1031) |
RE: Print Using? - SpriggsySpriggs - 11-03-2022 (11-03-2022, 03:26 PM)Kernelpanic Wrote:@KernelpanicQuote:mnrvovrfc - This is the BASIC program, name it whatever you want, but place in the same directory as "hourminsec.h". Recommended both files on the same directory as QB64PE executable. Try using ".\hourminsec" instead RE: Print Using? - bplus - 11-03-2022 I can't believe anyone is seriously considering this as an option. Just my opinion but WTH? RE: Print Using? - Kernelpanic - 11-03-2022 Quote:Try using ".\hourminsec" insteadThanks for the tip, works. RE: Print Using? - SpriggsySpriggs - 11-03-2022 I'm confused why the external sub is using an out string rather than just returning the string. Breaks up the flow of the program with the out string style. RE: Print Using? - mnrvovrfc - 11-03-2022 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> Then this BASIC file which must be in the same directory as the header file and QB64PE executable: Code: (Select All) declare library "strf" 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. RE: Print Using? - bplus - 11-03-2022 Ah practicing API skills, OK! RE: Print Using? - mnrvovrfc - 11-03-2022 (11-03-2022, 05:22 PM)bplus Wrote: Ah practicing API skills, OK!In addition, I want to make it work on Linux as well as Windows. And someone else should be as interested for Macintosh. The thing is that with Q(uick)BASIC we used to be limited to BASIC-only solutions. If someone wasn't confident enough doing mixed-language programming then he/she was content with having a mess of "LEN()" and string functions instead of "PRINT USING" only to always get two-digit date and time variables. The creators of GW-BASIC and Q(uick)BASIC didn't perceive that somebody wanted to format an arbitrary date and/or time; they felt "DATE$" and "TIME$" were good enough. That's because back then, at least on Windows those two "function values" could be changed by the user. In QB64 we were given the choice to look for a solution in C/C++, for somebody who knew enough about it. This is something the Wiki encouraged me to do. I modified the "fileexist" example, that used to be in the Wiki, to come up with my own function which produced full paths for a given directory on the disk, and made it work on Windows and Linux. Before QB64PE there was no example in the Wiki which wrote a function which resided in a "dot-H" file, and declared also as function inside "DECLARE" block. Declaring the ones "directly" from C runtime library didn't count for me, I wanted to see a written example like that "fileexist" one. That's why I said I was comfortable writing it as subprogram with the final parameter being changeable. RE: Print Using? - bplus - 11-03-2022 Well I practiced making a generalized Function Pad$ because of this thread but not very useful towards specific problem of OP but WTH? Code: (Select All) _Title "Test Pad$" ' b+ 2022-11-02 RE: Print Using? - SMcNeill - 11-03-2022 You guys really do like to complicate things. Stick to the simple BASICs: Code: (Select All) Do RE: Print Using? - SpriggsySpriggs - 11-03-2022 (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. Try "Declare CustomType Library" instead of "Declare Library" |