Operating System - OpenVMS
1753792 Members
7256 Online
108799 Solutions
New Discussion юеВ

Re: ENTER A STRING AND RETURN AN INT

 
Hein van den Heuvel
Honored Contributor

Re: ENTER A STRING AND RETURN AN INT


Yeah well... where the heck is the VMS component in this question.
Suddenly the whole problem sounds like a middle school home work excercise.

Oh well,
Regards,

Hein.
Lawrence Czlapinski
Trusted Contributor

Re: ENTER A STRING AND RETURN AN INT

Hein: My solution with a one correction catches false positives. I was checking for the wrong end value. Better to use f$length.
CONSHY├В┬╗ string="#F"
CONSHY├В┬╗ original_string="#F"
CONSHY├В┬╗ length=F$LENGTH(original_string)
CONSHY├В┬╗ if length.eq.1 then string=original_string+" "
CONSHY├В┬╗ if length.eq.2 string=original_string
%DCL-W-EXPSYN, invalid expression syntax - check operators and operands
CONSHY├В┬╗ if length.eq.2 then string=original_string
CONSHY├В┬╗ list="C C#D D#E F F#G G#A A#B "
CONSHY├В┬╗ integer_var=f$locate(string,list)/2
CONSHY├В┬╗ sh sym integer_var
INTEGER_VAR = 12 Hex = 0000000C Octal = 00000000014
CONSHY├В┬╗ if integer_var .eq. f$length(list)/2 then write sys$output "string error
on ",string
string error on #F
CONSHY├В┬╗
Lawrence
Jan van den Ende
Honored Contributor

Re: ENTER A STRING AND RETURN AN INT

Martin,

Let me do the honor that the previous posters omitted:

Welcome to the VMS forum.

And in case Hein is right (excuses when he and me are wrong!)

since you happened to trip on the worlds MOST stable, MOST secure (and regrettably, best kept-secret) OS, you are cordially invited to get some better aquaintance with it.
Be warned: the elegance, consistency, security, stability, & scalability of it, will forever ruin your positive view of any other OS!

Once again: Welcome.

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.
Lawrence Czlapinski
Trusted Contributor

Re: ENTER A STRING AND RETURN AN INT

Hein: You were right. I used the wrong input value. So it is better to use a delimiter.
Lawrence
John Gillings
Honored Contributor

Re: ENTER A STRING AND RETURN AN INT

Don't forget your enharmonic synonyms!

flats
C Db E Eb E...

double sharps
B+C#C+D#D+...

double flats
DbbDbEbbDbFb...

Upper casing might not be such a good idea if you use "b" for "flat".
A crucible of informative mistakes
Martin Devek
New Member

Re: ENTER A STRING AND RETURN AN INT

strcmp
David B Sneddon
Honored Contributor

Re: ENTER A STRING AND RETURN AN INT

Martin,

To borrow some text from Jan...

from your Forum Profile:


I have assigned points to 0 of 13 responses to my questions.


Maybe you can find some time to do some assigning?

http://forums1.itrc.hp.com/service/forums/helptips.do?#33

It is fully up to _YOU_ to decide how many points you
assign. If you consider an answer is not deserving any
points, you can assign 0 points, and then that answer
will no longer be counted as unassigned.
Consider, that every poster took at least the trouble
of posting for you!

To easily find your streams with unassigned points,
click your own name somewhere, this will bring up your
profile. Near the bottom of that page, under the caption
"My Question(s)" you will find "questions or topics with
unassigned points", clicking that will give all, and
only, your questions that still have unassigned postings.

Thanks on behalf of your Forum colleagues.

PS. Nothing personal in this. Jan tries to post it to
everyone with this kind of assignment ratio in this forum.
If you have received a posting like this before, please do
not take offence, none is intended!

Proost.

Have one on Jan.

Dave
Arch_Muthiah
Honored Contributor

Re: ENTER A STRING AND RETURN AN INT

Jan,

This thread has a sign of "this question has at least one answer that has received a rating of 8 points or better" when Martin does not assign ponits to any of the answers.

Archunan
Regards
Archie