PaulNewton

65 Reputation

3 Badges

2 years, 261 days

MaplePrimes Activity


These are replies submitted by PaulNewton

@Carl Love Thank you for pointing that out (and my Visual Foxpro function suffers from the same shortcoming).  In my case I do know that there will always be a number in parentheses at the end of the string but your regex might very well come in useful in another context.

@dharr Thank you

(The FAIL is the result of the else clause, that is returned if there is no match.) 

I had worked that out, it was the fi that puzzled me

fi is a short form for end if. In older Maple these backward spellings were standard - also od for end do. Now they are no longer documented, but can still be used.

But perhaps shouldn't still be used (since they are now undocumented) so as not to confuse newbies like myself?

@Carl Love Thank you, but I must agree with acer 27088 said yesterday at 745 AM

In comparison, using complicated regular expression matching looks needlessly complicated here.

I am not sure what FAIL fi is doing - what is fi and where does it come from?

@Carl Love Regular expressions have always been a bit of a black art as far as I am concerned, unless

  1. I can find the regex I need (via Google or any number of sites that have pre-tested regex expressions in various categories (e.g. zip codes, postcodes, National Insurance numbers etc etc) or
  2. Somebody, like yourself, can come up with the regex that I need

I have filed away your Even more slick offering for possible future use ... so, thank you.

P.S. I wouldn't need true in the result, just "2.13"

@mmcdara Thank you.  I will compare your corrected version with mine and implement the changes you recommend.  I will also bear in mind your advice for the future.

@acer 

I only have a problem if I choose NO to both dialogs ...

@acer Thank you for Drop, Take and I will use your <pre> </pre> technique in my own future posts.

@acer Thank you,  You are right I needed substitute and not remove (I had misinterpreted the remove documentation).  I actually wanted the result "2.13" so the following does the trick (so I do need remove after all)

L1 := "Methionine = (S)-2-amino-4-(methylsulfanyl)-butanoic acid (2.13)";
acid1 := "Methionine = (S)-2-amino-4-(methylsulfanyl)-butanoic acid ";
StringTools:-Remove("()", StringTools:-Substitute(L1, acid1, ""));

Actually, in the language I am familiar with (Visual FoxPro) there is a better way to extract what I want directly from L1 without needing acid1

I could probably do the same in Maple if I were more au fait with string manipulation in Maple and had more time to find out how.

BTW How did you get the grey box for the code example in your previous post?

@acer

Your latest uploads are looking really good and I believe I can dispense with the display of the native plot entirely.  Now I only need to know if I can set the plot component properties to be variables.  Specifically, I would need to set the text of the legends so that they agree with the acids chosen for the plot, and also the text for the title.

I will start looking at the plot component documentation ...

@acer

Please ignore my last post.  I will work with your latest uploads for which I am very grateful.  Thank you. 

@acer 

I am testing with the second of your uploaded files in which the calculatePlot procedure does indeed return the plot.  I have edited the click code for the button to contain

use DocumentTools in 
  A := calculatePlot();
  plots:-display(A);
end use; 

but that doesn't work ... 

@acer 

Unfortunately neither of the documents you uploaded is workiing as I expected.  When you first execute the worksheet, all is well but then when you change one of the acids (e.g. change the first acid to adipic acid) and click on the Plot button, the plot remains unchanged.

@acer 

Many,many thanks.  As always, your replies are extremely helpful and much appreciated.  I consider myself as having had my wrist slapped for not following the advice previously given.

I will now study your changes and suggestions carefully and then implement them in my original document (I don't want to simply use the documents you have uploaded because I won't learn as much by doing that).

Thank you @dharr

I have changed with(plots) to uses plots as you suggested.  I am attaching my worksheet/document and a data file which is required (. Executing the worksheet displays the graph correctly.  Changing the acid in the dropdown and clicking the Plot button has no effect.  I know that clicking the Plot button is calling the calculate procedure because I tempoarily put a dialog in the procedure to demonstrate this (this has now been removed).

A:=Array(1) has been removed.  It used to be A:=Array(2) with A(1) being the first plot and A(2) being the second plot so that display(A) displayed the two plots side by side.

Dissociation_Constants.zip

V8_Calculation_of_pH_from_known_values_of_Vb_(Document).mw

@tomleslie 

Many thanks.

1 2 3 4 Page 2 of 4