Discussions related to Visual Prolog
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

How can I limit the length of source lines?

Unread post by Ferenc Nagy »

Hi,
How can parametrize the editor of the VIP frame system in order to break the lines automatically at the 72th or 80th character?
TIA, Regards,
Frank Nagy
Peter Muraya
VIP Member
Posts: 147
Joined: 5 Dec 2012 7:29

Unread post by Peter Muraya »

Hello Nancy,
I find that such a feature would be more helpful for organizing long comments than for breaking the actual source code. Consider the sample code below. The actual Prolog code statements are generally short; comments can be rather long and mine tend to be. Without a "word wrapping" facility I use the traditional hard return method.

Code: Select all

/*     Perform integration of expressions using the given metadata structure as the starting point.     The integration is carried out in a number of growth phases that are modelled along the lines     of natural biological reproduction and human social interactions*/     perform(Metadata, _Dbase):-           /*           Transform the metadata to a mutall\model via a series of assignment-type of transformations, leading           to a globally available pool of Mutall modellings, i.e., relations, attributes, garmetes and undescribed           data*/           assign::perform(Metadata),           /*           Generate user defined attributes by translating keywords into entities and attributes*/           translation::new():run(),           /*           Generate attributes by integrating e_stores (as vacancies) with a-stores (as candidates)           What  is the rationale of the close similarities between self a- and e- transplant?           This is because partial e- and a- stores are specified by the user independently. So,           they are treated independently.*/           transplant::new():run(),           /*           Defaulting:Add default attribute names and titles to the attributes database. Make sure the           defaults are evaluated. Note, that there very strong reasons for placing it here: it must           have access to evaluated normalized attributes (for what?)*/           defaulting::new():run(), etc.
Mutall Data Management Technical Support
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

We plan to implement an auto-formatting feature in the next release. It will however not change comments, because comments can contain many other things than plain text. Very often they contain code, sometimes table material, etc.

The formatting program will be a demo program, the IDE will use it with a fixed (non-customizable) with (which is much higher than 72-80 characters). But it can be called on the comment line (or as an IDE tool) with a different line width.

72-80 characters is far too little on modern screens and using Verdana which is a proportional font.
Regards Thomas Linder Puls
PDC
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

Screen line width and print line length

Unread post by Ferenc Nagy »

Thomas,
72-80 characters is far too little on modern screens and using Verdana which is a proportional font.
It is true as long as the source windows are not tiled horizontally.
In case of printed source code the limit set to 72-80 characters is strict for portrait pages.

Related question:
Let's suppose that yo have a long error explanation string (or a format string containing percent signs) exceeding the prefixed line width thrice. How would you split this string?
TIA, Regards,
Frank Nagy
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

If you have long string literals, I suggest you define them as constants in stead of writing them inside the clause.

Furthermore, string literals can be written in parts:

Code: Select all

constants     long : string =       "long string .....".   constants     long : string =       "part 1 ....."       "part 2 ....."       ...       "last part .....".
Regards Thomas Linder Puls
PDC
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

Nice undocumented feature

Unread post by Ferenc Nagy »

Thank you, Thomas.
Ugly

Code: Select all

 provideCustomTooltip(finish_but,idi_task_complete,"Finish button",             "This button invokes\nthe validition of the fields of the dialog,\nthen the storage of the entered data,\nit finally closes the dialog."),          
Split

Code: Select all

provideCustomTooltip(finish_but,idi_task_complete,"Finish button",             "This button invokes\nthe validition of the fields of the dialog,\n"             "then the storage of the entered data\n"             "it finally closes the dialog."),      
Is the trick of splitting strings among lines documented in the ordinary help files?
TIA, Regards,
Frank Nagy
Peter Muraya
VIP Member
Posts: 147
Joined: 5 Dec 2012 7:29

Unread post by Peter Muraya »

Hello Nancy,
In case of printed source code the limit set to 72-80 characters is strict for portrait pages.
I have not printed my code for a long time. The only situation I see printing necessary is as sample code in a printed document. When else would you really want to print code?
Mutall Data Management Technical Support
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Re: Nice undocumented feature

