FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour harbour program including FIVEWIN source which license?
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
harbour program including FIVEWIN source which license?
Posted: Fri Feb 04, 2022 01:19 PM

Dear Antonio,
for mod harbor I would like to use some functions from FIVEWIN.
Since the source code is also passed on along mod harbour programs - we are also planning to offer an application from us on FB for free download - I see a problem with the license here.

My example:
I would like to use and pass on the ValToStr.prg.

How do you plan to regulate copyright here?

Best regards,
Otto

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Re: harbour program including FIVEWIN source which license?
Posted: Fri Feb 04, 2022 01:29 PM
Dear Antonio,
Working on a universal routine for my program for EDIT.
Starting from
TABLE with a BUTTON "EDIT"
AJAX
read all record fields from the selected record and fill
<FORM> <//FORM>
SAVE BUTTON
AJAX request with data
"read at initialization" and
data from FORM (edited data)
prg Server
first check if data is unchanged between reading first and now saving the changes.
Here the strength of DBF comes into play: we can lock a single record!
lock record
check data currently stored on server and data read before editing
if equal, go ahead with storing the changes, otherwise return a
error message.

Best regards,
Otto

Code (fw): Select all Collapse
#include "FIVEWIN.CH"

STATIC aDir := {}

static cRegion := 'A', lCommas := .f., lDisplayZeros := nil, cCurSymbol := '$'
static lJsonHuman := .f.

function main
    local  aDirRaw := Directory(  "c:\test\", "DHS" )
    local cReadAtStart := {}
    local cReadBeforeAction := {}
    
    cReadAtStart := cValToStr( aDirRaw )
        ? "make some changes to " + "c:\xwinhotel\"
    cReadBeforeAction := cValToStr( Directory(  "c:\xwinhotel\", "DHS" ) )
    
    if cReadAtStart == cReadBeforeAction
        ? "no changes"
    else
        ? "directory has changed"
    endif
    
    
return 

//----------------------------------------------------------------//



function cValToStr( uVal, cPic, cInternational, lDispZeros )

   local cVal

   DEFAULT cInternational := cRegion, lDispZeros := lDisplayZeros

//   uVal     := xEval( uVal )        // in case uval is codeblock
//   cPic     := xEval( cPic, uVal )  // in case cpic is codeblock
   if ValType( cPic ) == 'B'
      cPic  := Eval( cPic, uVal )
   endif

   if uVal == nil
      cVal = ""         // "nil"      26 aug 2013

   elseif ValType( uVal ) == 'A'
      cVal        := FW_ArrayAsList( uVal, CRLF )
      return cVal

   elseif ! ( ValType( uVal ) $ "CDLNT" )
      return cValToChar( uVal )

   elseif Empty( cPic )

      if ValType( uVal ) == 'N' .and. cInternational == 'E'
         cVal     := Transform( uVal, '@E' )
      else
         cVal     := cValToChar( uVal )
      endif

/*
      if ValType( uVal ) == 'N'
         cVal     := cNumToStr( uVal, cInternational == 'E' )
      else
         cVal     := cValToChar( uVal )
      endif
*/

   elseif cPic == '@T'
#ifdef __XHARBOUR__
      cVal     := If( Year( uVal ) == 0, TTOC( uVal, 2 ), TTOC( uVal ) )
#else
      cVal     := If( Year( uVal ) == 0, HB_TToC( uVal, '', Set( _SET_TIMEFORMAT ) ), HB_TToC( uVal ) )
#endif
   elseif cPic == '@D'
      cVal     := DTOC( uVal )
   elseif ValType( uVal ) $ 'DT' .and. Left( cPic, 1 ) != "@"
      if Empty( uVal )
         cVal  := Space( Len( cPic ) )
      else
         cVal     := Lower( cPic )
         cVal     := StrTran( cVal, ":mm", ":mi" )
         cVal     := StrTran( cVal, "dddd", CDOW( uVal ) )
         cVal     := StrTran( cVal, "ddd",  Left( CDOW( uVal ), 3 ) )
         cVal     := StrTran( cVal, 'dd', StrZero( Day( uVal ), 2 ) )
         if 'mmmm' $ cVal
            cVal    := StrTran( cVal, 'mmmm', If( 'MMMM' $ cPic, Upper( cMonth( uVal ) ), cMonth( uVal ) ) )
         elseif 'mmm' $ cVal
            cVal    := StrTran( cVal, 'mmm', Left( If( 'MMM' $ cPic, Upper( cMonth( uVal ) ), cMonth( uVal ) ), 3 ) )
         else
            cVal    := StrTran( cVal, 'mm', StrZero( Month( uVal ), 2 ) )
         endif
         if 'yyyy' $ cVal
            cVal    := StrTran( cVal, 'yyyy', Str( Year( uVal ), 4, 0 ) )
         else
            cVal    := StrTran( cVal, 'yy',   StrZero( Year( uVal ) % 100, 2 ) )
         endif
         if 'hh' $ cVal
            cVal     := StrTran( cVal, 'hh', StrZero( Hour(   uVal ), 2 ) )
         endif
         if 'mi' $ cVal
            cVal     := StrTran( cVal, 'mi', StrZero( Minute( uVal ), 2 ) )
         endif
         if 'ss' $ cVal
#ifdef __XHARBOUR__
            cVal     := StrTran( cVal, 'ss', StrZero( Secs(   uVal ), 2 ) )
#else
            cVal     := StrTran( cVal, 'ss', StrZero( HB_Sec( uVal ), 2 ) )
#endif
         endif
      endif
   else
      cVal     := Transform( uVal, cPic )
   endif
   if Empty( uVal ) .and. lDispZeros != nil .and. ValType( uVal ) $ "DNT"    // date, number, datetime
      if lDispZeros
         if Empty( cVal ) .and. ValType( uVal ) == 'N'
            cPic  := LTrim( StrTran( StrTran( StrTran( StrTran( cPic, '@Z ', '' ), '@z ', '' ), 'Z', ), 'z', '' ) )
         endif
         cVal  := Transform( uVal, cPic )
      else
         cVal  := Space( Len( cVal ) )
      endif
   endif
/*
   if Left( cVal, 1 ) == "*" .and. Len( cVal ) > 2 .and. ValType( uVal ) == 'N'
      cVal  := cNum2ExpFormat( uVal, Max( Len( cVal ) - 4, 0 ) )
   endif
*/
   if "*" $ cVal .and. ValType( uVal ) == 'N' .and. !Empty( cPic ) .and. !( '*' $ cPic )
      cVal  := StretchPicture( uVal, cPic )
   endif

return cVal

//----------------------------------------------------------------------------//


function FW_ArrayAsList( aItems, cDelim )

   local cStr     := ''

   DEFAULT cDelim := ','

   if ! Empty( aItems )
      cStr     := cValToStr( aItems[ 1 ] )
      AEval( aItems, { |u| cStr += ( cDelim + cValToStr( u ) ) }, 2 )
   endif

return cStr

//----------------------------------------------------------------------------//


static function StretchPicture( nVal, cPic )

   local cVal, nn

   do while "*" $ ( cVal := Transform( nVal, cPic ) )
      if nn == nil
         nn := AAT( { '#', '9', '.' }, cPic )
         if nn == 0
            nn := Len( cPic ) + 1
         endif
      endif
      cPic  := Left( cPic, nn - 1 ) + "9" + SubStr( cPic, nn )
   enddo

return cVal

//----------------------------------------------------------------------------//

Continue the discussion