- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
in a QuickWin project, to get the name of a file to be oppened, I use
a subroutine containing the GETOPENFILENAME function.
The variable with the name of the file is defined to GETOPENFILENAME
in GGG%LPSTRFILE = LOC(NOMEARQ). NOMEARQ is declared in a module:
MODULE MODTRON
CHARACTER*255 NOMEARQ
LOGICAL TRONCO,INTERFERENCIA
END MODULE MODTRON
Another subroutine (wich also uses MODTRON) generates a OUTPUT.TXT file, with the filename,
obtained with GETOPENFILENAME, as a header.
To write the header I used:
OPEN(UNIT=5, FILE='C:PROJOUTPUT.TXT',FORM='FORMATTED')
WRITE(5,11)NOMEARQ
11 FORMAT(//,3X,'FILE: ',A25)
What is writen as the header, after 'FILE: ', is the filename appended with a nul character.
To get rid of the nul character I tried:
IL=LEN_TRIM(NOMEARQ)
OPEN(UNIT=5, FILE='C:PROJOUTPUT.TXT',FORM='FORMATTED')
WRITE(5,11)NOMEARQ(1,IL-1)
11 FORMAT(//,3X,'FILE: ',A25)
The nul character disapeared but 9 blanks were inserted before the filename.
What worked was:
CHARACTER*25 ARQD
.
.
.
IL=LEN_TRIM(NOMEARQ)
IRET=SYSTEMQQ('ECHO '//NOMEARQ(1:IL-1)//' > C:PROVPROV.TXT')
OPEN(UNIT=4, FILE='C:PROVPROV.TXT',FORM='FORMATTED')
READ(4,*) ARQD
CLOSE(4,DISP='DELETE')
OPEN(UNIT=5, FILE='C:PROJOUTPUT.TXT',FORM='FORMATTED')
WRITE(5,11)ARQD
11 FORMAT(//,3X,'FILE: ',A25)
This solution makes a hugly black DOS windows to appear for some seconds (due to SYSTEMQQ).
Is there an ellegant way of geting rid of the nul character? I have looked in online help but found nothing.
Thanks
Geraldo
in a QuickWin project, to get the name of a file to be oppened, I use
a subroutine containing the GETOPENFILENAME function.
The variable with the name of the file is defined to GETOPENFILENAME
in GGG%LPSTRFILE = LOC(NOMEARQ). NOMEARQ is declared in a module:
MODULE MODTRON
CHARACTER*255 NOMEARQ
LOGICAL TRONCO,INTERFERENCIA
END MODULE MODTRON
Another subroutine (wich also uses MODTRON) generates a OUTPUT.TXT file, with the filename,
obtained with GETOPENFILENAME, as a header.
To write the header I used:
OPEN(UNIT=5, FILE='C:PROJOUTPUT.TXT',FORM='FORMATTED')
WRITE(5,11)NOMEARQ
11 FORMAT(//,3X,'FILE: ',A25)
What is writen as the header, after 'FILE: ', is the filename appended with a nul character.
To get rid of the nul character I tried:
IL=LEN_TRIM(NOMEARQ)
OPEN(UNIT=5, FILE='C:PROJOUTPUT.TXT',FORM='FORMATTED')
WRITE(5,11)NOMEARQ(1,IL-1)
11 FORMAT(//,3X,'FILE: ',A25)
The nul character disapeared but 9 blanks were inserted before the filename.
What worked was:
CHARACTER*25 ARQD
.
.
.
IL=LEN_TRIM(NOMEARQ)
IRET=SYSTEMQQ('ECHO '//NOMEARQ(1:IL-1)//' > C:PROVPROV.TXT')
OPEN(UNIT=4, FILE='C:PROVPROV.TXT',FORM='FORMATTED')
READ(4,*) ARQD
CLOSE(4,DISP='DELETE')
OPEN(UNIT=5, FILE='C:PROJOUTPUT.TXT',FORM='FORMATTED')
WRITE(5,11)ARQD
11 FORMAT(//,3X,'FILE: ',A25)
This solution makes a hugly black DOS windows to appear for some seconds (due to SYSTEMQQ).
Is there an ellegant way of geting rid of the nul character? I have looked in online help but found nothing.
Thanks
Geraldo
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In your first attempt to get rid of the null just replace
IL=LEN_TRIM(NOMEARQ)
with
IL=INDEX(NOMEARQ,CHAR(0))
and NOMEARQ(:IL-1) has what you want.
James
IL=LEN_TRIM(NOMEARQ)
with
IL=INDEX(NOMEARQ,CHAR(0))
and NOMEARQ(:IL-1) has what you want.
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
James
Using IL=INDEX(NOMEARQ,CHAR(0)) gives the same as in my first try:
NOMEARQ(:IL-1) is right justified in the A25 field and the 9 leading blanks I refered are the diference between
25 and the number of characters of a particular filename. Those leading blanks do not harm but it is not nice having
FILE: C:PROJECTXYZ.DAT
Instead of
FILE: C:PROJECTXYZ.DAT
Trying ADJUSTLEFT(NOMEARQ(:IL-1)) left justified it but inserted nul characters up to position 25.
What solved my problem was:
NOMEARQ(IL:25)=' '
WRITE(5,11)NOMEARQ(:25)
11 FORMAT(//,3X,'FILE: ',A25)
Thanks for your answer, it made me think a litle more.
Geraldo
Using IL=INDEX(NOMEARQ,CHAR(0)) gives the same as in my first try:
NOMEARQ(:IL-1) is right justified in the A25 field and the 9 leading blanks I refered are the diference between
25 and the number of characters of a particular filename. Those leading blanks do not harm but it is not nice having
FILE: C:PROJECTXYZ.DAT
Instead of
FILE: C:PROJECTXYZ.DAT
Trying ADJUSTLEFT(NOMEARQ(:IL-1)) left justified it but inserted nul characters up to position 25.
What solved my problem was:
NOMEARQ(IL:25)=' '
WRITE(5,11)NOMEARQ(:25)
11 FORMAT(//,3X,'FILE: ',A25)
Thanks for your answer, it made me think a litle more.
Geraldo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Geraldo,
I thought but didn't say that you would also change the FORMAT statement from "A25" to "A". :-) Note that what is inserted in your case is not "nul" characters but spaces.
James
I thought but didn't say that you would also change the FORMAT statement from "A25" to "A". :-) Note that what is inserted in your case is not "nul" characters but spaces.
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
James
Using IL=INDEX(NOMEARQ,CHAR(0)) gives the same as in my first try:
NOMEARQ(:IL-1) is right justified in the A25 field and the 9 leading blanks I refered are the diference between 25 and the number of characters of the particular filename
I used.
Those leading blanks do not harm but it is not nice having
FILE: C:PROJECTXYZ.DAT
Instead of
FILE: C:PROJECTXYZ.DAT
Trying ADJUSTLEFT(NOMEARQ(:IL-1)) left justified it but inserted nul characters up to position 25.
What solved my problem was:
NOMEARQ(IL:25)=' '
WRITE(5,11)NOMEARQ(:25)
11 FORMAT(//,3X,'FILE: ',A25)
Thanks for your answer, it made me think a litle more.
Geraldo
Using IL=INDEX(NOMEARQ,CHAR(0)) gives the same as in my first try:
NOMEARQ(:IL-1) is right justified in the A25 field and the 9 leading blanks I refered are the diference between 25 and the number of characters of the particular filename
I used.
Those leading blanks do not harm but it is not nice having
FILE: C:PROJECTXYZ.DAT
Instead of
FILE: C:PROJECTXYZ.DAT
Trying ADJUSTLEFT(NOMEARQ(:IL-1)) left justified it but inserted nul characters up to position 25.
What solved my problem was:
NOMEARQ(IL:25)=' '
WRITE(5,11)NOMEARQ(:25)
11 FORMAT(//,3X,'FILE: ',A25)
Thanks for your answer, it made me think a litle more.
Geraldo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
James,
I messed things and send twice the same reply.
As for changing the A format I will test.
Thanks again
Geraldo
I messed things and send twice the same reply.
As for changing the A format I will test.
Thanks again
Geraldo

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