Silverfrost Forums

Welcome to our forums

A displaying problem+how to find what was selected in combo

9 Apr 2020 7:15 #25174

I am new to ClearWin+ and have (at present) 2 problems:

PROBLEM 1: I defined a window with three button options. First button enables to choose an input data file, the second one enables to select an output data file, where the input data will be re-written in a new structure (format).

After selecting the input data file, the file name (including path) is displayed in the box below the button (which I required), when the output data file is selected, the filename is NOT displayed in the box below.

I don´t know why, since the code should be OK (see below).

Problem 2. Third button is a combo, where I can select between two options, which are both CHARACTER*1 (z or b).

QUESTION: How can I find out what was selected and assign it to a variable in the main program, which will pass it to a subroutine? I tried to write a call back function, however, I was unable to find, how to pass the selected answer (z or b) within main program to assign it to a variable, which will be passed to a subroutine

Below, my code of the main program follows (without subroutine, which works fine):

WINAPP

PROGRAM TXT_2_SGF_WIN_APP

IMPLICIT NONE
INCLUDE <windows.ins>
EXTERNAL sb_vstup3, sb_vstup4 !, cb_combo
INTEGER ans, w, h, sb_vstup3, sb_vstup4, k, i
CHARACTER*129 subor3, subor4 !str, vstup!, vystup
CHARACTER*1 zmena(2)!, clearwin_string
DATA (zmena(i), i=1,2)/'z','b'/
COMMON subor3, subor4 !str, vstup
w=1000
h=600
subor3='.txt'
subor4='.txt' 

call ENABLE_UTF8@(1)

ans=winio@('%sz&amp;',w,h)

ans=winio@('%ww[no_frame,casts_shadow]&amp;')

ans=winio@('%ca[Program: TXT_2_SGF   - restructuring original input data to a new data structure]&amp;')

! ! Choose an input data TXT file ! ans=winio@('%3nl%ta%bf%fn[Courier New]Vstup TXT pre SGF:%ta%`^bt[&Vybrať súbor]&','FILE_OPENR[Zvoľ súbor]',subor3,sb_vstup3)

! ! Displaying of the name of the selected input file (including its path) ! ans=winio@('%2nl%ta%ob%80st%cb&',subor3) ! ! Dispalying of the output file name, where newly structured data will be written ! ans=winio@('%3nl%ta%bf%fn[Courier New]Výstup TXT pre SGF:%ta%^bt[&Vybrať súbor]&','FILE_OPENR[Zvoľ súbor]',subor4,sb_vstup4)

ans=winio@('%2nl%ta%ob%80st%cb&amp;',subor4)

! ! Defining whether to change the sign in fron of DX, DY values or not using combo box selection ! where z stands for YES and b stands for NO ! k=1

i=winio@('%3nl%taZmeniť zn. pred DX a DY vo výslednom TXT súbore? (z=áno, b=nie)%`5.2ls',zmena,3l,k)!,clearwin_string(zmena)) !call clearwin_string@('zmena') print *,'znam= ', zmena

END PROGRAM TXT_2_SGF_WIN_APP

INTEGER FUNCTION sb_vstup3() IMPLICIT NONE

CHARACTER*129 subor3, subor4 !str,vstup
INTEGER sb_vstup3
COMMON subor3, subor4 !str, vstup
!vstup=''

! WRITE (subor3,*) subor3

sb_vstup3=2
CALL window_update@(subor3)

END

INTEGER FUNCTION sb_vstup4() IMPLICIT NONE

CHARACTER*129 subor4, subor3 !str,vstup 
INTEGER sb_vstup4
COMMON subor4, subor3 !str, vstup
!vstup=''

! WRITE (subor4,*) subor4

sb_vstup4=1
CALL window_update@(subor4)

END

!CHARACTER() FUNCTION CLEARWIN_STRING (zmena) !CHARACTER() zmena !write(clearwin_string,*)zmena !END FUNCTION

!INTEGER FUNCTION cb_combo() ! IMPLICIT NONE ! CHARACTER1 zmena ! CHARACTER129 subor4, subor3
! INTEGER cb_combo ! COMMON subor4, subor3, zmena ! WRITE (zmena,*) zmena

! cb_combo=1 !END

11 Apr 2020 11:31 #25175

Thanks John!

I solved the problem with combo box selection (I did not notice the argument cur_item)!

