Re: passing FXArray by reference

Roland Hughes via Foxgui-users <[email protected]> Thu, 2 Oct 2025 05:04:06 -0500
Newsgroups gmane.comp.lib.fox-toolkit.user
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============0066522825088876783==
Content-Type: multipart/alternative;
 boundary="------------R20W5BjMJY62vYcJ6sUsKfi6"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------R20W5BjMJY62vYcJ6sUsKfi6
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Granted, I've never used Fox in production for anything, but, I do try 
to help out here from time to time.

Search::Search(const FXArray< Test >& testArray)

{

_testArray = testArray;

}

Unless I just got up too early:

 1. C++ developers are never supposed to declare variables that start
    with "_" because that is reserved for internal compiler and library
    things.
 2. That assignment statement in the above snippet is making a copy. If
    you pass by reference, there is no need to make a copy. Simply use
    the variable as if it were local.

*Note:* when passing a variable by reference (or pointer) any changes 
you make will be permanent. If you are trying to manipulate the data 
without making changes to the actual data, you /have/ to make copy.

*Note 2:* "very large" I know colleges have a really bad habit of 
teaching kids to do everything with arrays in memory, but large data 
needs to be in large storage. Sadly, they don't teach students to use 
databases. SQLite3 <https://sqlite.org/index.html> is free and available 
everywhere. I don't know if Fox has a front end for it or not. Yes, if 
you absolutely must, you can make in-memory databases instead of ones on 
disk.

SELECT FROM WHERE <https://www.sqlitetutorial.net/sqlite-where/>.  You 
can even ORDER BY.

I'm old, so I hate re-inventing the wheel.



On 10/1/2025 7:45 PM, John Selverian wrote:
>
> I’m currently passing an FXArray by value. I’d like to pass it by 
> reference since it is very large but I can’t seem to get it right.
>
> In my main program I declare it like this:
>
> FXArray<Test> _testArrayMain;
>
> And I pass it like this:
>
> Search search (_testArrayMain);
>
> In the routine I’m passing it to I have this:
>
> In the header:
>
> FXArray<Test> _testArray;
>
> Search (const FXArray< Test >&);
>
> In the source:
>
> Search::Search(const FXArray< Test >& testArray)
>
> {
>
> _testArray = testArray;
>
> }
>
> It gets passed fine but it takes awhile since it is so big. I’ve tried 
> many different ways but I always get many compiler errors.
>
> How would I pass it by reference?
>
> Kind regards,
>
> js
>
>
>
> _______________________________________________
> Foxgui-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/foxgui-users

-- 
Roland Hughes, President
Logikal Solutions
(630)-205-1593  (cell)
https://theminimumyouneedtoknow.com
https://infiniteexposure.net
https://johnsmith-book.com

--------------R20W5BjMJY62vYcJ6sUsKfi6
Content-Type: multipart/related;
 boundary="------------ghWYdgGAtAqBTBziwl98x5fu"

