- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everybody,i have a wired problem, i am trying to retrieve some strings from an edit box,i can store the string in a variable, but when i later do anotheroperations i lose the string stored in my variable, i dont know the reason specially because this disn't happen before, but now isdriving me crazy. Im sure someone can help me.
IRET=GETDLGITEMTEXT(HDLG,IDC_NAME,str10,20)
IRET=GetwindowTextLength(hname)
IF(iret==0) THEN
IRET=MESSAGEBOX(HDLG,'Must Input Tendon Name','Input missing',ior(ior(mb_ok,mb_iconexclamation),mb_applmodal))
goto 10000
END IF
temp1(1)%name= str10 !---> i can store the string in temp1(1)%name
!get the material
iret = SendMessage(hipstyp1, CB_GETCURSEL, 0, &
0 )
iret = SendMessage(hipstyp1,CB_GETLBTEXT, iret, &
loc(str) ) ! afterthis command i loose the temp1(1)%name value and becomes = ' '
Thanks friends!
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
str10 is 23 chars long, temp1(1)%name is 20 long.
I already solve the problem by changing the position of this line ->temp1(1)%name= str10, to the end of the code I posted, so it finally comes this way. I don't know the reason but it works if you know please tell me.
IRET=GETDLGITEMTEXT(HDLG,IDC_NAME,str10,20)
IRET=GetwindowTextLength(hname)
IF(iret==0) THEN
IRET=MESSAGEBOX(HDLG,'Must Input Tendon Name','Input missing',ior(ior(mb_ok,mb_iconexclamation),mb_applmodal))
goto 10000
END IF
!get the material
iret = SendMessage(hipstyp1, CB_GETCURSEL, 0, &
0 )
iret = SendMessage(hipstyp1,CB_GETLBTEXT, iret, &
loc(str) )
temp1(1)%name= str10 !---> now it works
THANKS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
kooka:
str10 is 23 chars long, temp1(1)%name is 20 long.I already solve the problem by changing the position of this line ->temp1(1)%name= str10, to the end of the code I posted, so it finally comes this way. I don't know the reason but it works if you know please tell me.
You didn't say how long is str (not str10!). Is it a character variable at all?
Try this:
- Revert the code to the previous, "erroneous" state
- Set a breakpoint (F9) at the CB_GETLBTEXT line
- Run the program through the debugger (F5)
- Open the Debug/Windows/Memory 1 window. Type "Temp1(1)%name" there. You should see a stream of bytes with the variable contents in that window.
- Step over the CB_GETLBTEXT line (F10). You will see new memory contents in red. Try to figure out how it got overwritten.
- If necessary, also open another Memory window (Memory 2) and watch the contents of str there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I agree with Jugoslav, moving the line only moves the problem to another place, it doesnt solve it. I know that, made my experience in memory corruption too :-) Cause and effect are not related in that case, so bad code doesnt produce an error at once, but later on. When you copy a variable for example.
Try these compiler settings: In Fortran -> Diagnostics set Generate Interface Blocks Yes and Check Routine Interfaces Yes. Get rid of all new reported warnings, move your line back to where it was and look if the error still occurs.
Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
tanks friends, i discovered the problem.
the problemis been caused by the str value -> 'pres ', it is overwritting part of the memory of temp1(1)%name, the problem is that, that value is been retrieved from a combobox, and the value is corrupted. When i want to put a string in the combo it has the value 'pres ', but when i send this message:
iret = SendMessage(hipstyp1, CB_INSERTSTRING, -1, &
loc(ACEROS(I)%NAME) )
the string is corrupted with a strange value comming-> 'pres ', I already probe this way:
iret = SendMessage(hipstyp1, CB_INSERTSTRING, -1, &
loc(trim(ACEROS(I)%NAME)) )
but gets this way -> 'pres~qJ '., now i can retrieve the value of temp1(1)%name adding a trim funtion to str
character(23) str, STR10
temp1(1)%name= trim(str10)
!get the material
iret = SendMessage(hipstyp1, CB_gETCURSEL, 0, &
0 )
iret = SendMessage(hipstyp1,CB_GETLBTEXT, iret, &
loc(trim(str)) )
but now i cant get the value of str because it becomes ' ' .
I am lost now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
finally i solved.
the code is
character(23) str, STR10
.....!omited code
!set the string in the combo box
iret = SendMessage(hipstyp1, CB_INSERTSTRING, -1, &
loc(trim(adjustl(ACEROS(I)%NAME))//' 'C) )
.....!omited code
temp1(1)%name= trim(str10)
!get the material
iret = SendMessage(hipstyp1, CB_gETCURSEL, 0, &
0 )
iret = SendMessage(hipstyp1,CB_GETLBTEXT, iret, &
loc(str) )
! all work fine, tanks

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page