[nsbasic-ce] Re: Array assignment question

2008-10-08 Thread tomnew2003
--- In [EMAIL PROTECTED], "Chris Kenworthy"
<[EMAIL PROTECTED]> wrote:
>
> I have to say that you lost me at this point. dataFromWinsock is a 
> string variable, but ArrayA is indeed an array. That's clearly stated 
> in the Split function documentation. Now, you could save a copy of 
> dataFromWinsock and split it into another array, instead of saving a 
> copy of ArrayA, but that's not what you were saying.
>

Yes, you're correct that SPLIT creates an array of "String" variables
by parsing the original string data, so my statement about it not
being an array was wrong. My main point still applies about being able
to copy the content of one string variable to another by an assignment
statement (=). This applies to both string variables and  array of
string variables.

My other point was that arrays of other data types (integers, longs,
single, double, etc.) don't allow you to copy the content by a simple
assignment statement.

Sorry for the confusion (it was late when I wrong my response last
night :)

-Tom



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"nsb-ce" group.
To post to this group, send email to nsb-ce@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nsb-ce?hl=en
-~--~~~~--~~--~--~---



[nsbasic-ce] Re: Array assignment question

2008-10-07 Thread tomnew2003
Edgard,

In reviewing your problem again I noticed that you are using the SPLIT
command in your sample function to parse the WinSock data. That
implies you are dealing with a string and not bytes, integers, longs, etc.
Your line,
 ArrayA = SPLIT(dataFromWinsock,'|')
makes ArrayA a string variable and not an array (but you could create
an array of strings). Since it's a string variable you can make a copy
of the data by simply assigning it to another variable, which then
becomes a string variable. You could think of a String variable as a
buffer for ASCII data.

For example:
Dim String1, String2
String1 = "my winsock data"
String2 = String1  ' copy the data
String1 = ""   ' Clear the first string

Here an example of creating an array of string variables:
Dim Strings(4) ' Create an array to store 4 strings
Strings(0) = "my winsock data"
Strings(1) = Strings(0)  ' copy the data
Strings(0) = ""  ' Clear the first string

The above examples will NOT work with array of bytes, integers, longs,
etc. (The SPLIT command only works with string data.) The type of data
that you are dealing with determines how you have to handle the data.
If you are calling an external API with a byte or integer array, you
will get back an array that contains data that you can only access
using an array index.

To address Bob's comments, I think your example assumes you have data
available to store into the two arrays while it's being received. My
assumption was a WinSock API was called and an array returned
containing the data and that is what was needed to be transferred or
duplicated to another array.

As a side note, all my work with Declare/API calls dealing with
variables and arrays is with NS Basic Desktop, but I'm assuming it
also applies to CE too. Can anyone let me know if this is the correct
assumption?

Regards,
Tom

