Re: [U2] Mocking UniSession in .NET

2012-08-15 Thread Ravindranath Wickramanayake
Thanks Brian I will try that out.

-Original Message-
From: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Brian Leach
Sent: Tuesday, August 14, 2012 3:32 PM
To: U2 Users List
Subject: Re: [U2] Mocking UniSession in .NET

... in fact if you're building, you may be better off just using a
stringbuilder and generating the delimited string. If the UniDynArray is
wrapping a string that might explain why it seems slow. (.net strings
are immutable so changing strings is a bad idea). 

on the server the string manipulations are highly optimised using
various hidden pointers and hints.

Brian

Sent from my iPad

On 14 Aug 2012, at 21:25, Brian Leach br...@brianleach.co.uk wrote:

 Do you need to send an actual UniDynArray or the underlying data in a
dynamic array format? IIIRC the UniSubroutine arguments are overloaded
to use strings: and a dynamic array (encapsulated in a UniDynArray) is
actually a delimited string. Fields separated by \xFe, values by \xFD,
text encoding is 8 bit ansi so get the TextEncoding from page 1252. 
 
 Now I dont know what the UniDynArray does internally to manage data 
 but I have found it slow, and often better to go to the underlying 
 string and parse or manipulate it directly e.g. using a 
 Liststring.AddRange( myArray.StringValue.Split('\xFd'));
 
 AFAIK the only reason the UniDynArray is constructed from the
UniSession is because it needs to get any NLS mappings from the server
(anyone know better?) and certainly the older COM implementation of
UniObjects did not need a session to create a dynamic array, so you
could probably just simulate that and ignore the parenting UniSession.
 
 
 oh and be careful about insert, you probably need replace in most
cases. that will replace the content of an existing or non-existing
element.
 
 B
 Sent from my iPad
 
 On 14 Aug 2012, at 20:49, Ravindranath Wickramanayake
ra...@rammutual.com wrote:
 
 Hmm my Business logic sends data to Data Layer then data layer talks 
 to pick server by using UniObject.NET dll. What I'm trying to unit 
 test is this DataLayer Calls to pick to check whether it converts 
 complex objects to UniDynArrays correctly.
 
 So How do you abstract UniSession out? Sproc coming from pick side 
 (which I have no control over) require me to send UniDynArray.
 
 What I want is to send user data to a UniDynArray. I have already 
 interfaced UniDynArray insert methods but I can't see how I could 
 return a UniDynArray without a UniSession. Is there a way you could 
 fake UniSession for unit testing purposes?
 
 -Original Message-
 From: u2-users-boun...@listserver.u2ug.org
 [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Brian 
 Leach
 Sent: Tuesday, August 14, 2012 4:56 AM
 To: 'U2 Users List'
 Subject: Re: [U2] Mocking UniSession in .NET
 
 T
 
 I think we're actually talking the same thing: a separation between 
 the business logic and the client.
 Mocking the business logic calls so they don't touch the server, and 
 separately unit testing the server routines so you know they will 
 work when they will be hit.
 
 And I'm a believer in unit tests, or at least the discipline they 
 enforce - learned the hard way - and as a platform for integration 
 testing. Without automated testing I haven't got the resources to do 
 a full integration  test for every release. Though not necessarily 
 going as far as TDD yet.
 
 Brian
 
 -Original Message-
 From: u2-users-boun...@listserver.u2ug.org
 [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Tony 
 Gravagno
 Sent: 14 August 2012 01:29
 To: u2-users@listserver.u2ug.org
 Subject: Re: [U2] Mocking UniSession in .NET
 
 Brian Leach
 would it be better to construct a higher level wrapper for your
 business
 functions and mock those? the UO libraries are quite low level: its
 a bit
 like mocking ado.net rather than your db calls.
 
 From: Ravindranath
 Thanks for the reply. I am trying to do higher level wrappers to
 hide
 those UniObject stuff but the problem is in order to to get
 UniDynArray it
 has to have UniSession. [snip]
 
 
 Brian, I was going to suggest the same thing. But this is one of the 
 differences between unit testing an application and mocking, which 
 will allow a unit test to run completely in test mode without 
 actually calling to the server within the application code. Ravi 
 could abstract his code out for the test but that very process could 
 be considered an invalidation of the test.
 
 Despite the latest craze around unit testing and the entire industry 
 that it's spawned, I still find applications I use to be as crappy as

 they've always been, so I'm not as enamored with unit tests or 
 mocking as many others. When working on a GUI project I try to get 
 the BASIC app developers to handle everything there while I 
 intentionally remain ignorant of their inner processes. Once my 
 clients get the hang of this they really enjoy the process - the 
 BASIC developers 

[U2] CSV to Array

2012-08-15 Thread Wjhonson

Rex Gozar uploaded this code, and someone (perhaps him) corrected it, but 
there's a redundancy here.  I'm trying to fix it, in my own version, mostly 
perhaps I *hate* the CONTINUE, but the logic is a bit convoluted eh?  Anyone 
spot the redundancy ?

  EQU COMMA TO ','
  EQU DQ TO ''
  BUFFER = TEXT
  BUFPTR = 0
  CPTR = 0
  QUOTESW = @FALSE
  LOOP
 CPTR += 1
 C = BUFFER[CPTR,1]
  WHILE (C NE ) DO
 IF (DQ EQ C) THEN
IF (QUOTESW) AND (DQ:DQ EQ BUFFER[CPTR,2]) THEN
   CPTR += 1
END ELSE
   QUOTESW = NOT(QUOTESW)
   CONTINUE
END
 END
 IF (COMMA EQ C) AND NOT(QUOTESW) THEN
C = @FM
 END
 BUFPTR += 1
 BUFFER[BUFPTR,1] = C
  REPEAT
  RECORD = BUFFER[1,BUFPTR]
  RETURN
   END

___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] CSV to Array

2012-08-15 Thread Tony Gravagno
Anyone getting paid to play guessing games? Dude, get to the point. If
this were presented as I need help I think many people would jump to
help. But presenting this as a Mensa challenge is just wasting
people's time.
T

Wjhonson wrote:
  Rex Gozar uploaded this code, and someone (perhaps him) corrected
it,
 but there's a redundancy here.  I'm trying to fix it, in my own
version,
 mostly perhaps I *hate* the CONTINUE, but the logic is a bit
convoluted
 eh?  Anyone spot the redundancy ?

___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] CSV to Array

