Actualmente tengo el siguiente código:
- Code: Select all Expand view
- Function Conect (n)
LOCAL c
LOCAL hIni
LOCAL oServer
LOCAL cServer, cUser, cPassword, nPort, cDBName,nFlags
LOCAL oErr
c = "mysql"
if n != NIL
c = "mysql" + AllTrim( n )
endif
msgstop(c)
hIni := HB_ReadIni( "connect.ini" )
oServer := NIL
cServer := hIni[ c ]["host"]
cUser := hIni[ c ]["user"]
cPassword := hIni[ c ]["psw"]
nPort := val(hIni[ c ]["port"])
cDBName := hIni[ c ]["dbname"]
nFlags := val(hIni[ c ]["flags"])
La Variable c es el nombre de la Section que se extraera del INI ("connect.ini"), el problema es si la Section no es encontrada se produce el siguiente error de ejecución:
Application
===========
Path and name: C:\PRO\RAIG32\SISVEN.exe (32 bits)
Size: 6,259,200 bytes
Compiler version: Harbour 3.2.0dev (r2004201301)
FiveWin version: FWH 22.03
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.2, Build 9200
Time from start: 0 hours 0 mins 10 secs
Error occurred at: 12/05/2022, 20:45:48
Error description: Error BASE/1132 Bound error: array access
Args:
[ 1] = H { "MAIN" => {=>}, "mysql" => { "host" => "dolphintest.sitasoft.net", "user" => "test_dolphin", ... }
[ 2] = C mysql2011
Stack Calls
===========
Called from: c:\pro\raig32\prgh\Sisven.prg => CONNECTTO( 62 )
Called from: c:\pro\raig32\prgh\Sisven.prg => SELECT_EMP( 548 )
Called from: c:\pro\raig32\prgh\Sisven.prg => (b)IDENTIFICA( 498 )Application
===========
Path and name: C:\PRO\RAIG32\SISVEN.exe (32 bits)
Size: 6,259,200 bytes
Compiler version: Harbour 3.2.0dev (r2004201301)
FiveWin version: FWH 22.03
C compiler version: Borland/Embarcadero C++ 7.0 (32-bit)
Windows version: 6.2, Build 9200
Time from start: 0 hours 0 mins 10 secs
Error occurred at: 12/05/2022, 20:45:48
Error description: Error BASE/1132 Bound error: array access
Args:
[ 1] = H { "MAIN" => {=>}, "mysql" => { "host" => "dolphintest.sitasoft.net", "user" => "test_dolphin", ... }
[ 2] = C mysql2011
Stack Calls
===========
Called from: c:\pro\raig32\prgh\Sisven.prg => CONNECTTO( 62 )
Called from: c:\pro\raig32\prgh\Sisven.prg => SELECT_EMP( 548 )
Called from: c:\pro\raig32\prgh\Sisven.prg => (b)IDENTIFICA( 498 )
Favor su orientación de cómo poder resolver mi problema.
Un abrazo desde Santiago de Chile