--- In [EMAIL PROTECTED], "Bob Katayama" <[EMAIL PROTECTED]> wrote:
>
> Seems to you what you are trying achieve is what a buffer does,
meaning a
> temporary storage.
> 
>  
> 
> This is how a buffer works.
> 
> Open data.
> 
> Data=A(X)
> 
> Data=B(X)
> 
> A stays intact and B is used to be manipulated.
> 
>  
> 
> This way there is no need to rename an array or transfer from one
array to
> another. Just create 2 or more different arrays as the data is received.
> 
> Data in Array A is used just to verify the information in B is correct
> before manipulation or compared to after manipulation..
> 
>  
> 
> Thus:
> 
>  
> 
> Data IN - IN represent how many data points.
> 
> TEMP - TEMP is smaller size< total number of data points.
> 
>  
> 
> Beginning
> 
> If IN =END of data then go to finished.
> 
> Otherwise do Function
> 
>  
> 
> Function
> 
> ArrayA(X) = IN
> 
> ARRAYB(X) = IN
> 
> Do whatever to B so that the end results in the value of B is changed.
> 
> Then you can compare the value of B to A whenever you need to.
> 
> Loop back to beginning
> 
>  
> 
> This allows for example ArrayA(15) to stay as the data received and
> ARRAYB(15) to represent ARRAYA(15) in its changed state
> 
>  
> 
> The other way is a 3 dimensional array where you have ARRAYA(X,0) and
> ARRAYA(X,1)
> 
> ARRAYA(X,0) represents original data received.
> 
> ARRAYA(X,1) represents the changed data.
> 
>  
> 
> Since you have the original data and the changed data contained in two
> single arrays or one 3D array that there is no copying required.
> 
> Hope this makes sense and helps you.
> 
>  
> 
> Bob
> 
>  
> 
>  
> 
>  
> 
>  
> 
> I believe this is what you are looking for.
> 
>  
> 
> Bob
> 
>  
> 
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On
> Behalf Of tomnew2003
> Sent: Tuesday, October 07, 2008 2:29 PM
> To: [EMAIL PROTECTED]
> Subject: [nsbasic-ce] Re: Array assignment question
> 
>  
> 
> Arrays are not objects and from my understanding of how variables and
> arrays are constructed, you cannot assign one array to another in
> order to copy the contents of the array. I believe you will need to
> create a routine that copies the content of the array, one element at
> a time.
> 
> If your intent is to always read Winsock data into the same named
> array and transfer that to an array with a different name without
> needing the data in the original array, I think that can be done. You
> can use some external API functions to change an internal variable
> pointer to switch the array buffer from one variable to another. I
> haven't tried this myself but I think it's possible but it requires an
> understanding of how variables are constructed 

[nsbasic-ce] Re: Array assignment question

2008-10-07 Thread tomnew2003
Arrays are not objects and from my understanding of how variables and
arrays are constructed, you cannot assign one array to another in
order to copy the contents of the array. I believe you will need to
create a routine that copies the content of the array, one element at
a time.

If your intent is to always read Winsock data into the same named
array and transfer that to an array with a different name without
needing the data in the original array, I think that can be done. You
can use some external API functions to change an internal variable
pointer to switch the array buffer from one variable to another. I
haven't tried this myself but I think it's possible but it requires an
understanding of how variables are constructed and stored in memory.

You might also look at the EVAL and EXECUTE commands where you can
change array names at time of execution. This won't help with copying
the contents of an array, only with assigning different array names
when you do your Winsock calls.

-Tom
--- In [EMAIL PROTECTED], "elriba75" <[EMAIL PROTECTED]> wrote:
>
> Hi,
> 
> Thanks for replying.
> 
> With objects it works this way:
> 
> 1) Assignment is a reference assignment, so that ObjB and ObjA are
> "pointing" to the same object:
> Set ObjB = ObjA
> 
> 2)  However, I can clear a reference without destroying the object (
> because ObjB is referencing the object too):
>ObjA = ""
>or 
>Set ObjA = Nothing
> 
> Clears ObjA, BUT ObjB still contains (actually points to) the original
> object.
> 
> I need something like this but for Arrays for some work I'm doing.   I
> have a function that reads data using Winsock and places it into an
> array.  Instead of using that data from THAT array, I want to copy it
> to another reference, and use that.   
> 
> Function myFunc()
>ArrayA = SPLIT(dataFromWinsock,'|')
>.some code
>ok = True
> End Function
> 
> Sub Process
>If myFunc() = True  Then
>   ArrayB = ArrayA
>   ArrayA = ""
>End If
>use ArrayB from now on
> 
>If myFunc() = True Then
>ArrayC = ArrayA
>ArrayA = "
>End If
> Use ArrayC and ArrayB now...
> End Sub
> 
> The exact code is quite different, but the idea is the same.
> 
> Best regards,
> Edgard
>



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"nsb-ce" group.
To post to this group, send email to nsb-ce@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/nsb-ce?hl=en
-~--~~~~--~~--~--~---