Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
bug when using _Dest _Console
#11
Just thought I'd add this.... You don't need _DEST _CONSOLE or _SOURCE _CONSOLE in $CONSOLE:ONLY since those are both automatically set when using $CONSOLE:ONLY. I made this change to the code maybe a year ago.
Tread on those who tread on you

Reply
#12
Thanks Indy, I just recently started using $CONSOLE:ONLY so I could track math iterations (scroll the screen results) easier. A belated +1 for updating the project last year.

Pete
If eggs are brain food, Biden has his scrambled.

Reply
#13
(09-14-2022, 04:06 PM)Spriggsy Wrote: Just thought I'd add this.... You don't need _DEST _CONSOLE or _SOURCE _CONSOLE in $CONSOLE:ONLY since those are both automatically set when using $CONSOLE:ONLY. I made this change to the code maybe a year ago.
Still, the example @Jack is displaying is a bug which is embarrassing. This printing error could rear its ugly face somewhere else. Some people are dedicated to breaking stuff and to doing bizarre things only to report a bug. Such as the Linux distro-hoppers because they would never give up MacOS or Windows.

This is interesting, from the long and complicated "qbs_input()" within "libqb.cpp":
Code: (Select All)
if (write_page->console) {
            qbs_set(key, qbs_new_txt(""));
            chr = fgetc(stdin);
            if (chr != EOF) {
                if (chr == '\n')
                    chr = 13;
                qbs_set(key, qbs_new_txt(" "));
                key->chr[0] = chr;
            } else {
                Sleep(10);
            }
        } else {
            Sleep(10);
            qbs_set(key, qbs_inkey());
        }
Look at that "qbs_set()" statement not near this line. Is that what is adding that funny space?
Reply
#14
(09-14-2022, 04:40 PM)mnrvovrfc Wrote:
(09-14-2022, 04:06 PM)Spriggsy Wrote: Just thought I'd add this.... You don't need _DEST _CONSOLE or _SOURCE _CONSOLE in $CONSOLE:ONLY since those are both automatically set when using $CONSOLE:ONLY. I made this change to the code maybe a year ago.
Still, the example @Jack is displaying is a bug which is embarrassing. This printing error could rear its ugly face somewhere else. Some people are dedicated to breaking stuff and to doing bizarre things only to report a bug. Such as the Linux distro-hoppers because they would never give up MacOS or Windows.

@mnrvovrfc Right, I'm just letting him know that whether he includes that line or not, it will still be set.
Tread on those who tread on you

Reply
#15
However, the bug might not be related to QB64 itself. I wonder if one of you could try doing the equivalent in regular C/C++ and see what the console output gives you.
Tread on those who tread on you

Reply
#16
(09-14-2022, 04:30 AM)Jack Wrote: the graphic console is ok for display-only but if you want to copy the displayed "text" by click&drag with the mouse you are **** out of luck, look at the thousands of screenshots on the former forum simply because you couldn't copy the displayed text, now you are going to tell me that you can use some _clipboard command to place something on the clipboard, that's simply lame compared to simply using the mouse with click&drag
but not just the ability to copy text but also to paste

This si why I write my own custom input routines. My routines allow the user to cut/copy/paste input and output. I guess that makes me the Anti-Gates, and that's a good thing. Same with scrolling screen, custom made to allow the mouse to drag the thumb. Of course I made all of those bells and whistles for WP purposes, but I suppose with some work, it could be applied to math output as well.

Honestly, for me, the only advantage I see with CONSOLE display is the screen scrolling. That is a nice perk.

Interesting bug discovery, though. Thanks for finding it.

Pete
Reply
#17
P.S., if you want to copy from a console, I think you can highlight and use the right-click. Also, if you definitely want to use CTRL+C then you have to add some sort of custom pause when running headless that way you don't kill the program. Or, you can run your console program from command prompt, PowerShell, or Windows Terminal and then the terminal will stay open when you use CTRL+C.
Tread on those who tread on you

Reply
#18
(09-14-2022, 04:47 PM)Spriggsy Wrote: However, the bug might not be related to QB64 itself. I wonder if one of you could try doing the equivalent in regular C/C++ and see what the console output gives you.

Do you mean something like this? - From 10 numbers it's over!
Code: (Select All)
//Aus QB64 - 14. Sept. 2022

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    long int n;
    
    printf("\nGrosse Zahl: ");
    scanf("%ld", &n);
    
    printf("\n%ld\n", n);
    return(0);
}

[Image: QB64-Grosse-Zahl2022-09-14.jpg]
Reply
#19
Using "scanf()" could be a pain. However cannot use "gets()" in its place because it doesn't check for the target buffer size, and using string-to-number conversions like "atol()" are clunky. Could use "fgets()" instead for string input from "stdin". Another thing is that "scanf()" or alike function doesn't prevent the user from typing a non-numeral, or a plus or minus sign or multiple decimal points out of place. That's why all the checking in "qbs_input()" within "libqb.cpp" is needed. The CRT, for "scanf()" is hardwired to stop at a certain number of characters depending on the format which is "%ld" or alike. I don't know that much about C/C++ programming but I did enough to tell you that I had to avoid using "scanf()" although I was compelled to use "fscanf()" for input files and "sscanf()" for a few other things.

I looked at the screenshot. "scanf()" only picks up as many characters as it thinks should fit into the type asked for by the "format" first parameter it's given, that's why it displayed strange values in the first and second attempts. If it's going to convert improperly like that, it's not going to matter if it could accept 10 digits or 100 digits.
Reply
#20
Oh yeah, you can copy paste from console, just not from right mouse menu:

Here is code I used to test and 2 pastes back into editor:
Code: (Select All)
$Console:Only
_Dest _Console

Dim As Long n

Do
    Input "n "; n
    Print n
    Sleep
Loop

' copy paste from console!!
n ? 99999999999999999999
999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 999999999
n ? 77777777777777777777777
777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 777777777
n ? 66666
66666
' copy paste from console!!
n ? 99999999999999999999
999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999 999999999
n ? 77777777777777777777777
777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777 777777777

Thanks to Spriggsy for hint.

So along with scrolling, Console is good for copy paste, just not with right mouse menu.


[Image: copy-paste-from-console.png]
b = b + ...
Reply




Users browsing this thread: 3 Guest(s)