Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29267 Discussions

Problems with real value translation Dlg Win32

ileao1
Beginner
1,052 Views
I wrote a program in CVF win32 Template, using dialog boxes, and i come across with some problems related to the translation of characters strings into real values.
Here is a code sample:
character(80) text
integer ioint
A0 real
integer(4) iret
.
case (WM_COMMAND)
if (LoWord(wParam) .EQ. IDC_EDIT_A0) then
iret = GetDlgItemText(dlg, IDC_EDIT_A0,text,len(text))
read(text,*,iostat = ioint) A0
.
.
.
endif

if i highlight all the numbers in the edit box and write the new value over the old, the translation do not proceed, the variable A0 keeps its old value.
What should i do? anybody knows?
ileao
0 Kudos
6 Replies
Steven_L_Intel1
Employee
1,052 Views
My guess is that the READ is failing - possibly because of the NUL in the string which I think will be returned by GetDlgItemText. What is the value of ioint after the READ? What is the contents of variable TEXT before the READ?

Steve
0 Kudos
ileao1
Beginner
1,052 Views
Before typing in the editing box the values were

before
Co = 6.2, ioint = 0 and text=' '


EDIT BOX = 20 [entered]
read(text,*,iostat = ioint) Co

after
text = '20 '
ioint = 59
Co = 6.2 [Unchanged]

I really dont know why!!!!!!! Read produced no effect.



ileao

0 Kudos
Steven_L_Intel1
Employee
1,052 Views
Error 59 is "List-directed I/O Syntax Error", which is what I expected. The READ is failing and thus doesn't change the variable.

I'll bet that after the 20 is a NUL. You need to adjust the length of TEXT to eliminate the NUL. One way is this:

i = index (text,char(0)) - 1
text = text(1:i)

then do the read.

Steve
0 Kudos
ileao1
Beginner
1,052 Views
Steve.

I dont if it's becouse i'm using the dfwina module, but the INDEX command seems to fail.
C:TEMPCVF - USER MADE Examplesgenesiswin32DATA.f90(318) : Error: This name has not been declared as an array or a function. [INDEX]
i = INDEX (co_text,char(0)) - 1
0 Kudos
Steven_L_Intel1
Employee
1,052 Views
INDEX is an intrinsic, and I don't know of anything in DFWINA that would pose a conflict. Perhaps you have INDEX declared explicitly elsewhere?

Steve
0 Kudos
ileao1
Beginner
1,052 Views
Steve

Thank you very very much. It runs softly...!! You were right.

May be you could help me in another problem. Ill post right now.

ileao.
0 Kudos
Reply