Re: Invalid conversion error when using TEXT datatype in INPUT

wh <[email protected]>
Newsgroups gmane.comp.lang.4gl.aubit.general
Message-ID <[email protected]>
Hello Mike,

after a debugging session on the "XML UI / TEXT Datatype" problem I 
created a (temporary?) fix. I added a "char to blob" conversion routine 
in lib/libaubit/conv.c. First tests looks promising, but can you please 
check that my patch isn't a pice of bullshit? ;) (see attached 
patch.txt)






Am , schrieb wh:
> Hello Mike,
> 
> in TUI mode there is one more little bug (I think):
> When you start an external text editor with ! in a blob field, change
> the content, save & exit, the the content of the form field is not
> updated. I'm not sure what the original Informix behaviour is, but 
> AFAIK
> the field content is updated after the end of the external-editor.
> 
> the datatype-conversion bug still exists in the XML UI. Can you give me
> a hint where this conversion take place? I'm a bit lost in the aubit
> sources :-)
> 
> 
> 
> 
>> Hmm - I think there is a problem with validation check - its trying to
>> convert to a string so it can run some checks - but I'm really not
>> sure it needs to run those on blobs..
>> 
>> I've committed the change to CVS - if you can try that and let me know
>> if you're still having compilation issues - I can try to fix those
>> too..
>> 
>> If you just want to make the change on your own local source - try
>> adding the "if" test in lib/libui/ui_curses/ioform.c :
>> 
>> int
>> A4GL_check_and_copy_field_to_data_area (struct s_form_dets *form,
>>                                         
>> struct struct_scr_field *fprop, char *fld_data, char *data_area, int
>> var_dtype)
>> {
>>   int pprval;
>>   int dsize;
>> 
>> // Add these 3 lines
>> 
>>   if ((fprop->datatype & DTYPE_MASK) == DTYPE_BYTE ||
>> (fprop->datatype &DTYPE_MASK) == DTYPE_TEXT) {
>>          return 1;
>>   }
>> 
>> and see how you get on..
>> 
>> On 9 November 2013 12:51, <[email protected]> wrote:
>> 
>>> Hello,
>>>  
>>> when I use the INPUT statement with a TEXT datatype I get an
>>> "Invalid conversion" error after finishing the INPUT with the accept
>>> key.
>>>  
>>> Here is a minimal example:
>>> t1.4gl:
>>> =====
>>> main
>>> define b1 text
>>> open window w1 with form "f1"
>>> locate b1 in file "/tmp/b1"
>>> input b1 without defaults from myblob
>>> close window w1
>>> end main
>>> =====
>>>  
>>> f1.per:
>>> =====
>>> database formonly
>>> screen
>>> {
>>> [a           ]
>>> }
>>> end
>>> attributes
>>> a = formonly.myblob type text;
>>> =====
>>>  
>>> compile with
>>> 4glpc t1.4gl -o t1.4ae
>>> fcompile f1.per
>>>  
>>> then run t1.4ae, press "!" to start DBEDIT, write some text, close
>>> edtor, finish INPUT with accept key:
>>> 
>>> Err:Program ./t1.4ae stopped at 't1.4gl', line number 5.
>>> Error status number -30284.
>>> Invalid conversion.
>>> 4gl function call stack :
>>>     MAIN
>>>  
>>> I seams the the INPUT statement accepts the datatype TEXT but
>>> returns it als CHAR?
>>>  
>>> see also the attached debug.out.gz
>>>  
>>> I used version 1.2_34 from  aubit.com [1] (not the latest CVS
>>> version, had some problems to compile on my machine).
>>> System: ubuntu linux 13.10 64bit (compiler: gcc (Ubuntu/Linaro
>>> 4.8.1-10ubuntu8) 4.8.1).
>>> This happens with A4GL_UI=TUI and also with XML (ventas client).
>>>  
>>>  
>>> thanks for any help!
>>> Walter
>>> 
>> ------------------------------------------------------------------------------
>>> November Webinars for C, C++, Fortran Developers
>>> Accelerate application performance with scalable programming
>>> models. Explore
>>> techniques for threading, error checking, porting, and tuning. Get
>>> the most
>>> from the latest Intel processors and coprocessors. See abstracts
>>> and register
>>> 
>> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
>>> [2]
>>> _______________________________________________
>>> Aubit4gl-discuss mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss [3]
>> 
>> 
>> 
>> Links:
>> ------
>> [1] http://aubit.com
>> [2]
>> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&amp;iu=/4140/ostg.clktrk
>> [3] https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss
>> 
>> ------------------------------------------------------------------------------
>> November Webinars for C, C++, Fortran Developers
>> Accelerate application performance with scalable programming models.
>> Explore
>> techniques for threading, error checking, porting, and tuning. Get the
>> most
>> from the latest Intel processors and coprocessors. See abstracts and
>> register
>> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
>> 
>> _______________________________________________
>> Aubit4gl-discuss mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss
> 
> ------------------------------------------------------------------------------
> November Webinars for C, C++, Fortran Developers
> Accelerate application performance with scalable programming models. 
> Explore
> techniques for threading, error checking, porting, and tuning. Get the 
> most
> from the latest Intel processors and coprocessors. See abstracts and 
> register
> http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
> _______________________________________________
> Aubit4gl-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk

_______________________________________________
Aubit4gl-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/aubit4gl-discuss
patch.txt (text/x-diff, 2.7 KB)
--- lib/libaubit4gl/conv.c	2013-11-11 15:44:02.198434204 +0100
+++ lib/libaubit4gl/conv.c.orig	2013-11-11 15:44:02.894415469 +0100
@@ -159,8 +159,6 @@
 int A4GL_ltodec (void *a, void *z, int size);
 
 int A4GL_btob (void *a, void *b, int size);
-int A4GL_ctob (void *a, void *b, int size);
-int A4GL_vtob (void *a, void *b, int size);
 
 int A4GL_dtos (void *aa, void *zz, int size);
 //int A4GL_dttoc (void *a, void *b, int size);
@@ -304,7 +302,7 @@
 int (*convmatrix[MAX_DTYPE][MAX_DTYPE]) (void *ptr1, void *ptr2, int size) =
 {
   {
-  A4GL_ctoc, A4GL_stoi, A4GL_stol, A4GL_stof, A4GL_stosf, A4GL_stodec, A4GL_stol, A4GL_stod, A4GL_stomdec, NO, A4GL_ctodt, A4GL_ctob, A4GL_ctob, A4GL_ctovc, A4GL_ctoint},
+  A4GL_ctoc, A4GL_stoi, A4GL_stol, A4GL_stof, A4GL_stosf, A4GL_stodec, A4GL_stol, A4GL_stod, A4GL_stomdec, NO, A4GL_ctodt, NO, NO, A4GL_ctovc, A4GL_ctoint},
   {
   A4GL_itoc, A4GL_itoi, A4GL_itol, A4GL_itof, A4GL_itosf, A4GL_itodec, A4GL_itol, A4GL_itod, A4GL_itomdec, NO, NO, NO, NO,
       A4GL_itovc, A4GL_itoint},
@@ -339,7 +337,7 @@
   NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, A4GL_btob, NO, NO},
   {
   A4GL_vctoc, A4GL_vctoi, A4GL_vctol, A4GL_vctof, A4GL_vctosf, A4GL_vctodec, A4GL_vctol, A4GL_vctod, A4GL_vctomdec, NO,
-      A4GL_vctodt,  A4GL_vtob,  A4GL_vtob, A4GL_vctovc, A4GL_vctoint},
+      A4GL_vctodt, NO, NO, A4GL_vctovc, A4GL_vctoint},
   {
   A4GL_inttoc, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, A4GL_inttoint},
 };
