display format in edit box query

Author: lalitpct@gmail.com (lalitpct)


In and editbox , I am getting below values , I want to run a command like
$replace(values,1,$syntax("&*/"),"", -1) which replaces "/a/b/c/d/" with ""
Not sure whether we can define in the display format ? does anyone have idea about it ?

value on screen
==============
/a/b/c/d/g.sqr_repair   
/l/k/c/d/g.sqr_20080925 
/ed/qw/c/d/g.sqr:1   

3 Comments

  1. NO, there is no way to apply a display format to a STRING removing characters, all you can do is adding characters in between.

    See QRG.PDF(Version 8.4.06) page 7-1:

    String
    For string fields with data type String or Special String, the valid display
    format codes are:

    ? Character from data element.
    %? One question mark.
    %% One percent symbol.
    Any ASCII character That ASCII character as a constant.
     

    Uli

    P.S: haven't we discussed a similar issue on "using replace one in tricky way" ?


    Author: ulrich-merkel (ulrichmerkel@web.de)
  2. Hi Uli ,

     We did discuss that , but here requirement was in dispaly format and not exactly replacing it , anyways thanks for the information .

    handling it in display would have been very simple ..by coding in the form i know , but I though this can be implemented in display format .

    Now I know it ,

     

    Thanks

    Regards

    lal


    Author: lalitpct (lalitpct@gmail.com)
  3. If the "to ignore characters" are only on the front of the value, than one can use this code:

    FORMAT-Trigger:


      $format=$replace(@$fieldname,1,$syntax("&*/"),"",-1) 

    DEFORMAT-Trigger
      variables
         string v_ORG
      endvariables
      v_ORG=@$fieldname
      $format="%%v_ORG[1:$length(v_ORG)-$length($replace(v_ORG,1,$syntax("&*/"),"",-1))]%%$format%%%"

    If there is a more complex "rule", just put other code into FORMAT/DEFORMAT-Trigger

     

    If you wan't to have this code reusable, then declare two global functions
     FORMAT:   $format=GF_FMT_<some_type_name>($format,"")
     DEFORMAT: $format=GF_DFMT_<some_type_name>($format,"")

    Or


     FORMAT:   call GP_FMT_<some_type_name>("")


     DEFORMAT: call GP_DFMT_<some_type_name>("")

    [Where the last argument are for further parameters in UIL format]

    As $format and $fieldname a availble in the globale procedure context, there is no need to pass them by parameter

    Next step is to put this code into the FORMAT/DEFORAMT-trigger in model so all components have this code inside without further programming

     

    Ingo

     

     

     


    Author: istiller (i2stiller@gmx.de)