Autore Topic: Carattere di continuazione di riga nel codice  (Letto 334 volte)

Offline vuott

  • Moderatore globale
  • Senatore Gambero
  • *****
  • Post: 11.302
  • Ne mors quidem nos iunget
    • Mostra profilo
Carattere di continuazione di riga nel codice
« il: 07 Dicembre 2013, 00:01:09 »
Vi riporto questa discussione apparsa nella M.L. ufficiale:


" Is there a line continuation character available for code? I find that I
often have very long lines (e.g. in Exec commands).

John Rose
"


" There is no line continuation character, but you usually can go to
another line inside an expression after a comma.

Regards,

--
Benoît Minisini
"


"  I agree with John, Benoît.  There really should be a specific character to
continue a line; if only to keep from confusing anyone maintaining the code.  Put it on the 'nice to have' list, anyway.

Bill
"


" If you are using SHELL, you can assign lines to variables.  If the string
continues on multiple lines, assign the text to string variables, and
concatenate those variables.
The example below merely shows SHELL accepting a string variable as its
command string:

DIM sRes as String
DIM shellString as String

  shellString = "cat /proc/meminfo"
  Shell shellString To sRes

If you use EXEC, the flexibility is more limited, as the command cannot be
contained in a variable, but the following will work:

DIM execString as String
DIM sRes as String
  execString = "/proc/meminfo"
  Exec ["cat", execString] To sRes

MinnesotaJon
"
« Ultima modifica: 07 Dicembre 2013, 20:26:48 da vuott »
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »

Offline Top Fuel

  • Gran Maestro dei Gamberi
  • *****
  • Post: 960
    • Mostra profilo
Re: Carattere di continuazione di riga nel codice
« Risposta #1 il: 08 Dicembre 2013, 17:54:57 »
Beh, le linee sono talmente lunghe che voglio vedere come fai a riempirle... :D
Dear youtube administrators, your search bar is broken. When I type the letter "J" it appears justin bieber when it should appear Jimi Hendrix. Fix this, please.

Offline vuott

  • Moderatore globale
  • Senatore Gambero
  • *****
  • Post: 11.302
  • Ne mors quidem nos iunget
    • Mostra profilo
Re: Carattere di continuazione di riga nel codice
« Risposta #2 il: 08 Dicembre 2013, 23:45:10 »
...continua...


" Of course, it can:
Codice: gambas [Seleziona]
Dim aExec As String[]
Dim sRes As String

aExec = ["cat", "/proc/meminfo"]
' Use aExec.Add() to add more arguments
Exec aExec To sRes


Tobias Boege "
« Chiunque, non ricorrendo lo stato di necessità, nel proprio progetto Gambas fa uso delle istruzioni Shell o Exec, è punito con la sanzione pecuniaria da euro 20,00 a euro 60,00. »