2012-08-15 Thread Wjhonson

There's no point in being abusive Tony.  No one appreciates it.


-Original Message-
From: Tony Gravagno 3xk547...@sneakemail.com
To: u2-users u2-users@listserver.u2ug.org
Sent: Wed, Aug 15, 2012 2:50 pm
Subject: Re: [U2] CSV to Array


Anyone getting paid to play guessing games? Dude, get to the point. If
this were presented as I need help I think many people would jump to
help. But presenting this as a Mensa challenge is just wasting
people's time.
T

Wjhonson wrote:
  Rex Gozar uploaded this code, and someone (perhaps him) corrected
it,
 but there's a redundancy here.  I'm trying to fix it, in my own
version,
 mostly perhaps I *hate* the CONTINUE, but the logic is a bit
convoluted
 eh?  Anyone spot the redundancy ?

___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

 
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] CSV to Array

2012-08-15 Thread Phil Walker
At risk of starting a flame war, I agree with Tony. I need to tune my email 
rules better.

 -Original Message-
 From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-
 boun...@listserver.u2ug.org] On Behalf Of Wjhonson
 Sent: 16 August 2012 9:58 a.m.
 To: u2-users@listserver.u2ug.org
 Subject: Re: [U2] CSV to Array
 
 
 There's no point in being abusive Tony.  No one appreciates it.
 
 
 -Original Message-
 From: Tony Gravagno 3xk547...@sneakemail.com
 To: u2-users u2-users@listserver.u2ug.org
 Sent: Wed, Aug 15, 2012 2:50 pm
 Subject: Re: [U2] CSV to Array
 
 
 Anyone getting paid to play guessing games? Dude, get to the point. If this
 were presented as I need help I think many people would jump to help.
 But presenting this as a Mensa challenge is just wasting people's time.
 T
 
 Wjhonson wrote:
   Rex Gozar uploaded this code, and someone (perhaps him) corrected it,
  but there's a redundancy here.  I'm trying to fix it, in my own
 version,
  mostly perhaps I *hate* the CONTINUE, but the logic is a bit
 convoluted
  eh?  Anyone spot the redundancy ?
 
 ___
 U2-Users mailing list
 U2-Users@listserver.u2ug.org
 http://listserver.u2ug.org/mailman/listinfo/u2-users
 
 
 ___
 U2-Users mailing list
 U2-Users@listserver.u2ug.org
 http://listserver.u2ug.org/mailman/listinfo/u2-users