--------------ghWYdgGAtAqBTBziwl98x5fu
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Granted, I've never used Fox in production for anything, but, I
      do try to help out here from time to time.</p>
    <pre class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><a class="moz-txt-link-freetext" href="Search::Search(const">Search::Search(const</a> FXArray&lt; Test &gt;&amp; testArray)</span></pre>
    <pre class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">{</span></pre>
    <pre class="MsoNormal" style="text-indent:.5in"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">_testArray = testArray;</span></pre>
    <pre><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">}</span></pre>
    <p><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">Unless
        I just got up too early:</span></p>
    <ol>
      <li>C++ developers are never supposed to declare variables that
        start with "_" because that is reserved for internal compiler
        and library things.</li>
      <li>That assignment statement in the above snippet is making a
        copy. If you pass by reference, there is no need to make a copy.
        Simply use the variable as if it were local. <br>
      </li>
    </ol>
    <p><b>Note:</b> when passing a variable by reference (or pointer)
      any changes you make will be permanent. If you are trying to
      manipulate the data without making changes to the actual data, you
      <i>have</i> to make copy.<br>
    </p>
    <p><b>Note 2:</b> "very large" I know colleges have a really bad
      habit of teaching kids to do everything with arrays in memory, but
      large data needs to be in large storage. Sadly, they don't teach
      students to use databases. <a
        href="https://sqlite.org/index.html">SQLite3</a> is free and
      available everywhere. I don't know if Fox has a front end for it
      or not. Yes, if you absolutely must, you can make in-memory
      databases instead of ones on disk.</p>
    <p><a href="https://www.sqlitetutorial.net/sqlite-where/">SELECT
        FROM WHERE</a>.  You can even ORDER BY.</p>
    <p>I'm old, so I hate re-inventing the wheel.<br>
    </p>
    <p><br>
    </p>
    <p><br>
    </p>
    <p></p>
    <div class="moz-cite-prefix">On 10/1/2025 7:45 PM, John Selverian
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:[email protected]">
      <meta name="Microsoft Theme 2.00" content="Concrete 011">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator"
        content="Microsoft Word 15 (filtered medium)">
      <style>@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
	{font-family:Verdana;
	panose-1:2 11 6 4 3 5 4 4 2 4;}@font-face
	{font-family:Aptos;}p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	font-size:12.0pt;
	font-family:"Verdana",sans-serif;
	color:#434343;
	mso-ligatures:standardcontextual;}span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Aptos",serif;
	color:windowtext;}.MsoChpDefault
	{mso-style-type:export-only;}div.WordSection1
	{page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--><img
        src="cid:[email protected]"
v:src="imap://roland%40logikalsolutions%[email protected]:993/fetch%3EUID%3E.INBOX%3E293965?header=quotebody&amp;part=1.1.2&amp;filename=image001.gif"
        v:shapes="_x0000_Mail" class="shape"
        style="display:none;width:0;height:0" width="0" height="0"><!--[if gte mso 9]><xml>
<v:background id="_x0000_s1025" o:bwmode="white" o:targetscreensize="1024,768">
<v:fill src="imap://roland%40logikalsolutions%[email protected]:993/fetch%3EUID%3E.INBOX%3E293965?header=quotebody&part=1.1.2&filename=image001.gif" o:title="background_concrete" type="frame" />
</v:background></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">I’m
            currently passing an FXArray by value. I’d like to pass it
            by reference since it is very large but I can’t seem to get
            it right.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">In
            my main program I declare it like this:<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">               
            FXArray&lt;Test&gt; _testArrayMain;<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">And
            I pass it like this:<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal" style="text-indent:.5in"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">Search
            search (_testArrayMain);<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">In
            the routine I’m passing it to I have this:<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">In
            the header:<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">FXArray&lt;Test&gt;
            _testArray;<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">Search
            (const FXArray&lt; Test &gt;&amp;);<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">In
            the source:<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><a class="moz-txt-link-freetext" href="Search::Search(const">Search::Search(const</a>
            FXArray&lt; Test &gt;&amp; testArray)<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">{<o:p></o:p></span></p>
        <p class="MsoNormal" style="text-indent:.5in"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">_testArray
            = testArray;<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">}<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">It
            gets passed fine but it takes awhile since it is so big.
            I’ve tried many different ways but I always get many
            compiler errors.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext">How
            would I pass it by reference?<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext;mso-ligatures:none">Kind
            regards,<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext;mso-ligatures:none"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:&quot;Aptos&quot;,serif;color:windowtext;mso-ligatures:none">js<o:p></o:p></span></p>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
Foxgui-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
<a class="moz-txt-link-freetext" href="https://lists.sourceforge.net/lists/listinfo/foxgui-users">https://lists.sourceforge.net/lists/listinfo/foxgui-users</a>
</pre>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Roland Hughes, President
Logikal Solutions
(630)-205-1593  (cell)
<a class="moz-txt-link-freetext" href="https://theminimumyouneedtoknow.com">https://theminimumyouneedtoknow.com</a>
<a class="moz-txt-link-freetext" href="https://infiniteexposure.net">https://infiniteexposure.net</a>
<a class="moz-txt-link-freetext" href="https://johnsmith-book.com">https://johnsmith-book.com</a></pre>
  </body>
</html>
--------------ghWYdgGAtAqBTBziwl98x5fu
Content-Type: image/gif; name="image001.gif"
Content-Disposition: inline; filename="image001.gif"
Content-Id: <[email protected]>
Content-Transfer-Encoding: base64

R0lGODlhHwAfAIAAAODg4AAAACH5BAAAAAAALAAAAAAfAB8AAAIdhI+py+0Po5y02ouz3rz7
D4biSJbmiabqyrbuOxUAOw==

--------------ghWYdgGAtAqBTBziwl98x5fu--

--------------R20W5BjMJY62vYcJ6sUsKfi6--


--===============0066522825088876783==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============0066522825088876783==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Foxgui-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/foxgui-users

--===============0066522825088876783==--