However, I still have the first problem (when I select/define an output file, using OPEN_FILEW, the selected/defined variable file is not displayed in the required box (ans=winio@('%2nl%ta%ob%80st%cb&',s4) in contrast to the fisrt case, where when using OPEN_FILER, the selected variable is displayed in the requested box (ans=winio@('%2nl%ta%ob%80st%cb&',s3) ,

12 Apr 2020 3:56 #25176

At the very beginning of the development I also tried to use FILE_OPENR for the output file name, however, this not worked, nothing was displayed in the prepared box for it. But I found that the use of OPEN_FILER does NOT allow to specify a new file name (which is required). Therefore I switched to FILE_OPENW. Now, I can specify a new file name l by typing in its name according to my will, however, this changes nothing in my problem - the prepared box, where the typed in output file name (including its path) should be displayed does not work as before (I see there only initialization name for the output file, which is .txt). So, I really do NOT understand, where could be a problem, since (apart from this) the program runs. I tried to debug it and I could see (under variable for output file name) the correct file name, which I typed in (including its path). Nevertheless - the box displays - as before - only string .txt (as originally initialized in the main program, regardless what I type in.

14 Apr 2020 9:24 #25196

Hi John,

I would like to send the screenshot of the main window, however - how can I do it here? I see no attachment option here (for file attachments, as it is usual in other platforms). Is it the IMG ption([img]http://image_url[/img])? I am here (in this forum) totally new (a week), so please be a little bit patient and advise me. I could access my server, where you could download full description of my problem including all necessary files, if necessary.

Explanation to your question: In the main window of the program I select three variables: Variable1 - an existing data file (I use OPEN_FILER - it works, I see in the box prepared for displaying of the selection the selected filename including its path). Variable2 - I used both FILE_OPENR and then FILE_OPENW to display the selected output file name TYPED IN by me (the file DOES NOT exists yet). The typed in filename is NOT displayed in the box below prepared for it (regardless what I use - OPEN_FILER or W), although the program works, creates the file specified by me and writes in the data in the requested format (more than 87 000 lines, each line consists of X,Y coordinates and their DX, DY variations) Variable3: I can choose (in the combo box), whether I want to change the signs (+ or -) in front of DX, DY values to the opposite signs or NOT. Selection z stands for YES (in slovak language: change = zmena, therefore is there z). Selectionb is NOT for box, it stands for NO CHANGE in signs (in slovak: bez zmeny/without change, therefore you see there the option b.

15 Apr 2020 10:58 #25215

Martin,

I have compiled and run your demo code as I couldn't at first work out what is going wrong. However, the issue isn't FILE_OPENW because if you change both of them to _OPENR or both to _OPENW, or one of each in either order, the first one works as expected and the second one doesn't.

The error is that in your callback routine sb_vstup4 you have the order of subor3 and subor4 reversed in your COMMON statement. So, if you change them round, the demo program works as intended. I have appended a cut down version of your program.

Eddie

WINAPP
PROGRAM Test
IMPLICIT NONE
INCLUDE <windows.ins>
EXTERNAL sb_vstup3, sb_vstup4 
INTEGER ans, sb_vstup3, sb_vstup4
CHARACTER*129 subor3, subor4 
COMMON subor3, subor4 
subor3='.txt'
subor4='.txt'
ans = winio@ ('%ca[Test]&')
ans=winio@('%nl%bf%fn[Courier New]%`^bt[&Get File 1]&','FILE_OPENW[File_1]',subor3,sb_vstup3)
ans=winio@('%2nl%ob%80st%cb&',subor3)
ans=winio@('%3nl%bf%fn[Courier New]%^bt[&Get File 2]&','FILE_OPENW[File_2]',subor4,sb_vstup4)
ans=winio@('%2nl%ob%80st%cb',subor4)
END PROGRAM 

INTEGER FUNCTION sb_vstup3()
IMPLICIT NONE
CHARACTER*129 subor3, subor4
INTEGER sb_vstup3
COMMON subor3, subor4
sb_vstup3=2
CALL window_update@(subor3)
END

INTEGER FUNCTION sb_vstup4()
IMPLICIT NONE
CHARACTER*129 subor3, subor4 ! change not needed
INTEGER sb_vstup4
COMMON subor3, subor4
sb_vstup4=2
CALL window_update@(subor4)
END
16 Apr 2020 6:25 #25225

Many thanks Eddie!!! Now it works fine. I reviewed my code 100x, but was unable to catch the reversed order! Again - many thanks and best wishes!

Martin

20 Apr 2020 8:36 #25258

Thanks again Eddie!

I already registered, so next time, when I will have a problem and some images will help to solve it, I will post them there!

Martin

Please login to reply.