Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Text with accents in file
#1
Hi Gintaras, Hi all

I try to extract text from a notepad file, and this text contains french accents (é à ô è...)

I did convert text from file using:


_s.ConvertEncoding(_unicode 28591)

but accents appear as ? (question mark)

QM is running as unicode in options, and the program will be an exe looking for a specific test file.

Also, i'd like to do a russian french study program, i.e one word input in french would make guess russian word for it, and russian word would wait for french word input.

As cyrillic is needed, i'd like to know how to do to have a word pair in CSV file.



Any help would be appreciated.
#2
If text in file has code page id 28591 and you load it into _s:

_s.ConvertEncoding(28591 _unicode)

If text in file is UTF-8, don't need to convert.

Save CSV file as UTF-8.
In Unicode mode _s.setfile saves text as UTF-8.
#3
well i have copied 28591 from old code but dont remember why i used it.

as french, something like latin1 or latin9 seems the good charset, but in notepad, offered only to save "as is" or unicode, so i don't know the exact charset of plain text file in notepad :/

but _s.ConvertEncoding(28591 _unicode) did it.

IS it the same for russian words? What charset to set then?
#4
utf-8
#5
OK, will try later.
I face another problem.

I want to extract datas from the file with is comma separated fields by a ICsv variable. 
But it seems that this variable created in WM_INITDIALOG routine is not accessible from message2 or sub functions when I want to call
its datas when a button of the dialog is clicked.

Am I supposed to create the ICSv variable and open the file each time i need datas from the files, and not have a once for all Icsv variable?

excerpt:

#sub DlgProc
function# hDlg message wParam lParam

sel message
    case WM_INITDIALOG
    str+ chemin fichier
    int+ reponse=0
    sub.ChargeFichier //works
    ICsv g._create
    g.FromString(fichier)
    int nr=g.RowCount
    case WM_DESTROY
    case WM_COMMAND goto messages2

that part does not work...

 messages2
sel wParam
    case 4
    mes reponse
    case 13
    DT_Ok hDlg 
    case 14
    _s=g.Cell(2 0)
    _s.setwintext(id(3 hDlg))
    _s=g.Cell(2 1)
    _s.setwintext(id(8 hDlg))
    _s=g.Cell(2 2)
    _s.setwintext(id(9 hDlg))
    _s=g.Cell(2 3)
    _s.setwintext(id(10 hDlg))


any hint??
#6
DlgProc is called many times. Its local variables are new each time. Use thread variables or main function's variables.

Macro Macro284
Code:
Copy      Help
str g="a"

str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog" "4"
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040800 "*" "" "" ""

if(!ShowDialog(dd &sub.DlgProc 0)) ret


#sub DlgProc v
function# hDlg message wParam lParam

sel message
,case WM_INITDIALOG
,out g
,g="b"
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,out g
,case IDCANCEL
ret 1
#7
Thanks, got it working.

Did not catch exactly how the dialog was handled by the function, done now.

Last one, was is the QM type of C static variable/functions (keep value through calls)?
#8
The closest is a thread variable declared with --. Such variables are visible only in that function.

int-- x
#9
Yes, though it was only for the scope, not static property.

Last one for now.

ARRAY(int) a
for _i 0 10
    a[]=_i
    out a[_i]

ARRAY(int)* b=&a
Shuffle_Int(b)


Function Shuffle_Int

function ARRAY(int)'*Liste

_i=Liste.len

Error in <open ":3263: /43">Shuffle_Int:  missing parts.

Why???? (passing by reference is the same)


Shuffle_Int(&a)
function ARRAY(int)'&Liste




I want to alter directly the int ARRAY...

Finally found that if i say the function returns int

function# ARRAY(int)'&Liste works....
But using a pointer to directly modify the array should be without any return type, no?
I'm a bit lost there....
#10
In which line is error "missing parts"?
#11
Sorry fir wasting your time Gintaras, but i'm a moron on this one.

The 'Liste' varible is a defined structure in another macro, did not take care of the red color when writing code.

BUT, the reference value in function works.

but if i want to use a pointer, that does not work as expected (in C , dereferncing the pointer should access the ARRAY.

ARRAY(int) a
for _i 0 10
    a[]=_i
    out a[_i]

ARRAY(int)* b=&a
Shuffle_Int(b)


Shuffle_Int
function ARRAY(int)'*anarray

_i=anarray.len
out _i   <====== outputs 10 as expected


out anarray[0] ====> Error (RT) in <open ":3263: /106">Shuffle_Int:  Exception 0xC0000005. Access violation. Cannot read memory at 0x32C0000. In qm.exe at 0x49EC4B (0x400000+0x9EC4B)

must use a double pointer and pass adress of array?
#12
Why to pass array pointer and not reference?

Shuffle_Int(a)

Shuffle_Int
function ARRAY(int)&anarray
#13
essentially to learn....

as it does not work as expected, i hoped the you could show me the right code to use!!!!

Passing by pointers could be useful in other situations, and i can't find the good way to do this in QM
#14
Don't know why access violation exception. Should be array type mismatch, because out cannot convert ARRAY(int) to string. If you want to access elements of ARRAY passed by pointer:

function ARRAY(int)*anarray

_i=anarray.len
out _i
;out anarray[0] ;;array type mismatch, because anarray[0] is ARRAY(int)
out anarray[0][0] ;;anarray[0][0] is int
#15
Or do you want to pass array memory directly?

Shuffle_Int(&a[0] a.len)

Function Shuffle_Int:
function int*anarray int'arrayLength

out arrayLength
out anarray[0]
#16
ok, then if i understand correctly, i must access first element of 1 dim array as it was a 2 dim array, whose first column is 0 (1 dim) and datas in 2nd column to get the int value..........

a[0] -> out a[0][0]
a[1] -> out a[0][1
and so on

Is that right?

Quote:Shuffle_Int(&a[0] a.len)


so passing by pointer the address of the ARRAY does not permits to use a.len in function? OK explains some troubles...
#17
2-dim array elements are accessed a[0 0]

anarray is pointer to an ARRAY(int) variable. Then anarray[0] is that variable, and anarray[0][0] is element 0 of that variable.
#18
OK, hard to change C habits...name of array is a pointer to first element, but can acces datas via name[X] directly (I know you know but explains why i struggle)

BTW, will QM3 accept QM2 syntax AND C#, or only C# (in this case, i guess i'll have to start learning it as I never learned or used it)?
#19
QM3 - only C#. But QM2 and QM3 can run at the same time, like 2 different programs.
#20
will QM3 able to port QM2 macros to C# and avoid losing years of coding?
Will it keep current features (dialog editor, Acc find and use etc etc) or will it lose
features (i guess it will add new features too)?

I ask that because I love using QM, got used to QM2 syntax (except when failures as this thread shows) and wonder
if worth switching to Visual C# if all the bells and whistles of QM2 aren't enables in QM3.....

I'm worried, nothing more...
#21
QM2 macros cannot be converted to QM3 C#. You can continue using QM2, and if like, start using QM3 too.
At first QM3 will have less features than QM2, but will evolve and I expect after several years will have everything and more.
#22
OK, by convert, i was thinking actually rewrite...

Time will tell, but i suppose QM2 will be stalled from the day QM3 emerges and no more improved......

But maybe if compatible with regular C#, we can port to QM3 third party code to use in QM3 and extend possibilities, as C langage helps me to 
code and add functions to QM (as in this last program where I translate in QM a Fisher-Yates algorithm found on the web.....

Thanks for the good job anyway...and still using QM


Forum Jump:


Users browsing this thread: 5 Guest(s)