forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

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

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
Martin_K



Joined: 09 Apr 2020
Posts: 120

PostPosted: Thu Apr 09, 2020 8:15 pm    Post subject: A displaying problem+how to find what was selected in combo Reply with quote

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&',w,h)

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

ans=winio@('%ca[Program: TXT_2_SGF - restructuring original input data to a new data structure]&')
!
! 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&',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
! CHARACTER*1 zmena
! CHARACTER*129 subor4, subor3
! INTEGER cb_combo
! COMMON subor4, subor3, zmena
! WRITE (zmena,*) zmena

! cb_combo=1
!END
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1450
Location: Aerospace Valley

PostPosted: Fri Apr 10, 2020 2:23 am    Post subject: Reply with quote

Define the variable(s) you want to pass in a MODULE and 'USE' that MODULE in all routines (and main program) where it's referenced.
Thus avoiding the use of older common blocls.
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1450
Location: Aerospace Valley

PostPosted: Fri Apr 10, 2020 2:31 am    Post subject: Reply with quote

cur_item is the index of the item whixh has been selected

(see https://silverfrost.com/ftn95-help/clearwinp/formats/_ls.aspx)
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
Back to top
View user's profile Send private message
Martin_K



Joined: 09 Apr 2020
Posts: 120

PostPosted: Sun Apr 12, 2020 12:31 am    Post subject: Reply with quote

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) ,
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1450
Location: Aerospace Valley

PostPosted: Sun Apr 12, 2020 12:55 pm    Post subject: Reply with quote

in your top post you wrote:
Quote:
when the output data file is selected, the filename is NOT displayed in the box below

.. do i understand that you're trying toSELECT the OUTPUT file from an already existing file ? .... because this is not what FILE_OPENW does ... it requires YOU TO TYPE THE FILENAME(i.e. it assumes a new file is required.

Try using FILE_OPENR for opening an existing file to which you want to WRITE.
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
Back to top
View user's profile Send private message
Martin_K



Joined: 09 Apr 2020
Posts: 120

PostPosted: Sun Apr 12, 2020 4:56 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1450
Location: Aerospace Valley

PostPosted: Tue Apr 14, 2020 2:00 pm    Post subject: Reply with quote

I'm confused about which b='box' you're expecting to be filled with the output filename ...
can you post screengrabs of what you get in each case Martin? ... for each of the use of OPEN_FILER@ and OPEN_FILEW@, foroutput file AND input file.
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
Back to top
View user's profile Send private message
Martin_K



Joined: 09 Apr 2020
Posts: 120

PostPosted: Tue Apr 14, 2020 10:24 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 2180
Location: Yateley, Hants, UK

PostPosted: Wed Apr 15, 2020 11:58 pm    Post subject: Reply with quote

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

Code:
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
Back to top
View user's profile Send private message
Martin_K



Joined: 09 Apr 2020
Posts: 120

PostPosted: Thu Apr 16, 2020 7:25 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 1450
Location: Aerospace Valley

PostPosted: Mon Apr 20, 2020 9:11 pm    Post subject: Reply with quote

Martin,

For posting screengrabs, etc ..... anything you want really in image form.

There is no storage facility on the forum.

But you can use this FREE (simple registration) service here to store your images (it's free):
https://postimages.org/

It was DanRRight who highlighted it initially as a good service to use.

The method is outlined in a post I made a couple of years back because of numerous requests on how to do it around that time, you can read it here:
http://forums.silverfrost.com/viewtopic.php?t=3825&highlight=postimg

For long codes etc people tend to use DropBox (or similar) and post the link.

As you'll quite quickly see the forum has a maximum post (comment) size limit , so often you may have to post in 2 or more comments !

It's a bugbear (or similar) which apparently we have to live with.
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
Back to top
View user's profile Send private message
Martin_K



Joined: 09 Apr 2020
Posts: 120

PostPosted: Mon Apr 20, 2020 9:36 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group