Operating System - OpenVMS
1826452 Members
4051 Online
109692 Solutions
New Discussion

Re: problem getting the correct filename

 
SOLVED
Go to solution
nipun_2
Regular Advisor

problem getting the correct filename

Hi,
I have problem renaming a file. In my case it is DICOM File


I am passing the complete file path as a an argument in 'p1' and 'p2'
The way I give it to file

"$@''IPL_FILE' ''AIMFILE' ''DICOMFILE'"

so p1 is

AIMFILE := 'DEV''DIR''FILENAME'.AIM

p2 is

DICOMFILE := 'DEV''DIR''FILENAME'.DCM



And here is the script attached. I need to use

"dicomFilename"

So I am having trouble at
$ dicomFilename := F$PARSE(p2,,,"DIRECTORY") + filename

as a symbol
where i would need that
dicomFilename is a symbol containg "disk1:[dir1.dir2]chk"

Please let me know if you require further clarification
13 REPLIES 13
Uwe Zessin
Honored Contributor
Solution

Re: problem getting the correct filename

Nipun,
if I understand the problem correctly, you just need to use this (not ":=", but a simple "="):

$ dicomFilename = F$PARSE(p2,,,"DIRECTORY") + filename
.
Lawrence Czlapinski
Trusted Contributor

Re: problem getting the correct filename

nipon:
Try dicomFilename:='F$PARSE(p2,,,"DIRECTORY")'+'filename'

$DIR = "[SYS_MGMT.logs]"
$DICOMFILE:='DEV''DIR'FILENAME.DCM
$DEV = "DSA0:"
$DIR = "[SYS_MGMT.logs]"
$filename:=change_check.log
$DICOMFILE:='DEV''DIR''FILENAME' !all Single quotes
$P2=DICOMFILE
$dicomFilename:='F$PARSE(P2,,,"DIRECTORY")'+'FILENAME'
ASDEV1» sh sym dicomfilename
DICOMFILENAME = "[SYS_MGMT.LOGS]+CHANGE_CHECK.LOG"
Lawrence
Phillip Thayer
Esteemed Contributor

Re: problem getting the correct filename

On the line:

dicomFilename := F$PARSE(p2,,,"DIRECTORY") + filename

Remove the ":" in front of the "=" so that it would be as follows:

dicomFilename = F$PARSE(p2,,,"DIRECTORY") + filename

and this should work.

Phil
Once it's in production it's all bugs after that.
Lawrence Czlapinski
Trusted Contributor

Re: problem getting the correct filename

Nipon: As Uwe said = works.
If you use, ":=" whatever is behind it is intrepeted as ASCII strings, so you would need single quotes around both parts to have DCL translate both parts correctly.
Lawrence
Uwe Zessin
Honored Contributor

Re: problem getting the correct filename

Doesn't work for me, Lawrence:

$ A="12"
$ B="34"
$
$ C:='A'+'B'
$ show symbol C
C = "12+34"
$

A slightly different version that does not work either:

$ C:="''A'"+"''B'"
$ show symbol C
C = "12+34"
$

This works:
$ C=A+B
$ show symbol C
C = "1234"
$

And this:
$ C="''A'"+"''B'"
$ show symbol C
C = "1234"
$
.
nipun_2
Regular Advisor

Re: problem getting the correct filename

thanks for the reply guys,
That worked however I have to do F$Parse in a different way.

However, I can't seem to go into the "IF loop"

I want to have the option that if some user writes

filename = "test" file

it should go into the IF LOOP so that we can have that name of the file

otherwise go the normal way.

Currently I feel it just doesn't enter the IF Subroutine.

I am reattaching the script file. Please let me know what I am doing wrong.
nipun_2
Regular Advisor

Re: problem getting the correct filename

thanks for the reply guys,
That worked however I have to do F$Parse in a different way.

However, I can't seem to go into the "IF loop"

I want to have the option that if some user writes

filename = "test" file

it should go into the IF LOOP so that we can have that name of the file

otherwise go the normal way.

Currently I feel it just doesn't enter the IF Subroutine.

I am reattaching the script file. Please let me know what I am doing wrong.
Uwe Zessin
Honored Contributor

Re: problem getting the correct filename

