FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour oWord:CentimetersToPoints( )
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM

oWord:CentimetersToPoints( )

Posted: Sun Apr 23, 2023 03:34 PM
https://forums.fivetechsupport.com/viewtopic.php?f=6&t=43084&sid=49cf627237bfc9a8329574d91789d8e4

xHarbour: CRASH.
Code (fw): Select all Collapse
// C:\FWH..\SAMPLES\WORDCENT.PRG

#Include "FiveWin.ch"

FUNCTION Main()

   LOCAL oWord
   // Convert 2.5 centimeters to points
   LOCAL nPts

   oWord := WinWordObj():New()

   nPts := oWord:CentimetersToPoints( 2.5 )

   // Display the result
   MsgInfo("2.5 centimeters = " + Str(nPts) + " points")

   // Quit Word
   oWord:Quit()

RETURN NIL
/*
// Create a Word application object
// LOCAL oWord := WinWordObj():New()   // HARBOUR FUNCIONA.
*/

// FIN / END
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: oWord:CentimetersToPoints( )

Posted: Sun Apr 23, 2023 09:05 PM
Not Correct:
Code (fw): Select all Collapse
  oWord := WinWordObj():New()
This is correct:
Code (fw): Select all Collapse
  oWord := WinWordObj()
oWord:CentimetersToPoints( n ) works with Harbour, but fails with xHarbour with runtime error.

Better we calculate like this:
nPts := nCms * 28.35
Regards



G. N. Rao.

Hyderabad, India
Posts: 1392
Joined: Mon May 14, 2007 09:49 AM

Re: oWord:CentimetersToPoints( )

Posted: Mon Apr 24, 2023 10:47 AM

Harbour/xHarbour

xtranslate CentimetersToPoint(<n>)=>(<n>*28.35)

xtranslate PointToCentimeters(<n>)=>(<n>/28.35)

Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM

Re: oWord:CentimetersToPoints( )

Posted: Mon Apr 24, 2023 11:14 AM
Gracias. Super many thanks. resuelto, resolved.
Code (fw): Select all Collapse
// [url]https://forums.fivetechsupport.com/viewtopic.php?f=6&t=43084&sid=933f9771c33783191aabd62bdcb36e9e[/url]
// [url]https://forums.fivetechsupport.com/viewtopic.php?f=3&t=43093&sid=933f9771c33783191aabd62bdcb36e9e[/url]

// C:\FWH..\SAMPLES\WORDCENT.PRG - Modificado by Jimmy/Natter/Rao.

#Include "FiveWin.ch"

// Harbour/xHarbour:
#xtranslate CentimetersToPoint(<n>)=>(<n>*28.35)
//#xtranslate PointToCentimeters(<n>)=>(<n>/28.35)
#xtranslate PointToCentimeters(<n>)=>(<n>*28.35)

FUNCTION Main()

   LOCAL oWord, nCms
   // Convert 2.5 centimeters to points
   LOCAL nPts

   oWord := WinWordObj()

   oWord := CreateObject("Word.Application")

   IF EMPTY( oWord )

      MsgInfo( "Microsoft Word not installied" )

      RETURN NIL

   ENDIF

   #ifdef __XHARBOUR__

      nPts := PointToCentimeters( 2.5 )        // xHarbour

   #else

      nPts := oWord:CentimetersToPoints( 2.5 ) // Harbour

   #endif

   // nCms := 2.5
   // nPts := nCms * 28.35

   // Display the result
   MsgInfo("2.5 centimeters = " + Str(nPts) + " points")

   // Quit Word
   oWord:Quit()

RETURN NIL

// FIN / END
Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM

Re: oWord:CentimetersToPoints( )

Posted: Mon Apr 24, 2023 11:41 AM
I just need to figure out what this error is:

Solo necesito averiguar qué es este error:

https://forums.fivetechsupport.com/viewtopic.php?f=6&t=43084&sid=4132bd3592f232a9b39f43dfc43e989c&sid=933f9771c33783191aabd62bdcb36e9e#p259210

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341

Continue the discussion