Unread post by Thomas Linder Puls »

Ferenc Nagy wrote:Is the trick of splitting strings among lines documented in the ordinary help files?
Yes, it is the first line of Language Reference/Lexical Elements#String Literals: A string literal consists of one or more StringLiteralPart's, which are concatenated.

But there are no examples or the like, so it is easy to miss.
Regards Thomas Linder Puls
PDC
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

The next version ought to emphasize the string literal parts

Unread post by Ferenc Nagy »

Thomas,
Quote from the link in Thomas' answer:
String Literals

StringLiteral:
StringLiteralPart-list

StringLiteralPart:
' <CharacterValue>-list-opt '
" <CharacterValue>-list-opt "
@AtOpenChar AnyCharacter-list-opt AtCloseChar

A string literal consists of one or more StringLiteralPart's, which are concatenated.
The last sentence is very important. The next version ought to emphasize it:
"The splitting of StringLiteral-s into StringLiteralPart-s
1) Make your long string literals much more readable.
2) If you have both single and double quotes in your string literals then we recommend to break them into parts.
Example

Code: Select all

StringLiteralPart:    ' blah-blah " containing only " double quote(s) '    "sermon 'containing only single  quote(s) ".
TIA, Regards,
Frank Nagy
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

Re:

Unread post by Ferenc Nagy »

Peter Muraya wrote:Hello Nancy,
Peter,
I am not Nancy but Francis, Frank, Ferenc as you like it.
I have not printed my code for a long time. The only situation I see printing necessary is as sample code in a printed document. When else would you really want to print code?
Indeed the programs are so long that we cannot carry home their printed versions.
Printing means wasting paper since soon after we change a single line any printout becomes outdated.

However the human eye is has been better adapted to the proofreading during the 5000 years from paper than since 50 years of screens. The computers drive us to change a single error and rebuild the whole project. Sometimes I must take a breath, leave alone the computer and investigate the buggy part of my program on paper. I used to call it the effect of bus #90. When I used to find the bugs so long in the KFKI at the Western border of Budapest http://www.kfki.hu/?language=en that last special bus had gone and I had to commute home by the rare #90 I opened the fold-out and - HEUREKA - I have found HERE LIES THE RUB!
TIA, Regards,
Frank Nagy
Peter Muraya
VIP Member
Posts: 147
Joined: 5 Dec 2012 7:29

Unread post by Peter Muraya »

Frank, sorry for the misspelling.
And thanks for link to the KFKI website. The google translation to English of some of the the pages helped me to follow them quite easily.

I take your point about debugging from a printed copy. I too have been on that road but laptops have changed my habit quite a bit.

And the the mixing of single quotes and double quotes in a split string ... well that is something new to me. Thanks.
Mutall Data Management Technical Support
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

KFKI

Unread post by Ferenc Nagy »

Peter,
Have not you seen the Union Jack in the upper left corner on the webpage of the KFKI = Central Resource Institute of Physics? Click on that to get the Englsih version. I suppose there are less funny mis-transtations than the Google is making.

KFKI = a big campus. It is no longer a centralized dynosaur. You can see 52 firm names on copper plates in its gate. My workspace used to be the Institute of Isotopes http://www.iki.kfki.hu/departments/index_en.shtml, namely
Radioactive Material Registry Section

Center registry of radioactive materials in Hungary with a dedicated computer system.
Software development for the central registry.
TIA, Regards,
Frank Nagy
User avatar
Ferenc Nagy
VIP Member
Posts: 215
Joined: 24 Apr 2007 12:26

Regex.htm

Unread post by Ferenc Nagy »

Thomas,
I could collect the long strings from my program. The Find in Files dialog permits regular expressions.
The file .... \pfc\regEx\packRegEx.htm contains an usable help about their syntax.
The pattern
".{40,200}"
is a good choice. This pattern means in plain English
= Look for strings enclosed by double quotes containing at least 40 at most 200 arbitrary characters among them.
The pattern needs correction to discard the lists of short quoted words like:
"apple", "banana", "cucumber", "donut"
.
TIA, Regards,
Frank Nagy
Post Reply