- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is a newbie question, have the following code, which works acceptably but am wondering if there is a simpler way to do it? I want to have a list box with a selection of integers or real numbers available as choices. I want to read the operators selection, do some calculations with this choice and then output them back to a different dialog box. If there is a way I would store the originals in the intput box as integers or reals, rather than strings. As it is I read a string, convert it to and integer, do the calculations, convert back to an string and then send it back to the other dialog box.
I'm sure this is trivial, let me know if there is a more straight forward way.
Thanks
Jim
I'm sure this is trivial, let me know if there is a more straight forward way.
Thanks
Jim
logical retlog ! read input from dialog box retlog = DlgGet( dlg, idc_input, index ) ! convert string to integer read(index,*) value ! perform calculations value3=value*3 ! convert integer value back to string write(index2,'(I4)') value3 ! send output as string back to different dialog box retlog = DlgSet( dlg, IDC_OUTPUT, index2 )
Link Copied
1 Reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That's the only sure way. There are Win32 APIs GetDlgItemInt and SetDlgItemInt (use Dlg%hWnd as the first argument) but I'm not sure whether they'd work correctly in conjunction with DFLOGM (I foresee problems with updating of edit box contents).
I usually use a home-brew helper library for working with strings. That will avoid necessity for having a character dummy variable for writing (but not for reading),
something along these lines:
So, your last line would look like
HTH
Jugoslav
I usually use a home-brew helper library for working with strings. That will avoid necessity for having a character dummy variable for writing (but not for reading),
something along these lines:
MODULE STRINGS INTERFACE STRING MODULE PROCEDURE FSTRING MODULE PROCEDURE ISTRING END INTERFACE CONTAINS FUNCTION FSTRING(fValue, iWid, iPrec) RESULT(s) !Writes fValue into string of length iWid with iPrec decimals CHARACTER(LEN=iWid):: s REAL, INTENT(IN):: fValue INTEGER, INTENT(IN):: iWid, iPrec CHARACTER(10):: sFormat INTEGER:: iErr WRITE(sFormat, "('f', i3.3,'.', i3.3)") iWid, iPrec WRITE(s, sFormat, IOSTAT=iErr) fValue END FUNCTION FSTRING !ISTRING is for your excercise :-) END MODULE STRINGS
So, your last line would look like
retlog = DlgSet( dlg, IDC_OUTPUT, STRING(index2, 4) )
HTH
Jugoslav

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