HB_ReadIni

Projeto [x]Harbour - Compilador de código aberto compatível com o Clipper.

Moderador: Moderadores

Avatar do usuário
jairfab
Usuário Nível 3
Usuário Nível 3
Mensagens: 252
Registrado em: 21 Mai 2007 09:43
Localização: São Paulo, Região Leste - Suzano

HB_ReadIni

Mensagem por jairfab »

Boa tarde meu amigos!

Estou convertendo aqui um sistema xharbour xcc para xharbour bcc7 e o sistema tem muitas chamadas desta função HB_ReadIni para retornar um hash conforme exemplo de dados abaixo

Leitura de um arquivo como este aqui:

Código: Selecionar todos


[MAIN]

[Update]
CNPJEmp=
PLANOSIS=
UpdateAuto=S

deveria retorna a seguinte hash

Código: Selecionar todos

*****        hRet["Update"] := Hash()
*****        hRet["Update"]["CNPJEmp"] := ""
*****        hRet["Update"]["PLANOSIS"]  := "1"
*****        hRet["Update"]["UpdateAuto"]    := "S"

Alguem ja teve este mesmo problema e colo conseguiu resolver! Sei q a alternativa mais viavel seria uma funcao que faz a leitura de quaisquer arquivo ini e retorna um hash.

Aceito quaisquer sujestoes!
Delpji 7, harbour 3.2, xharbour 1.2.3, Bcc7, Minigw, Minigui 19.11, hwgui 2.20, FiveWin 19.05 Gtwvw, Gtwvg, C# VS 2017
Avatar do usuário
JoséQuintas
Administrador
Administrador
Mensagens: 20415
Registrado em: 26 Fev 2007 11:59
Localização: São Paulo-SP
Curtiram: 1 vez

HB_ReadIni

Mensagem por JoséQuintas »

Não entendi.
Fazia parte do xharbour ?
Fontes são públicos, tá nos fontes, tanto a versão antiga quanto a nova.
Pode comparar os dois e decidir o que fazer.
José M. C. Quintas
Harbour 3.2, mingw, multithread, gtwvg, fivewin 25.12, dbfcdx, MySQL, ADOClass, PDFClass, SefazClass, (hwgui), (hmg3), (hmg extended), (oohg), PNotepad, ASP, (Linux/Flagship/harbour 3.2)
"The world is full of kings and queens, who blind our eyes and steal our dreams Its Heaven and Hell"

https://github.com/JoseQuintas/
Avatar do usuário
clodoaldomonteiro
Usuário Nível 4
Usuário Nível 4
Mensagens: 821
Registrado em: 30 Dez 2006 13:17
Localização: Teresina-PI
Contato:

HB_ReadIni

Mensagem por clodoaldomonteiro »

Tem no xHarbour, última atualização:

HB_ReadIni()
Reads an INI file from disk

Syntax
HB_ReadIni( <cFileName> , ;
[<lCaseSens>] , ;
[<cDelimiter>], ;
[<lAutoMain>] ) --> hIniData

Arguments
<cFileName>
This is a character string holding the name of the INI file to open. It must include path and file extension. If the path is omitted from <cFileName>, the file is searched in the current directory.
<lCaseSens>
This parameter defaults to .T. (true) causing the function to return a case sensitive Hash(). When set to .F. (false), the returned hash is case insensitive.
<cDelimiter>
This is a character string holding the delimiter(s) recognized as separating character between key and value within the INI file. Bydefault, the characters ":", "=" and "|" are recognized.
<lAutoMain>
This parameter defaults to .T. (true) so that a [MAIN] section is automatically added to the resulting hash. All key/value pairs appearing at the beginning of the INI file outside a [section] are assigned to the hash key "MAIN". Return
The function returns two dimensional hash holding sections and key/value pairs of each section inthe INI file. When the file does not exist, the return value is NIL.
Description
Function HB_ReadIni() reads an INI file and loads the data into a two dimensional Hash, which is returned. INI files are commonly used for configuration data of applications. They are comfortable to use since they can be created and/or changed with a regular ASCII editor.

Código: Selecionar todos

// The example uses the INI file discussed in the function
// description and creates from it a case sensitive Hash.
// The key values of different sections are displayed.

   PROCEDURE Main
      LOCAL hIniData := HB_ReadIni( "test.ini" )

      ? Valtype( hIniData["MAIN"] )         // result: H
      ? Valtype( hIniData["SECTION1"] )     // result: H

      ? hIniData["MAIN"]["mainKey2"]        // result: mainvalue2

      ? hIniData["SECTION1"]["sectionKey1"] // result: valueA
      ? hIniData["SECTION1"]["sectionKey2"] // result: valueB

      ? hIniData["SECTION2"]["sectionKey1"] // result: valueC
      ? hIniData["SECTION2"]["sectionKey2"] // result: valueD

   RETURN
At. Clodoaldo Monteiro
Linguagens: Clipper / Harbour
Área de Atuação: Sistemas de gestão para Prefeituras Municipais
Fones: (86)3223-0653, 98859-0236
www.simplesinformatica.com.br
SOSSOFT

HB_ReadIni

Mensagem por SOSSOFT »

Tem isso no Harbour também?
Responder