___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] CSV to Array

2012-08-15 Thread Wjhonson

No one is forcing you to respond Phil.
I posted some interesting code and asked for comments.

The comments so far are just uncalled for abuse.
You should be banned from this list.


-Original Message-
From: Phil Walker p...@gnosys.co.nz
To: U2 Users List u2-users@listserver.u2ug.org
Sent: Wed, Aug 15, 2012 3:02 pm
Subject: Re: [U2] CSV to Array


At risk of starting a flame war, I agree with Tony. I need to tune my email 
rules better.

 -Original Message-
 From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-
 boun...@listserver.u2ug.org] On Behalf Of Wjhonson
 Sent: 16 August 2012 9:58 a.m.
 To: u2-users@listserver.u2ug.org
 Subject: Re: [U2] CSV to Array
 
 
 There's no point in being abusive Tony.  No one appreciates it.
 
 
 -Original Message-
 From: Tony Gravagno 3xk547...@sneakemail.com
 To: u2-users u2-users@listserver.u2ug.org
 Sent: Wed, Aug 15, 2012 2:50 pm
 Subject: Re: [U2] CSV to Array
 
 
 Anyone getting paid to play guessing games? Dude, get to the point. If this
 were presented as I need help I think many people would jump to help.
 But presenting this as a Mensa challenge is just wasting people's time.
 T
 
 Wjhonson wrote:
   Rex Gozar uploaded this code, and someone (perhaps him) corrected it,
  but there's a redundancy here.  I'm trying to fix it, in my own
 version,
  mostly perhaps I *hate* the CONTINUE, but the logic is a bit
 convoluted
  eh?  Anyone spot the redundancy ?
 
 ___
 U2-Users mailing list
 U2-Users@listserver.u2ug.org
 http://listserver.u2ug.org/mailman/listinfo/u2-users
 
 
 ___
 U2-Users mailing list
 U2-Users@listserver.u2ug.org
 http://listserver.u2ug.org/mailman/listinfo/u2-users


___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

 
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] CSV to Array

2012-08-15 Thread larryh
This thread is CLOSED.  Take it offline.

Larry Hiscock
Moderator



 No one is forcing you to respond Phil.
 I posted some interesting code and asked for comments.

 The comments so far are just uncalled for abuse.
 You should be banned from this list.


 -Original Message-
 From: Phil Walker p...@gnosys.co.nz
 To: U2 Users List u2-users@listserver.u2ug.org
 Sent: Wed, Aug 15, 2012 3:02 pm
 Subject: Re: [U2] CSV to Array


 At risk of starting a flame war, I agree with Tony. I need to tune my
 email
 rules better.

 -Original Message-
 From: u2-users-boun...@listserver.u2ug.org [mailto:u2-users-
 boun...@listserver.u2ug.org] On Behalf Of Wjhonson
 Sent: 16 August 2012 9:58 a.m.
 To: u2-users@listserver.u2ug.org
 Subject: Re: [U2] CSV to Array


 There's no point in being abusive Tony.  No one appreciates it.


 -Original Message-
 From: Tony Gravagno 3xk547...@sneakemail.com
 To: u2-users u2-users@listserver.u2ug.org
 Sent: Wed, Aug 15, 2012 2:50 pm
 Subject: Re: [U2] CSV to Array


 Anyone getting paid to play guessing games? Dude, get to the point. If
 this
 were presented as I need help I think many people would jump to help.
 But presenting this as a Mensa challenge is just wasting people's time.
 T

 Wjhonson wrote:
   Rex Gozar uploaded this code, and someone (perhaps him) corrected it,
  but there's a redundancy here.  I'm trying to fix it, in my own
 version,
  mostly perhaps I *hate* the CONTINUE, but the logic is a bit
 convoluted
  eh?  Anyone spot the redundancy ?

 ___
 U2-Users mailing list
 U2-Users@listserver.u2ug.org
 http://listserver.u2ug.org/mailman/listinfo/u2-users


 ___
 U2-Users mailing list
 U2-Users@listserver.u2ug.org
 http://listserver.u2ug.org/mailman/listinfo/u2-users


 ___
 U2-Users mailing list
 U2-Users@listserver.u2ug.org
 http://listserver.u2ug.org/mailman/listinfo/u2-users


 ___
 U2-Users mailing list
 U2-Users@listserver.u2ug.org
 http://listserver.u2ug.org/mailman/listinfo/u2-users



