• Print

Author Topic: Danish keyboard in qb64 [fixed*][new commands added to QB64]  (Read 3620 times)

LarsBechNygaard

  • Newbie
  • *
  • Posts: 20
Danish keyboard in qb64 [fixed*][new commands added to QB64]
« on: October 02, 2010, 04:05:13 am »
When running qb64 I seem unable to input the scandinavian characters "æøå/ÆØÅ"
How do I mend this error..?
I am running an (originally) english windows7, with a Danish languagepack.
« Last Edit: October 15, 2010, 06:36:17 am by Galleon »

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 5412
  • QB Forever
Re: Danish keyboard in qb64
« Reply #1 on: October 02, 2010, 04:20:36 am »
In 1 week an update to QB64 will be release which will fix this problem. It is a massive overhaul of the QB64 input system which affects the QB64 IDE and the programs you create.
Something old... Something new... Something borrowed... Something blue...

LarsBechNygaard

  • Newbie
  • *
  • Posts: 20
Re: Danish keyboard in qb64
« Reply #2 on: October 03, 2010, 01:19:29 am »
 :D Okay.. sounds great. Thanks a lot!

LarsBechNygaard

  • Newbie
  • *
  • Posts: 20
Re: Danish keyboard in qb64 [fixed*]
« Reply #3 on: October 11, 2010, 12:24:08 am »
Well, I've just tested the new edition, and most unfortunately I still cannot use "øØ", but æÆ and åÅ is working nicely now...

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 5412
  • QB Forever
Re: Danish keyboard in qb64 [fixed*]
« Reply #4 on: October 11, 2010, 03:08:20 am »
Thanks for the feedback.

I see the character you cannot enter is:
http://www.fileformat.info/info/unicode/char/search.htm?q=%C3%98&preview=entity
Unfortunately it is not present in CP437, the QB64 standard ASCII character set:
http://en.wikipedia.org/wiki/Code_page_437
Therefore, you will need to use QB64's UNICODE support.

QB64 does not accept non-CP437 characters directly in source code yet, but you can input them and output them in your programs. Try this:
Quote
SCREEN _NEWIMAGE(640, 400, 32)

uf = _LOADFONT("cyberbit.ttf", 24, "UNICODE")
f = _LOADFONT("cyberbit.ttf", 24)
_FONT f

PRINT "Here's the character you wanted:"
switchfont uf
FOR x = 1 TO 10
    PRINT MKL$(&HD8);
NEXT
switchfont f

LOCATE 4, 1: PRINT "Now press some keys..."
DO

    k& = _KEYHIT

    IF k& > 0 THEN
        IF k& < 255 THEN PRINT CHR$(k&);
        IF k& >= &H40000000 THEN
            switchfont uf
            PRINT MKL$(k& - &H40000000);
            switchfont f
        END IF
    END IF
LOOP

SUB switchfont (f) 'maintains cursor position during a font switch
x = POS(0)
y = CSRLIN
_FONT f
LOCATE y, x
END SUB
Something old... Something new... Something borrowed... Something blue...

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 5412
  • QB Forever
Re: Danish keyboard in qb64 [fixed*]
« Reply #5 on: October 15, 2010, 04:03:02 am »
Good news LarsBechNygaard,

I've decided to include some simple ASCII<->UNICODE mapping commands into QB64 which will effectively allow you to setup a Danish codepage. This would involve 4 or 5 lines of code at the beginning of your programs and the use of a .TTF font, most of which contain those unique characters. After that everything would work as you'd expect it to with minimum fuss.

QB64's role is to be a bridge between modern technology and QBASIC, and simple mapping commands will aptly support that role.

Two commands will be added:
1) A function to return the UNICODE character an ASCII character is currently mapped to.
2) A sub to set a UNICODE character an ASCII character will represent.
Something old... Something new... Something borrowed... Something blue...

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 5412
  • QB Forever
Re: Danish keyboard in qb64 [fixed*]
« Reply #6 on: October 15, 2010, 05:58:13 am »
I'm going to assume Windows 7 is using 'codepage 850' with the Danish language pack:
http://en.wikipedia.org/wiki/Code_page_850

I'll write you an example of how to setup 'codepage 850' in a QB64 program, but the example won't work until after the next update.
Something old... Something new... Something borrowed... Something blue...

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 5412
  • QB Forever
Re: Danish keyboard in qb64 [fixed*]
« Reply #7 on: October 15, 2010, 06:32:38 am »
This is what you want, but it won't work until after the next update. I've finished coding and testing these functions and they worked beautifully:
Code: [Select]
SCREEN 0

'use any font containing characters from codepage 850
_FONT _LOADFONT("c:\windows\fonts\cour.ttf", 24, "MONOSPACE")

'use codepage 850
RESTORE CP850_DATA
FOR ascii_code& = 0 TO 255
    READ unicode_code&
    _MAPUNICODE unicode_code& TO ascii_code&
NEXT
CP850_DATA: DATA 0,9786,9787,9829,9830,9827,9824,8226,9688,9675,9689,9794,9792,9834,9835,9788,9658,9668,8597,8252,182,167,9644,8616,8593,8595,8594,8592,8735,8596,9650,9660,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,8962,199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197,201,230,198,244,246,242,251,249,255,214,220,248,163,216,215,402,225,237,243,250,241,209,170,186,191,174,172,189,188,161,171,187,9617,9618,9619,9474,9508,193,194,192,169,9571,9553,9559,9565,162,165,9488,9492,9524,9516,9500,9472,9532,227,195,9562,9556,9577,9574,9568,9552,9580,164,240,208,202,203,200,305,205,206,207,9496,9484,9608,9604,166,204,9600,211,223,212,210,245,213,181,254,222,218,219,217,253,221,175,180,173,177,8215,190,182,167,247,184,176,168,183,185,179,178,9632,160

