You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: EidosScribe/EidosHelpFunctions.rtf
+18Lines changed: 18 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -6686,6 +6686,24 @@ The task keys recognized, and the tasks they govern, are:\
6686
6686
\f3\fs20\cf2 Typically, a dictionary of task keys and thread counts is read from a file and set up with this function at initialization time, but it is also possible to change new task thread counts dynamically. If Eidos is not configured to run multithreaded, this function has no effect.\
\f0\b\fs20\cf2 Reads a line of input from the \'93standard input\'94 file.
6693
+
\f3\b0 This function is intended to allow for communication between a running Eidos script (such as a SLiM simulation) and an external process that is sending input to it. It reads one line from the standard input and returns it as a singleton
6694
+
\f1\fs18 string
6695
+
\f3\fs20 . This is done with the C++ function
6696
+
\f1\fs18 std::getline()
6697
+
\f3\fs20 , using the
6698
+
\f1\fs18 std::cin
6699
+
\f3\fs20 file. If that call returns false (typically because the end-of-file was reached or there was a read error of some kind), the empty string
6700
+
\f1\fs18 ""
6701
+
\f3\fs20 will be returned. The
6702
+
\f1\fs18 system()
6703
+
\f3\fs20 function can also be helpful for related situations.\
6704
+
This function will raise an error if called in a GUI environment such as EidosScribe, SLiMgui, or SLiMguiLegacy, since there is no standard input set up for the running script in those environments.\
"SURVIVAL"<spanclass="Apple-tab-span"></span></span>survival evaluation (no callbacks)</p>
650
650
<pclass="p5">Typically, a dictionary of task keys and thread counts is read from a file and set up with this function at initialization time, but it is also possible to change new task thread counts dynamically.<spanclass="Apple-converted-space"></span>If Eidos is not configured to run multithreaded, this function has no effect.</p>
651
+
<pclass="p4">(string$)readLine(void)</p>
652
+
<pclass="p5"><b>Reads a line of input from the “standard input” file.</b><spanclass="Apple-converted-space"></span>This function is intended to allow for communication between a running Eidos script (such as a SLiM simulation) and an external process that is sending input to it.<spanclass="Apple-converted-space"></span>It reads one line from the standard input and returns it as a singleton <spanclass="s2">string</span>.<spanclass="Apple-converted-space"></span>This is done with the C++ function <spanclass="s2">std::getline()</span>, using the <spanclass="s2">std::cin</span> file.<spanclass="Apple-converted-space"></span>If that call returns false (typically because the end-of-file was reached or there was a read error of some kind), the empty string <spanclass="s2">""</span> will be returned.<spanclass="Apple-converted-space"></span>The <spanclass="s2">system()</span> function can also be helpful for related situations.</p>
653
+
<pclass="p5">This function will raise an error if called in a GUI environment such as EidosScribe, SLiMgui, or SLiMguiLegacy, since there is no standard input set up for the running script in those environments.</p>
<pclass="p5"><b>Removes variables</b> from the Eidos namespace; in other words, it causes the variables to become undefined.<spanclass="Apple-converted-space"></span>Variables are specified by their <spanclass="s2">string</span> name in the <spanclass="s2">variableNames</span> parameter.<spanclass="Apple-converted-space"></span>If the optional <spanclass="s2">variableNames</span> parameter is <spanclass="s2">NULL</span> (the default), <i>all</i> variables will be removed (be careful!).</p>
653
656
<pclass="p5">In SLiM 3, there was an optional parameter <spanclass="s2">removeConstants</span> that, if <spanclass="s2">T</span>, allowed you to remove defined constants (and then potentially redefine them to have a different value).<spanclass="Apple-converted-space"></span>The <spanclass="s2">removeConstants</span> parameter was removed in SLiM 4, since the <spanclass="s2">defineGlobal()</span> function now provides the ability to define (and redefine) global variables that are not constant.</p>
Copy file name to clipboardExpand all lines: VERSIONS
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,8 @@ development head (in the master branch):
18
18
add the PCG random number generator, switch to pcg32_fast and pcg64_fast, remove all use of the old taus2 and MT19937-64 generators; note this completely breaks backward reproducibility
19
19
fix various bugs involving conflicts between defined constants and other symbols, including #573 and #574; this sets new definition rules that could break some existing scripts (but is unlikely to)
20
20
fix #575, QtSLiM terminates early when single-stepping with a rescheduled script block
21
-
----- last merge into multitrait was done here
21
+
fix #579, crash in models with (a) tree-seq recording, (b) multiple chromosomes, AND (c) rejection of proposed offspring in modifyChild()
22
+
add readLine() function for obtaining stdin input to running models, thanks to Chris Talbot
// BCH 12/1/2025: In the multichrom case we need to protect against a segfault inside
5856
+
// tsk_table_collection_truncate() for the secondary table collections. This is because
5857
+
// they have NULL for their various column pointers, and tsk_table_collection_truncate()
5858
+
// accesses index 0 of every offset column to get the offset for row 0. (It is always
5859
+
// for row 0 in the shared tables because they are zeroed out; their num_rows was zero
5860
+
// in RecordTablePosition().) See https://github.com/MesserLab/SLiM/issues/579 for details.
5861
+
// BEWARE: This code will need updating if new shared tables are added, or new columns
5862
+
// are added within the existing shared table. Any offset column that is accessed in the
5863
+
// ..._truncate() functions for the shared tables needs to be protected here.
5864
+
tsk_size_t zero_value = 0;
5865
+
tsk_size_t *pointer_to_zero_value = &zero_value;
5866
+
5867
+
for (size_t trees_index = 1; trees_index < trees_count; ++trees_index)
5868
+
{
5869
+
TreeSeqInfo &tsinfo_i = treeseq_[trees_index];
5870
+
5871
+
#if DEBUG
5872
+
// This protection scheme relies upon the bookmarked row being zero for shared tables;
5873
+
// only the zeroth element of each offset column is set up by the hack here.
5874
+
if ((tsinfo_i.table_position_.nodes != 0) ||
5875
+
(tsinfo_i.table_position_.individuals != 0) ||
5876
+
(tsinfo_i.table_position_.populations != 0))
5877
+
EIDOS_TERMINATION << "ERROR (Species::RetractNewIndividual): (internal error) tree sequence bookmark for a shared table in a secondary table collection is non-zero." << EidosTerminate();
// This function was implemented by Chris Talbot 11/19/25 for use in reinforcement learning environments.
231
+
// Associated with issue #576.
232
+
233
+
#ifdef EIDOS_GUI
234
+
// Cannot be called inside a GUI since there is (presumably) no stdin set up for the script to read.
235
+
EIDOS_TERMINATION << "ERROR (Eidos_ExecuteFunction_readLine): function readLine() is not available in GUI environments (SLiMgui, SLiMguiLegacy, or EidosScribe)." << EidosTerminate(nullptr);
236
+
#else
237
+
// Read a single line from stdin (command-line mode with interactive terminal)
238
+
std::string line;
239
+
240
+
if (std::getline(std::cin, line))
241
+
{
242
+
// Control for CRLF vs. LF line endings
243
+
if (!line.empty() && line[line.size() - 1] == '\r')
0 commit comments