STRU - Lists and modifies the structure of the dbfs files

You can share your experience with HMG. Share with some screenshots/project details so that others will also be benefited.

Moderator: Rathinagiri

User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: STRU - Lists and modifies the structure of the dbfs file

Post by IMATECH »

Hi Pablo !

Back to my 1st choice: If files was previous saved as UTF8 we don't need to use translations

Thanks to 'vszakats' that remember me about this simple fact ;)

Code: Select all


REQUEST HB_LANG_PT
REQUEST HB_CODEPAGE_UTF8

PROCEDURE Main()
   LOCAL cFile
   LOCAL cText

   /* Set language for Screen */
   hb_langSelect( hb_UserLang(), "UTF8EX" )
   hb_cdpSelect( "UTF8EX" )

   /* Terminal and OS codepage */
   // hb_SetTermCP( "UTF8EX" )
   hb_SetTermCP( hb_cdpTerm() )
   Set( _SET_OSCODEPAGE, hb_cdpOS() )

   SETMODE( 62, 164 )

   CLS

   cFile := 'English.Lng'
   cText := MemoRead( cFile )
   alert( cFile + ';;' + cText )

   cFile := 'French.Lng'
   cText := MemoRead( cFile )
   alert( cFile + ';;' + cText )

   cFile := 'Italian.Lng'
   cText := MemoRead( cFile )
   alert( cFile + ';;' + cText )

   cFile := 'Polish.lng'
   cText := MemoRead( cFile )
   alert( cFile + ';;' + cText )

   cFile := 'Portuguese.Lng'
   cText := MemoRead( cFile )
   alert( cFile + ';;' + cText )

   cFile := 'Spanish.Lng'
   cText := MemoRead( cFile )
   alert( cFile + ';;' + cText )

   cFile := 'Turkish.Lng'
   cText := MemoRead( cFile )
   alert( cFile + ';;' + cText )

   RETURN

M., Ronaldo

By: IMATECH

Imation Tecnologia
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

STRU - Lists and modifies the structure of the dbfs file

Post by Pablo César »

Chacal.GO wrote:I have downloaded your project for case study....

When understand core logic will make some tests, and give a new reply...
Ronaldo, I thought that you had understood my source code, mas you not are considering format in the Portuguese.Lng file which is constructed with 135 lines and are in quotes because I need keeping same quantity of space characters in the length. And still giving some errors (as it was mentioned in my previous msg) for this reason.
Another question is STRU can be run in console and GUI modes. Not only in console.

Here in attached file are files of simplified examples with same STRU´S question.
Attachments
Teste51.rar
(790.24 KiB) Downloaded 315 times
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: STRU - Lists and modifies the structure of the dbfs file

Post by IMATECH »

Hi Pablo !
.
.
.
Unicode support will work fine on any gui/console projects ( off course: all source need to be unicode ready too )

Then you need to re-write some of your functions...

Try to replace your function: MakeLangArry
.
.
.

Code: Select all


//*----------------------------------------------------------------------------*
//
// M., Ronaldo <ronmesq@gmail.com> 2012/10/12
//
// Function MR_FileUTF8_To_Array( cLangFile )
//
// Uses: hbMisc
//
//*----------------------------------------------------------------------------*
Function MR_FileUTF8_To_Array( cLangFile )

   Local aLines := {}
   LOCAL oFile := TFileRead():New( cFile )

   oFile:Open()
   IF !( oFile:Error() )
      WHILE oFile:MoreToRead()
        Aadd(aLines, TRIM( oFile:ReadLine() ) )
      END
   Endif
   oFile:Close()

Return( aLines )

.
.
.
Finally
I sugest you to change language files format: as ini files saved as utf8 ( in case of any line missing you can use a default value for your array elements )
.
.
.
Regards
M., Ronaldo

By: IMATECH

Imation Tecnologia
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

STRU - Lists and modifies the structure of the dbfs files

Post by Pablo César »

In console mode it is working OK but in GUI not:
Screen53.PNG
Screen53.PNG (9.42 KiB) Viewed 5126 times
Portuguese.Lng in attached compressed file is in UTF-8 format. Some strange characters in first element is been wrongly displayed.
I sugest you to change language files format: as ini files saved as utf8
But do you believe that is possible to keep spaces without triming ? As example see 17 element.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: STRU - Lists and modifies the structure of the dbfs file

Post by esgici »

Hi Ronaldo and Pablo

IMHO writing international applications banned by Harbour management team a short time ago ;)

Saudação
Viva INTERNATIONAL HMG :D
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: STRU - Lists and modifies the structure of the dbfs file

Post by IMATECH »