'demo: show the upper character map
FOR x = 128 TO 255
    PRINT CHR$(x);
NEXT

'demo: input some characters
PRINT: PRINT
INPUT "Type some characters now >", ignore$

Screenshot of above program running:
http://www.qb64.net/cp850qb.jpg

PS. As for the QB64 IDE, it won't be too hard for me to add support for code-pages there either, but that's a job for another day.
« Last Edit: October 15, 2010, 06:41:49 am by Galleon »
Something old... Something new... Something borrowed... Something blue...

Clippy

  • Hero Member
  • *****
  • Posts: 18161
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: Danish keyboard in qb64 [fixed*][new commands added to QB64]
« Reply #8 on: October 15, 2010, 07:39:34 am »
Meanwhile at the N54 Forum.

A fellow using QBX cannot type Hebrew in the IDE. When is the IDE gonna be ready for that?  ;D

It misses FOR J = TO, but it can type up a GREAT Koran with no problemo...

And I thought the DLL libraries was gonna be a headache. Languages and typing is not much better. Wonder when the Chinese will be here asking.

Yadda Yadda Yadda
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

Cyperium

  • Hero Member
  • *****
  • Posts: 3621
  • Knowledge is good, but understanding is better
    • Cyperium
Re: Danish keyboard in qb64 [fixed*][new commands added to QB64]
« Reply #9 on: October 15, 2010, 07:51:45 am »
lol!

Does QB even work in Chinese? /%/&% TO 3 #¤((/#¤& 1 NEXT!
Venture - New Prototype, QB64 Editor v1.96e (linux compatible, if you compile the source).

LarsBechNygaard

  • Newbie
  • *
  • Posts: 20
Re: Danish keyboard in qb64 [fixed*][new commands added to QB64]
« Reply #10 on: October 17, 2010, 12:55:16 am »
 :D sounds good that you kind people really are putting all this hard work into it - I'll wait for the next update, and then I'll see if I can somehow insert the lines of code to my programs - I expect that the code is to preceed any program coding in my *.bas files..?

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 5412
  • QB Forever
Re: Danish keyboard in qb64 [fixed*][new commands added to QB64]
« Reply #11 on: October 17, 2010, 02:39:30 am »
Quote
I expect that the code is to precede any program coding in my *.bas files
Yep, it's as simple as that.

Also, you're gonna love this, I added a language section to the options menu of the QB64 IDE and you can select from 20 or so code pages. You'll find CP450 there too, and it'll make like much easier.
Something old... Something new... Something borrowed... Something blue...

Pete

  • Hero Member
  • *****
  • Posts: 6626
  • Cuz I sez so varmint!
Re: Danish keyboard in qb64 [fixed*][new commands added to QB64]
« Reply #12 on: October 17, 2010, 08:19:45 am »

I can't find C3PO.

 - R2D2



It's only rocket science; it's not Linux!

LarsBechNygaard

  • Newbie
  • *
  • Posts: 20
Re: Danish keyboard in qb64 [fixed*][new commands added to QB64]
« Reply #13 on: October 21, 2010, 04:07:01 am »
 ;D You're right, I'll love that, How and where do I download this functionality..?  ???

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 5412
  • QB Forever
Re: Danish keyboard in qb64 [fixed*][new commands added to QB64]
« Reply #14 on: October 21, 2010, 04:24:14 am »
Step 1: Check you version of QB64 is up to date. In the FILE menu select UPDATE
Step 2: In the OPTIONS menu select DISPLAY, then check the CUSTOM FONT check-box
Step 3: In the OPTIONS menu select LANGUAGE, then select CP850 and click OK
Now you can type using your language in the IDE.

For the programs you write to have this functionality, you must include some code like I showed you before at the beginning:
Code: [Select]
'use any font containing characters from codepage 850
_FONT _LOADFONT("c:\windows\fonts\cour.ttf", 24, "MONOSPACE")
'use codepage 850
RESTORE CP850_DATA
FOR ascii_code& = 0 TO 255
    READ unicode_code&
    _MAPUNICODE unicode_code& TO ascii_code&
NEXT
CP850_DATA: DATA 0,9786,9787,9829,9830,9827,9824,8226,9688,9675,9689,9794,9792,9834,9835,9788,9658,9668,8597,8252,182,167,9644,8616,8593,8595,8594,8592,8735,8596,9650,9660,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,8962,199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197,201,230,198,244,246,242,251,249,255,214,220,248,163,216,215,402,225,237,243,250,241,209,170,186,191,174,172,189,188,161,171,187,9617,9618,9619,9474,9508,193,194,192,169,9571,9553,9559,9565,162,165,9488,9492,9524,9516,9500,9472,9532,227,195,9562,9556,9577,9574,9568,9552,9580,164,240,208,202,203,200,305,205,206,207,9496,9484,9608,9604,166,204,9600,211,223,212,210,245,213,181,254,222,218,219,217,253,221,175,180,173,177,8215,190,182,167,247,184,176,168,183,185,179,178,9632,160
Something old... Something new... Something borrowed... Something blue...

  • Print