I don't see a loop, but let me allow a few comments / questions:

> $ filename = default

Do you have a symbol named "DEFAULT" or did you intend this:
$ filename = "default"

>$ dicomFilename = p2 - F$PARSE(p2,,,"VERSION") - ".DCM" - F$PARSE(p1,,,"NAME")+ filename
>$ dicomFilename = filename

The second command overwrites the result of the first command. I don't know if this is intentional, because there is no explanation what parameters the command procedure is supplied, but I see that the first command line uses |P1| and |P2|.

>$ EXIT
>$ ENDIF

Note that the procedure will always EXIT here when the symbol |filename| is a non-empty string and "ipl_scanco_prog" will not execute.

> -dicom_filename "dicomFilename

I guess this line is read by the program named "ipl_scanco_m.exe", but please note that DCL does not translate the value of the symbol |dicomFilename| for you.
.
nipun_2
Regular Advisor

Re: problem getting the correct filename

Hi Uwe,
Thanks for the detailed analysis. By loop I meant the "IF loop"

I want it to enter the loop if the user keeps the variable

filename = ""


I removed

"EXIT"

command from the IF subroutine. But I think I am still unable to enter the IF subroutine. I have attached the file again with the changes.

Regarding

filename = "default" (I intentionally kept it to see whether it comes up)

>$ dicomFilename = p2 - F$PARSE(p2,,,"VERSION") - ".DCM" - F$PARSE(p1,,,"NAME")+ filename
>$ dicomFilename = filename

The repition above was because I was not clear whether it does enter the sub-routine and is unable to do the parsing or just skips it.


Regarding p1 and p2 they are input arguments.



regaring IPL yeah from then it goes into a seprate application which is fine. I did not wish to eliminate that part for overall clarity.

Pleas let me know if you require further information or clarification.
Karl Rohwedder
Honored Contributor

Re: problem getting the correct filename


$ IF filename .ne. ""
$ THEN
$! dicomFilename = p2 - F$PARSE(p2,,,"VERSION") - ".DCM" - F$PARSE(p1,,,"NAME")+ filename
$ dicomFilename = filename
$ ENDIF

Shouldn't that be ".nes." instead of ".ne."?
You are comparing strings.

regards Kalle
Lawrence Czlapinski
Trusted Contributor

Re: problem getting the correct filename

Uwe:
I didn't realize my original statement was ambiguous.
"If you use, ":=" whatever is behind it is interpeted as ASCII strings, so you would need single quotes around both parts to have DCL translate both parts correctly." typo corrected
First, single quotes are required for each symbol not the plus sign. Without the single quotes, DCL adds the characters to the string being defined. There are parsing exceptions including single quote and double quotes.
You didn't follow the whole example I gave.
$DICOMFILE:='DEV''DIR''FILENAME' !all Single quotes
There is no "+" sign.

When combining strings, you don't normally need a "+" sign.
ASDEV1» a="12"
ASDEV1» b="34"
ASDEV1» c:='a''b'
ASDEV1» sh sym c
C = "1234"

For
$dicomFilename:='F$PARSE(P2,,,"DIRECTORY")'+'FILENAME'
if you use ":=", you need single quotes for both parts, otherwise you only get the directory part. For this line you do need the "+" sign if you use ":=". This is probably because of the lexical translation.

ASDEV1» c:='a'+'b'
ASDEV1» sh sym c
C = "12+34"
ASDEV1» c:=a+b
ASDEV1» sh sym c
C = "A+B"
ASDEV1» c:='a+'b
ASDEV1» sh sym c
C = "12+34"
ASDEV1» c:=ab
ASDEV1» sh sym c
C = "AB"
Lawrence
Lawrence Czlapinski
Trusted Contributor

Re: problem getting the correct filename

nipun: Put the lexical parts of dicomfilename into symbols in your development debug version. Then you can have debug show symbol statements to show what DCL is getting for the parts and for dicomfilename. After you are satisfied, comment them out.
Lawrence
Uwe Zessin
Honored Contributor

Re: problem getting the correct filename

Yes, I got confused by this statement from you:
> Try dicomFilename:='F$PARSE(p2,,,"DIRECTORY")'+'filename'

Thanks for the correction.
.