WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: stevengraff on January 23, 2014, 05:08:45 AM

Title: Continuation character in WIL script
Post by: stevengraff on January 23, 2014, 05:08:45 AM
Is there a way to break up a statement onto multiple lines (for "readability"), but still have it interpreted as if it were on a single line?

Title: Re: Continuation character in WIL script
Post by: stanl on January 23, 2014, 07:49:46 AM
Define 'statement': do you mean a WB command, or something like an SQL statement that is 4-500 characters in length?
Title: Re: Continuation character in WIL script
Post by: snowsnowsnow on January 23, 2014, 07:55:46 AM
I assume we are talking about a statement in a WB program (Note to readers: THis is a WinBatch forum, not a SQL forum, not a VB forum, and not a C forum).

And, in that case, the answer is "No."

The question has come up before.
Title: Re: Continuation character in WIL script
Post by: stevengraff on January 23, 2014, 08:23:15 AM
OK; thanks.
Title: Re: Continuation character in WIL script
Post by: Deana on January 23, 2014, 09:14:04 AM
WinBatch doesn't offer a "line continuation" character.

One technique is dealing with really long strings of data is to use the string concatenation operator to build a long string yet, still display the data so that it is readable.
Code (winbatch) Select
str = '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'
str = str: '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'
str = str:  '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'
Title: Re: Continuation character in WIL script
Post by: stanl on January 23, 2014, 10:06:40 AM
also useful if writing WB scripts using COM/CLR and talking to database tables with SQL [even though this is not a SQL Forum]

Code (WINBATCH) Select


cSQL='SELECT myfirstcolumn, mysecondcolumn, mythirdcolumn, myfourthcolumn, myfifthcolumn '
cSQL=cSQL:'mysixthcolumn,myseventhcolumn,myeighthcolumn,myninethcolumn,mycolumnthirty '
cSQL=cSQL:'FROM myfirsttable WHERE myeleventhcolumn="some value";'
;;;;.....
oConn.Execute(cSQL)
Title: Re: Continuation character in WIL script
Post by: stevengraff on January 24, 2014, 12:50:48 PM
Thanks; I've done that before. You're right, it's very usefull.
Title: Re: Continuation character in WIL script
Post by: DAG_P6 on January 25, 2014, 10:58:24 AM
Another place in which line continuation characters are extremely useful is in calls to functions that have long argument lists. Better yet would be the ability to insert line comments, as is often done in C and C++ code. I have seen, and written such calls that make good use of such inline comments to list the parameter names as they appear in the C/C++ header file in which the function is declared. This can be very handy when you think the actual arguments are out of order.

BTW, I know this isn't a C/C++ forum, but that doesn't preclude borrowing ideas from other languages, including C and C++, bearing in mind that the mere presence of a feature doesn't mean that everyone must use it.
Title: Re: Continuation character in WIL script
Post by: MiloradM on June 01, 2018, 02:05:33 AM
I know this is old post, but I am new in WinBatch and I very miss possibility of splitting program lines into multiple lines.

Every programming language I know (except old Fortran, I think) have this possibility (I did work on more than 15 languages), and now I call WinBatch authors to implement such feature in their very good and useful product.

Or, maybe that feature was already implemented from last post in this theme?
Title: Re: Continuation character in WIL script
Post by: stanl on June 01, 2018, 05:15:51 AM
There was a more recent thread about this where Jim asked about a StrCatEx() function and we discussed that versus delimiters, i.e. /* ..... */

And I believe Tony implemented something in WB, and I am sure he will chime in with how things turned out.
Title: Re: Continuation character in WIL script
Post by: kdmoyers on June 01, 2018, 06:44:35 AM
It's not really "line continuation" but there is this feature for long strings:
Code (winbatch) Select
HeaderText = $"
This program takes a quote number and produces an estimate of freight price for
various services, IF it can find sufficient historical examples to estimate from.
You can deselect items that are not part of the estimate.
$"

This works well for me, as all my cases of too-long statements are really cases
of too-long strings.