Hello Federico,

Sorry if this answer breaks the thread (despite you have forwarded your initial 
message to me with its full header. Thanks):

Le 21/12/2022 à 03:15, Federico Miyara a écrit :

Dear All,

I have to create a vector from a plain text containing about 700 decimal 
numbers, each one with several digits. The total character count incuding 
spaces is about 5700, so when I run this command I get the following error:

"Command is too long (more than 4096 characters long): could not send it to 
Scilab"

Is there a simple way to do this other than splitting the text into two parts, 
each one with less than 4096 digits and then concatenating the vectors, or 
saving the data as a text file and reading the file into a string variable and 
converting to numbers?

Thanks,

Federico Miyara

Federico 
Miyara<https://www.mail-archive.com/search?l=users@lists.scilab.org&q=from:%22Federico+Miyara%22>
 Thu, 17 Nov 2022 13:22:08 
-0800<https://www.mail-archive.com/search?l=users@lists.scilab.org&q=date:20221117>

Christopher,

Yes, you understand correctly my case.



There is a reason that justifies my request: I often use my scripts as examples 
within a didactic context. They are exhaustively commented, for instance. I 
consider it preferable to have all the needed data in the same script since I 
cannot be sure that potential future users who find my script will also find 
the associated file with the data (sometimes one downloads a file for future 
use without checking whether we are downloading all the associated files).Then 
they should also change the script according to the particular directory tree 
where they choose to place the data, which is an unnecessary distraction from 
the very point of the example.I agree that it wouldn't be convenient nor 
practical to work in this way with very large data sets, but some 1000 data is 
not unusual.

Regards,

Federico Miyara


I fully understand and share your concern.

I noticeably encountered a similar situation and requirement during last summer, to build 
some Scilab tests applied to some "passive extra content".
In the PHP language (that kept me busy for ~9000 hours in another life), i 
remembered some ob_start(..) .... ob_end(..) instructions: In a PHP script, all 
multi-line contents lying between these two statements are send to a buffer, 
instead of being executed.
Then for instance it is possible to get this content in a string array, with 
$myarray = ob_get_contents().

For Scilab, a similar feature can be implemented by putting the "passive 
content" in a /* multiline block of comments */.
Thus, i have implemented a get_blockcomment() function to read some 
block-comment in the Scilab script being currently executed.

The supported syntaxes are:
r = get_blockcomment() : reads and returns the next block-comment following 
this call.
r = get_blockcomment(n) : reads and returns the nth block-comment of the 
current file.
with r: column of text
Option doEval (boolean): evaluates the content and returns the results e 
instead of it:
e = get_blockcomment( , %t)
e = get_blockcomment(n, %t)

If no block-comment can be read, [] is returned.
The unitary tests file of this function is attached.

This function was first implemented as an internal one.
But afterwards, like you, i've thought that it is a general usage function, and 
indeed i use it as well in other contexts.

I think it would be useful in Scilab.  Would this be right?
Maybe its name could be improved.

Best regards
Samuel


This email and any attachments are intended solely for the use of the 
individual or entity to whom it is addressed and may be confidential and/or 
privileged.

If you are not one of the named recipients or have received this email in error,

(i) you should not read, disclose, or copy it,

(ii) please notify sender of your receipt by reply email and delete this email 
and all attachments,

(iii) Dassault Systèmes does not accept or assume any liability or 
responsibility for any use of or reliance on this email.


Please be informed that your personal data are processed according to our data 
privacy policy as described on our website. Should you have any questions 
related to personal data protection, please contact 3DS Data Protection Officer 
https://www.3ds.com/privacy-policy/contact/

// =============================================================================
// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
// Copyright (C) 2023 - Le Mans Université - Samuel GOUGEON
//
//  This file is distributed under the same license as the Scilab package.
// =============================================================================
// <-- CLI SHELL MODE -->
// <-- NO CHECK REF -->
// <-- ENGLISH IMPOSED -->

// Unitary tests of get_blockcomments()
// ------------------------------------
/* First block comment:
 -4 -5 -6  1  9  9  6  2
  6 -1  7  1  2  7 -6 -2
*/
// Read the next block-comment following this call:
r = get_blockcomment();
ref = [ ""
        "  3  8  2 -2  0 -7  2  9   // first row"
        "       "
        "  8 -2  8 -8 -5 -2  7  6   // second row"
        "  0 -2  7 -6 -5 -8  7 -9"];
assert_checkequal(r, ref);

// Read the first block-comment of the current file
r = get_blockcomment(1);
ref = [ " -4 -5 -6  1  9  9  6  2"
        "  6 -1  7  1  2  7 -6 -2"];
assert_checkequal(r, ref);

// Read the first block-comment of the current file and evaluate it:
r = get_blockcomment(1, %t);
ref = [ -4 -5 -6  1  9  9  6  2
         6 -1  7  1  2  7 -6 -2];
assert_checkequal(r, ref);

// Read the next block-comment following this call, and evaluate it:
// Empty or blank lines and appended comments are ignored
r = get_blockcomment(,%t);
ref = [3  8  2 -2  0 -7  2  9
       8 -2  8 -8 -5 -2  7  6
       0 -2  7 -6 -5 -8  7 -9 ];
assert_checkequal(r, ref);

/* Second one:

  3  8  2 -2  0 -7  2  9   // first row
       
  8 -2  8 -8 -5 -2  7  6   // second row
  0 -2  7 -6 -5 -8  7 -9
*/

// Inexisting block
assert_checkequal(get_blockcomment(10), []);

// ERRORS
// ------
// Continuation marks .. are not supported in evaluated blocks
msgref = "evstr: Argument #1: Some expression can''t be evaluated (%val=[[  3  
8  2 -2  0 -7  2  9 ..];                                  ^^Error: Unexpected 
token '']'' after line break with .. or ...)."
assert_checkerror("get_blockcomment(,%t)", msgref);

/* Third block with continuation marks:
  3  8  2 -2  0 -7  2  9 ..
  8 -2  8 -8 -5 -2  7  6
*/

// No following block
assert_checkequal(get_blockcomment(), []);
_______________________________________________
users mailing list - users@lists.scilab.org
Click here to unsubscribe: <mailto:users-unsubscr...@lists.scilab.org>
https://lists.scilab.org/mailman/listinfo/users

Reply via email to