@@ -1157,73 +1155,6 @@
   return 1;
 }
 
-/* 
- * Copy Char to blob
- *
- * @param a A pointer to the source char
- * @param b A pointer to the destination blob.
- * @param size
- * @return Allways 1
- */
-int
-A4GL_ctob (void *a, void *b, int size)
-{
-
-#ifdef DEBUG
-      A4GL_debug ("A4GL_ctob called, source CHAR=%s", a);
-#endif
-
-  struct fgl_int_loc *lb;
-  lb = (struct fgl_int_loc *) b;
-
-  if ( lb->where == 'M' ) 
-    { 
-#ifdef DEBUG
-      A4GL_debug ("src located in memory");
-#endif
-
-      if ( lb->ptr != NULL)
-        {
-          free (lb->ptr);
-        }
-	lb->ptr = strdup(a);
-        lb->memsize = strlen(a);
-    }
-  else
-   {
-#ifdef DEBUG
-      A4GL_debug ("src located in file, filename: %s", lb->filename);
-#endif
-     FILE *f;
-     f = fopen ( lb->filename, "w");
-     if (f)
-       {
-         fwrite ( a, 1, strlen (a), f);
-         fclose (f);
-       }
-    else
-       {
-         A4GL_exitwith_sql("Unable to open blobfile");
-       }
-   }
-   
-  return 1;
-}
-
-/* 
- * Copy Varchar to Text / Blob
- *
- * @param a A pointer to the source varchar
- * @param b A pointer to the destination blob.
- * @param size
- * @return Allways 1
- */
-int
-A4GL_vtob (void *a, void *b, int size)
-{
-  return A4GL_ctob(a, b, size);
-}
-
 /**
  *
  * @param aa
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.