FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour problema on transform
Posts: 1789
Joined: Tue Oct 11, 2005 05:01 PM
problema on transform
Posted: Mon Oct 25, 2021 08:48 PM
Estimados,
Code (fw): Select all Collapse
 ?transform(8,"@L9999")

en harbour y xharbour retorna 0008 lo cual es correcto.
Code (fw): Select all Collapse
 ?transform(val("8"),"@L9999")

en harbour retorna 8, y xharbour 0008, ahi falla harbour
Code (fw): Select all Collapse
 ?transform("8","@L9999")

ambos retornan 8, ahi no se si falla o esta correcto, dado que la ayuda indica que

Syntax
Transform( <xValue>, <cPicture> ) --> cFormattedString

Arguments
<xValue>
This is a value of data type Character, Date, Logic, Memo or Numeric to be formatted.
<cPicture>
This is a PICTURE formatting string defining the formatting rules (see below).


podrian aclarar? por favor...
Salu2

Carlos Vargas

Desde Managua, Nicaragua (CA)
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: problema on transform
Posted: Mon Oct 25, 2021 09:18 PM
Code (fw): Select all Collapse
// \samples\CVARGAS.PRG

#Include "FiveWin.ch"

FUNCTION Main()

   LOCAL cString  := "This is Harbour: "
   LOCAL cString2 := "This is xHarbour:"
   LOCAL nNumber  := 9923.34
   LOCAL nNumber1 := -95842.00
   LOCAL lValue   := .T.
   LOCAL dDate    := Date()

   #IFDEF __XHARBOUR__

      // if xHarbour

      ? cString2, Transform( nNumber,  "@L 99999999.99" )  //  "009923.34"

   #ELSE

      // if Harbour

      ? cString,  Transform( nNumber,  "@L 99999999.99" )  //  "009923.34"

   #ENDIF

RETURN NIL
/*
   ? "working with String"
   ? "Current String is",  cString
   ? "All uppercased",  Transform( cString,  "@!" )
   ? "Date is",  ddate
   ? "Date is ",  Transform( ddate,  "@D" )
   ? Transform( 0      ,  "@L 9999"     )  //  "0000"


The table below shows the possible function strings available with the Transform() function.

      @B   Left justify the string within the format.
      @C   Issue a CR after format is numbers are positive.
      @D   Put dates in SET DATE format.
      @E   Put dates in BRITISH format.
      @L   Make a zero padded string out of the number.
      @R   Insert non template characters.
      @X   Issue a DB after format is numbers are negative.
      @Z   Display any zero as blank spaces.
      @(   Quotes around negative numbers
      @!   Convert alpha characters to uppercased format.

The second part of <cTemplate> consists of the format string. Each character in the string may be formatted based on using the follow characters as template markers for the string.

      A,N,X,9,#   Any data type
      L           Shows logical as "T" or "F"
      Y           Shows logical as "Y" or "N"
      !           Convert to uppercase
      $           Dollar sing in place of leading spaces in 
                  numeric expression
      *           Asterisks in place of leading spaces in 
                  numeric expression
      ,           Commas position
      .           Decimal point position
*/


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: problema on transform
Posted: Wed Oct 27, 2021 10:55 PM
carlos vargas wrote:Estimados,
Code (fw): Select all Collapse
 ?transform(8,"@L9999")

en harbour y xharbour retorna 0008 lo cual es correcto.
Code (fw): Select all Collapse
 ?transform(val("8"),"@L9999")

en harbour retorna 8, y xharbour 0008, ahi falla harbour
Code (fw): Select all Collapse
 ?transform("8","@L9999")

ambos retornan 8, ahi no se si falla o esta correcto, dado que la ayuda indica que

Syntax
Transform( <xValue>, <cPicture> ) --> cFormattedString

Arguments
<xValue>
This is a value of data type Character, Date, Logic, Memo or Numeric to be formatted.
<cPicture>
This is a PICTURE formatting string defining the formatting rules (see below).


podrian aclarar? por favor...


"@L9999" is not correct
"@L 9999" is correct.
We should separate "@L" and "9999" with one space.
if we give the picture clause correctly, both Harbour and xHarbour give the same results correctly.

Code (fw): Select all Collapse
   ? Transform( 8,        "@L 9999" ), ;
     Transform( Val("8"), "@L 9999" )

Both Harbour and xHarbour produce the same result "0008" in both the cases.

Transform( "8", "@L 9999" ) is NOT CORRECT, because this picture clause applies to numeric values only.
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion