Author Topic: Can't get my console class to work  (Read 17580 times)

0 Members and 3 Guests are viewing this topic.

kryton9

  • Guest
Re: Can't get my console class to work
« Reply #30 on: July 08, 2011, 08:44:47 PM »
Thanks Charles for the help. Again one of those bugs I would never have guessed how to fix.

Charles Pegge

  • Guest
Re: Can't get my console class to work
« Reply #31 on: July 08, 2011, 11:24:59 PM »

The bug was mine :). It was quite difficult to trace but easy to fix. The OOP zone requires more rigorous testing as there are so many different possible combinations of structures.

Charles

kryton9

  • Guest
Re: Can't get my console class to work
« Reply #32 on: July 09, 2011, 10:11:11 AM »
There are still problems Charles. I did download the latest in progress version today.

Code: OxygenBasic
  1. sub px( char aChar, sys aNum )
  2.     for x = 1 to aNum
  3.         print aChar
  4.     next
  5. end sub
  6.  
  7. char c = "g"
  8.  
  9. px c, 5


Charles Pegge

  • Guest
Re: Can't get my console class to work
« Reply #33 on: July 09, 2011, 10:54:04 AM »
Hi Kent,

Yes I see the problem. It's picking up the wrong overload function for print when it sees a single zstring . You can get round this by adding another term like ""

Code: OxygenBasic
  1.  
  2. sub px( char* aChar, sys aNum )
  3.     for x = 1 to aNum  
  4.         print achar  ""
  5.     next  
  6. end sub  
  7.  
  8. char c[] = "grail"  
  9.  
  10. px c, 3
  11.  
« Last Edit: July 09, 2011, 11:27:00 AM by Charles Pegge »

kryton9

  • Guest
Re: Can't get my console class to work
« Reply #34 on: July 09, 2011, 02:40:05 PM »
It's just not in printing Charles with overloading. I just wrote this small example to show there is something wrong. It also won't work with a winapi call sending it just a single char as the call wants.
http://msdn.microsoft.com/en-us/library/ms682663(v=vs.85).aspx


Here is a funny return.
Code: OxygenBasic
  1. function px( char aChar, sys aNum ) as string
  2.     string s = ""
  3.     for x = 1 to aNum
  4.         s += aChar
  5.     next
  6.     return s
  7. end function
  8.  
  9. char c = "g"
  10.  
  11. print ">" px( c, 5 ) "<"

I just ran it a couple of times, I guess the answer changes. But the first time I got > 01 01 01 01 01<
« Last Edit: July 09, 2011, 02:55:43 PM by kryton9 »

Charles Pegge

  • Guest
Re: Can't get my console class to work
« Reply #35 on: July 09, 2011, 03:10:08 PM »
Kent I fixed a few more problems likely to show up with chars.

See if it makes any difference. I have checked it against Console and all the other major pieces.

If not then I don't mind tracing the problem in your code.

Charles
« Last Edit: July 10, 2011, 03:48:44 PM by Charles Pegge »

Peter

  • Guest
Re: Can't get my console class to work
« Reply #36 on: July 09, 2011, 03:13:29 PM »
Here are you.

function px( char* aChar, sys aNum ) as string 
    string s = "" 
    for x = 1 to aNum 
        s +=  aChar ""
    next 
    return s 
end function 
 
char c = "g" 
 
print ">" + px( c, 5 ) + "<" 

'Result = >ggggg<

Charles Pegge

  • Guest
Re: Can't get my console class to work
« Reply #37 on: July 09, 2011, 03:23:39 PM »

Yes well spotted Peter. I was about to say make sure it is char *achar in the prototype.

Charles

kryton9

  • Guest
Re: Can't get my console class to work
« Reply #38 on: July 09, 2011, 06:48:54 PM »
Thanks Peter and Charles. I did try the * and it was working then, but for a single character why would you need to use *?
It is confusing.


kryton9

  • Guest
Re: Can't get my console class to work
« Reply #39 on: July 09, 2011, 07:02:37 PM »
The new dll made no difference Charles. I am attaching my code. The method is named Fill and it wraps
sys FillConsoleOutputCharacterA( sys hConsoleOutput, char cCharacter, sys nLength, COORD dwWriteCoord, sys *lpNumberOfCharsWritten )

Hope it helps. Thanks in advance.

outdated attachments removed to avoid any confusion.
« Last Edit: July 10, 2011, 08:08:12 PM by kryton9 »

Charles Pegge

  • Guest
Re: Can't get my console class to work
« Reply #40 on: July 10, 2011, 12:09:30 AM »
Hi Kent

The problem is passing a char directly. Normally one would pass an ascii/unicode code in Basic. But you would have to change char to sys in the declaration.

FillConsoleOutputCharacterA( sys hConsoleOutput, sys cCharacter, sys nLength, COORD dwWriteCoord, sys *lpNumberOfCharsWritten )

I will see if I can fix it so that Oxygen will correctly interpret direct chars as a parameter.


Charles

kryton9

  • Guest
Re: Can't get my console class to work
« Reply #41 on: July 10, 2011, 12:41:05 AM »
Thanks Charles, I will try sys instead of char in the meantime.

Charles Pegge

  • Guest
Re: Can't get my console class to work
« Reply #42 on: July 10, 2011, 05:17:54 AM »
Kent,

'ggg' now appears on your console test screen, now that I have persuaded Oxygen to handle direct char params correctly.

No need to change the prototype :)

Charles
« Last Edit: July 10, 2011, 03:49:55 PM by Charles Pegge »

kryton9

  • Guest
Re: Can't get my console class to work
« Reply #43 on: July 10, 2011, 09:31:51 AM »
That is sweet to see. Thanks Charles!
It is amazing how all of the new console commands are all based on the previous one working. These were some key hold ups this week, but you got them. Thanks again.

kryton9

  • Guest
Re: Can't get my console class to work
« Reply #44 on: July 10, 2011, 08:10:10 PM »
Sorry to report, some old things that worked are no longer working. See the first post for the latest of my files.
Minor problems in the first 2 test files as noted in the post and in comments in code.

http://www.oxygenbasic.org/forum/index.php?topic=255.msg1544#msg1544
« Last Edit: July 10, 2011, 08:12:26 PM by kryton9 »