___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] CSV to Array

2012-08-15 Thread David Wolverton
I've done this in the past by doing this:

SWAP DQUOTE WITH @AM

Now, in theory, every EVEN attribute is a 'quoted' string - don't touch the
commas
Every ODD attribute is a 'non-quoted' string...

Double check me here in case I've lost it... but this should work ... seems
this would be faster as well on larger records.  Only thing you'd have to
test for -- if the first character is a doublequote, we will have a blank
first attribute and should not -- but that could be tested in the END ELSE
section (IF XXX = 1 THEN IF DATASTRING[1,1] = 1 THEN CONTINUE)

DATASTRING = 'A,B,C,D,E,F,G,H,I,J,K,L
NEWSTRING = 
SWAP '' WITH @AM IN DATASTRING
AMCNT = DCOUNT(DATASTRING,@AM)
FOR XXX  =  1 TO AMCNT 
  IF MOD(AMCNT,2) = 0 THEN
NEWSTRING  := @AM: DATASTRINGXXX
  END ELSE
DATAROW = NEWSTRINGXXX
SWAP ',' WITH @AM IN DATAROW
NEWSTRING := @AM:DATAROW
NEWSTRING-1 = DATAROW
  END
NEXT XXX


-Original Message-
From: u2-users-boun...@listserver.u2ug.org
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson
Sent: Wednesday, August 15, 2012 4:11 PM
To: u2-users@listserver.u2ug.org
Subject: [U2] CSV to Array


Rex Gozar uploaded this code, and someone (perhaps him) corrected it, but
there's a redundancy here.  I'm trying to fix it, in my own version, mostly
perhaps I *hate* the CONTINUE, but the logic is a bit convoluted eh?  Anyone
spot the redundancy ?

  EQU COMMA TO ','
  EQU DQ TO ''
  BUFFER = TEXT
  BUFPTR = 0
  CPTR = 0
  QUOTESW = @FALSE
  LOOP
 CPTR += 1
 C = BUFFER[CPTR,1]
  WHILE (C NE ) DO
 IF (DQ EQ C) THEN
IF (QUOTESW) AND (DQ:DQ EQ BUFFER[CPTR,2]) THEN
   CPTR += 1
END ELSE
   QUOTESW = NOT(QUOTESW)
   CONTINUE
END
 END
 IF (COMMA EQ C) AND NOT(QUOTESW) THEN
C = @FM
 END
 BUFPTR += 1
 BUFFER[BUFPTR,1] = C
  REPEAT
  RECORD = BUFFER[1,BUFPTR]
  RETURN
   END

___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


[U2] Escaping quotes

2012-08-15 Thread Wjhonson

I'm curious about this escaping quotes thing in the csv format.

Two double-quotes in a row means what exactly?  That it should be converted to 
one double-quote in the output ?
Or that it should be converted to nothing?

What if I encountere three double-quotes in a row, or four or fifteen?
Do I take them out in pairs?
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users


Re: [U2] Escaping quotes

2012-08-15 Thread Hona, David
I think this article says it all...

http://en.wikipedia.org/wiki/Comma-separated_values


-Original Message-
From: u2-users-boun...@listserver.u2ug.org 
[mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Wjhonson
Sent: Thursday, 16 August 2012 10:48 AM
To: u2-users@listserver.u2ug.org
Subject: [U2] Escaping quotes


I'm curious about this escaping quotes thing in the csv format.

Two double-quotes in a row means what exactly?  That it should be converted to 
one double-quote in the output ?
Or that it should be converted to nothing?

What if I encountere three double-quotes in a row, or four or fifteen?
Do I take them out in pairs?
___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

** IMPORTANT MESSAGE *   
This e-mail message is intended only for the addressee(s) and contains 
information which may be
confidential. 
If you are not the intended recipient please advise the sender by return email, 
do not use or
disclose the contents, and delete the message and any attachments from your 
system. Unless
specifically indicated, this email does not constitute formal advice or 
commitment by the sender
or the Commonwealth Bank of Australia (ABN 48 123 123 124) or its subsidiaries. 
We can be contacted through our web site: commbank.com.au. 
If you no longer wish to receive commercial electronic messages from us, please 
reply to this
e-mail by typing Unsubscribe in the subject line. 
**



___
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users