Hi Esgici !
.
.
.
IMHO writing international applications banned by Harbour management team a short time ago ;)
.
.
.
! Madness !

Harbour use modern C compiler, your reply make no sense ( imho )...

Please: send a link with this fact
.
.
.
Regards
Last edited by IMATECH on Fri Oct 12, 2012 4:49 pm, edited 2 times in total.
M., Ronaldo

By: IMATECH

Imation Tecnologia
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: STRU - Lists and modifies the structure of the dbfs file

Post by IMATECH »

Hi Pablo !
.
.
.
About Ini files:
A sample to use
.
.
.

Code: Select all


STATIC cIniFile := "MR_Stru.ini"

//*----------------------------------------------------------------------------*
//
// M., Ronaldo <ronmesq@gmail.com> 2012/10/12
//
// MR_Read_Ini_File( cIniFile )
//
// Uses: hbMisc
//
//*----------------------------------------------------------------------------*
Function MR_Read_Ini_File( cIniFile )
  LOCAL aLines := AFILL( ARRAY( 10 ), '' )
  LOCAL cSection := 'MESSAGES'
  LOCAL oIni := TIniFile():New( cIniFile )

  FOR i := 1 to Len( aLines )
     aLines[ i ] := PADC( oIni:ReadString( cSection, 'MSG_' + STRZERO( i, 3 ), '' ), 40 )
  NEXT

Return( aLines )

//*----------------------------------------------------------------------------*
//
// M., Ronaldo <ronmesq@gmail.com> 2012/10/12
//
// MR_Save_Ini_File( cIniFile, aLines )
//
// Uses: hbMisc
//
//*----------------------------------------------------------------------------*
Function MR_Save_Ini_File( cIniFile, aLines )
  LOCAL cSection := 'MESSAGES'
  LOCAL oIni := TIniFile():New( cIniFile )

  FOR i := 1 to Len( aLines )
    oIni:WriteString( cSection, 'MSG_' + STRZERO( i, 3 ), ALLTRIM( aLines[ i ] ) )
  NEXT

  oIni:UpdateFile()

Return( NILL )

.
.
.
About Unicode in HMG
HMG is not unicode ready... then you will need to handle this fact ( or update HMG sources )
.
.
.
Regards
M., Ronaldo

By: IMATECH

Imation Tecnologia
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: STRU - Lists and modifies the structure of the dbfs file

Post by esgici »

Chacal.GO wrote:Hi Esgici !
.
.
.
! Madness !

Harbour using a modern C compiler, your reply make no sense ( imho )...

Please: send a link with this fact
.
.
.
Regards
Hi Ronaldo

Sorry, not understood :?

Which reply you are about, what relation there is between C compiler and my reply,

and how / which link you ask and where I'll send :?:

Saudação
Viva INTERNATIONAL HMG :D
User avatar
IMATECH
Posts: 188
Joined: Sun May 27, 2012 9:33 pm
Location: Brazil: Goiânia-GO.

Re: STRU - Lists and modifies the structure of the dbfs file

Post by IMATECH »

Hi Esgici !
.
.
.
IMHO writing international applications banned by Harbour management team a short time ago ;)
This is mad !
Which reply you are about, what relation there is between C compiler and my reply,
and how / which link you ask and where I'll send :?:
1 - When you send a message to forum you need to click in: "Post a reply"
1.1 - IF you are using a C compiler you have no limits on creating any app
1.1.1 - Then your affirmation send harbour to Trash Programing language ( imho II )

2 - I think you have read this info in some place, then tell to us
2.1 - Please post here ( with you next reply )
.
.
.
Regards
M., Ronaldo

By: IMATECH

Imation Tecnologia
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: STRU - Lists and modifies the structure of the dbfs file

Post by esgici »

Chacal.GO wrote:This is mad !
What is mad; banning or my opinion ?
1 - When you send a message to forum you need to click in: "Post a reply"
Really :?:
1.1 - IF you are using a C compiler you have no limits on creating any app
If I am using C language, I don't use Harbour ;)

Someone think they are using C language by adding some #pragma ... end dump block into .prg, by borrowing anywhere ;)
1.1.1 - Then your affirmation send harbour to Trash Programing language ( imho II )
I didn't affirm anything and I don't send nor intent to send anything to anywhere.
2 - I think you have read this info in some place, then tell to us
I didn't transfer any info, only I write one "H" opinion. If you are wondering what is the base of this opinion it is :
If you intend to use unicode, no. (unless, you intend to sort or use other culture/dialect/language dependent operation, but displaying chars is not amongst these.)
Did you remember ?

By the way, are you in Harbour management team, or your are think so ?
Viva INTERNATIONAL HMG :D
Post Reply