Author | Topic: Can not edit a single dimensional array with empty values in it. Values are loaded from a table record. | |
---|---|---|
Richard Pulliam | Can not edit a single dimensional array with empty values in it. Values are loaded from a table record. on Sat, 09 Jun 2018 04:09:41 -0500 When I edit a record in a table I load the contents of the record to a single dimensional array and I edit the array. This works perfectly. When I am adding a record in a table I go to record 0 (ghost record) and I load the contents of the record to a single dimensional array. The problem is I can not edit the contents. Something like this: nRecno:=IIF(lAddingCustomer, 0, CUSTOMER->(RECNO())) CUSTOMER->(DBGOTO(nRecno)) aCustomer:=CUSTOMER->(Record2Array()) @01,00 SAY "Enter customer code" GET aCustomer[2] READ Can you tell me why? I even tried appending a record and loading the array with the empty contents of the record (Hate this!). Richard@ClipperSolutions.com ******************************************************************************* FUNCTION Record2Array(cAlias) LOCAL aRecord:={}, i DEFAULT cAlias TO ALIAS() FOR i:=1 TO (cAlias)->(FCOUNT()) AADD(aRecord, (cAlias)->(FIELDGET(i))) NEXT RETURN(aRecord) ***************************************************************************** --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus | |
Paul Chong | Re: Can not edit a single dimensional array with empty values in it. Values are loaded from a table record. on Mon, 11 Jun 2018 03:44:53 +0800 Hi, If i am not wrong, you need to insert spaces to the chr field according to its size, Space(xx). Phantom record chr field has length zero/empty string. Regards Paul On Sat, 09 Jun 2018 04:09:41 -0500, Richard Pulliam wrote: > When I edit a record in a table I load the contents of the record to a > single dimensional array and I edit the array. This works perfectly. > > When I am adding a record in a table I go to record 0 (ghost record) and > I load the contents of the record to a single dimensional array. > The problem is I can not edit the contents. > > Something like this: > > nRecno:=IIF(lAddingCustomer, 0, CUSTOMER->(RECNO())) > > CUSTOMER->(DBGOTO(nRecno)) > aCustomer:=CUSTOMER->(Record2Array()) > > @01,00 SAY "Enter customer code" GET aCustomer[2] > > READ > > Can you tell me why? > > I even tried appending a record and loading the array with the empty > contents of the record (Hate this!). > > Richard@ClipperSolutions.com > > ******************************************************************************* > FUNCTION Record2Array(cAlias) > LOCAL aRecord:={}, i > > DEFAULT cAlias TO ALIAS() > > FOR i:=1 TO (cAlias)->(FCOUNT()) > AADD(aRecord, (cAlias)->(FIELDGET(i))) > NEXT > > RETURN(aRecord) > > ***************************************************************************** > > --- > This email has been checked for viruses by Avast antivirus software. > https://www.avast.com/antivirus | |
Andreas Gehrs-Pahl | Re: Can not edit a single dimensional array with empty values in it. Values are loaded from a table record. on Sun, 10 Jun 2018 19:00:40 -0400 Richard, >The problem is I can not edit the contents. I don't quite know what your exact problem is. What exactly happens? Do you have an issue with typing a new value with Read? Or does aCustomer[2] stay empty after the Read? You didn't mention what the field type (or even what database/table or DBE) it is that you are using, or what the contents of the aCustomer array is after you read the "ghost record". Also what version of Xbase++ are you using? If I use your example code on the Alaska demo table "Customer.dbf" with Xbase++ 2.00.918, I have no problem with editing the aCustomer[2] value. The only reason I can see for this not working is when you try to edit a variable-length field, like a memo field, as it would have a zero-length in the Ghost/Phantom Record, which would prevent data entry with @ Say/Get/ Read. All other field types have a defined field length, which gives the field of the Ghost/Phantom Record a defined-length empty value. If that is your issue, you could give variable-length fields an empty default value in the Record2Array() function, based on the Field Type. Posting a more complete description of the issue and possibly a compilable program (with a demo database) would help with narrowing down the issue and finding a possibly remedy for you. Hope that helps, Andreas Andreas Gehrs-Pahl Absolute Software, LLC phone: (989) 723-9927 email: Andreas@AbsoluteSoftwareLLC.com web: http://www.AbsoluteSoftwareLLC.com [F]: https://www.facebook.com/AbsoluteSoftwareLLC | |
Jim Lee | Re: Can not edit a single dimensional array with empty values in it. Values are loaded from a table record. on Mon, 11 Jun 2018 01:49:34 +0200 > When I am adding a record in a table I go to record 0 (ghost record) hm .. for me GhostRec is LastRec()+1 GOTO ( LastRec() ) SKIP SCATTER() or IF !FOUND() SKIP SCATTER() Xbase++ have SCATTER() / GATHER() you will find Source under \SOURCE\SYS\Blocks.prg | |
Jorge L. Borlando | Re: Can not edit a single dimensional array with empty values in it. Values are loaded from a table record. on Fri, 15 Jun 2018 08:41:34 -0300 Hi Richard, maybe this comment is old, but when you add a record in a dbf, the data is not written until you move the pointer of the dbf best regards "Richard Pulliam" wrote in message news:5819d44a$7324e295$3d36c6@news.alaska-software.com... > > When I edit a record in a table I load the contents of the record to a > single dimensional array and I edit the array. This works perfectly. > > When I am adding a record in a table I go to record 0 (ghost record) and I > load the contents of the record to a single dimensional array. > The problem is I can not edit the contents. > > Something like this: > > nRecno:=IIF(lAddingCustomer, 0, CUSTOMER->(RECNO())) > > CUSTOMER->(DBGOTO(nRecno)) > aCustomer:=CUSTOMER->(Record2Array()) > > @01,00 SAY "Enter customer code" GET aCustomer[2] > > READ > > Can you tell me why? > > I even tried appending a record and loading the array with the empty > contents of the record (Hate this!). > > Richard@ClipperSolutions.com > > ******************************************************************************* > FUNCTION Record2Array(cAlias) > LOCAL aRecord:={}, i > > DEFAULT cAlias TO ALIAS() > > FOR i:=1 TO (cAlias)->(FCOUNT()) > AADD(aRecord, (cAlias)->(FIELDGET(i))) > NEXT > > RETURN(aRecord) > > ***************************************************************************** > > --- > This email has been checked for viruses by Avast antivirus software. > https://www.avast.com/antivirus > |