estoy trabajando en el programa de transformación de los recursos de 16 a 32 bits, y me he encontrado con un error que evidencia un bug en el xHarbour que está disponible en la página de FiveTech.
El error es absolutamente incoherente.
Si recompilo el programa con xHarbour de la versión de FW 7.04 funciona perfectamente, por lo que deduzco que el bug es probablemente de xHarbour.
Te adjunto el prg a ver si el fallo es algo que no me doy cuenta o qué, de paso seguro les servirá a todos para el tema de la transformación de 16 a 32 bits.
Code: Select all
/*********************************************
Conversión de recursos de 16 a 32 bits
(c) Carlos Mora
**********************************************/
#define CRLF Chr(13)+Chr(10)
Function Main( cFichero )
Local i, j, cText, cOut, cNew, nAt, cLine, aTokens
If !File( cFichero )
If !Empty( cFichero )
cFichero+='.rc'
EndIf
EndIf
If !File( cFichero )
? 'Usage:'
? 'rc16to32 <rc2export>'
Else
cText:= MemoRead( cFichero )
nAt:= At( ' DIALOG', cText ) - 1
While nAt > 0
nAsc:= Asc( SubStr( cText, nAt, 1 ) )
If nAsc == 13 .Or. nAsc == 10
Exit
EndIf
nAt--
EndDo
If nAsc > 0
cOut:= Left( cText, nAt )
cText:= SubStr( cText, nAt + 1 )
Else
cOut:= ''
EndIF
nLines:= MLCount( cText, 200 )
? nLines
i:= 1
While i <= nLines
? i
cLine:= MemoLine( cText, 200, i )
If Left( cLine, 2 ) == '/*' // Comienza un comentario
While i <= nLines
cOut+= cLine + CRLF
? cLine
If '*/' $ cLine // Termina el comentario
Exit
EndIf
i++
cLine:= MemoLine( cText, 200, i )
EndDo
ElseIf Empty( cLine )
cOut+= cLine + CRLF
? cLine
i++
Else
If Len( aTokens:= ListAsArray( AllTrim(cLine), " " ) ) > 1 // Lista de palabras
If aTokens[2] == 'DIALOG'
cNew:= ''
For j:= 1 To Len( aTokens )
If j == Len( aTokens ) - 3 .Or. j == Len( aTokens ) - 1
cNew+= Str( Val( aTokens[j] ) * 7 / 6, 4 )+ ', '
Else
cNew+= aTokens[j]+' '
EndIf
EndFor
cOut+= cNew + CRLF
? cNew
i++
// Avanzar hasta la apertura de la llave
While i <= nLines
cLine:= MemoLine( cText, 200, i )
i++
cOut+= cLine + CRLF
? cLine
If '{' $ cLine
// If At( Chr(123), cLine ) > 0
// If Left( cLine, 1 ) == // '{'
Exit
EndIf
EndDo
// Procesar el formulario
While i <= nLines
cLine:= MemoLine( cText, 200, i )
? cLine
i++
If '}' $ cLine
cOut+= cLine + CRLF
Exit
EndIf
// Ver que control es y como se traduce
If Len( aTokens:= ListAsArray( cLine, "," ) ) < 5 // Lista de palabras
cOut+= cLine + CRLF
Else // Las ultimas 4 son las coordenadas
cNew:= ''
cType:= AllTrim( aTokens[1] )
cType:= Left( cType, At( ' ', cType ) - 1 )
If cType == 'CONTROL'
// Ajustar tokens
aTokens[5]:= Str( Val( aTokens[5] ) * 7 / 6, 4 )
aTokens[7]:= Str( Val( aTokens[7] ) * 7 / 6, 4 )
Else //
aTokens[2]:= Str( Val( aTokens[2] ) * 7 / 6, 4 )
aTokens[4]:= Str( Val( aTokens[4] ) * 7 / 6, 4 )
EndIF
For j:= 1 To Len( aTokens )
cNew+= aTokens[j]
If j != Len( aTokens )
cNew+= ','
EndIf
EndFor
cOut+= cNew + CRLF
EndIf
EndDo
Else
cOut+= cLine + CRLF
i++
EndIf
EndIf
EndIf
EndDo
?
? 'test1.rc', Len(cOut)
MemoWrit( 'test1.rc' , cOut )
EndIf
Return NIL
FUNCTION ListAsArray( cList, cDelimiter )
LOCAL nPos // Position of cDelimiter in cList
LOCAL aList := {} // Define an empty array
If cDelimiter == NIL
cDelimiter := ","
EndIf
// Loop while there are more items to extract
DO WHILE ( nPos := AT( cDelimiter, cList )) != 0
// Add the item to aList and remove it from cList
AADD( aList, SUBSTR( cList, 1, nPos - 1 ))
cList := SUBSTR( cList, nPos + 1 )
ENDDO
AADD( aList, cList ) // Add final element
RETURN ( aList ) // Return the array
Code: Select all
# Make directives ############################################################
.autodepend
.swap
.suffixes: .prg .hrb
# Flags for modules to include: YES | NO (must be UPPERCASE)##################
RES_FILE = NO
LNK_DBFNTX = YES
LNK_DBFCDX = YES
LNK_FIVEWIN = NO
LNK_DEBUG = NO
LNK_ADVANTAGE = NO
LNK_ODBC = NO
LNK_XLS = NO
MAP_FILE = NO
USE_XHARBOUR = YES
# Application directories & filenames ########################################
APP_NAME = rc16to32 # (Your EXE name without extension)
APP_PRG_DIR = .
APP_OBJ_DIR = obj # (create the app\obj directory first)
APP_INCLUDE_DIR = .
APP_EXE_DIR = $(APP_PRG_DIR)
APP_RES_DIR = $(APP_PRG_DIR)
APP_EXE = $(APP_EXE_DIR)\$(APP_NAME).exe
APP_RC = $(APP_RES_DIR)\$(APP_NAME).rc
APP_RES = $(APP_RES_DIR)\$(APP_NAME).res
APP_MAP = $(APP_RES_DIR)\$(APP_NAME).map
# Paths for dependent files ##################################################
.path.prg = $(APP_PRG_DIR)
.path.hrb = $(APP_OBJ_DIR)
.path.obj = $(APP_OBJ_DIR)
# Application PRG files (your PRG files go here) #############################
APP_PRG_LIST = rc16to32.prg
# Contruction of the rest dependency lists ###################################
APP_PRGS = $(APP_PRG_LIST)
APP_HRBS = $(APP_PRG_LIST:.prg=.hrb)
APP_OBJS = $(APP_PRG_LIST:.prg=.obj)
# Fivewin directories ########################################################
FIVEWIN_DIR = c:\fwh704
FIVEWIN_INCLUDE_DIR = $(FIVEWIN_DIR)\include
FIVEWIN_LIB_DIR = $(FIVEWIN_DIR)\lib
# Fivewin libraries ##########################################################
!if $(USE_XHARBOUR) == YES
FIVE_LIB = $(FIVEWIN_LIB_DIR)\fiveHx.lib
!else
FIVE_LIB = $(FIVEWIN_LIB_DIR)\fiveH.lib
!endif
FIVEC_LIB = $(FIVEWIN_LIB_DIR)\fiveHC.lib
# Harbour directories & flags ################################################
!if $(USE_XHARBOUR) == YES
HARBOUR_DIR = c:\xharbour705
!else
HARBOUR_DIR = c:\harbour
!endif
HARBOUR_INCLUDE_DIR = $(HARBOUR_DIR)\include
HARBOUR_EXE_DIR = $(HARBOUR_DIR)\bin
HARBOUR_LIB_DIR = $(HARBOUR_DIR)\lib
HARBOUR_FLAGS = -i$(APP_INCLUDE_DIR);$(FIVEWIN_INCLUDE_DIR);$(HARBOUR_INCLUDE_DIR) -p -n -m -q -es2 -gc0
#HARBOUR_FLAGS = -i$(APP_INCLUDE_DIR);$(HARBOUR_INCLUDE_DIR) -n
HARBOUR_EXE = $(HARBOUR_EXE_DIR)\harbour.exe
# Harbour libraries ##########################################################
RTL_LIB = $(HARBOUR_LIB_DIR)\rtl.lib
VM_LIB = $(HARBOUR_LIB_DIR)\vm.lib
!if $(LNK_FIVEWIN) == YES
GT_LIB = $(HARBOUR_LIB_DIR)\gtgui.lib
!else
GT_LIB = $(HARBOUR_LIB_DIR)\gtwin.lib
!endif
LANG_LIB = $(HARBOUR_LIB_DIR)\lang.lib
MACRO_LIB = $(HARBOUR_LIB_DIR)\macro.lib
RDD_LIB = $(HARBOUR_LIB_DIR)\rdd.lib
DBFNTX_LIB = $(HARBOUR_LIB_DIR)\dbfntx.lib
DBFDBT_LIB = $(HARBOUR_LIB_DIR)\dbfdbt.lib
DBFCDX_LIB = $(HARBOUR_LIB_DIR)\dbfcdx.lib
DEBUG_LIB = $(HARBOUR_LIB_DIR)\debug.lib
COMMON_LIB = $(HARBOUR_LIB_DIR)\common.lib
PP_LIB = $(HARBOUR_LIB_DIR)\pp.lib
HBSIX_LIB = $(HARBOUR_LIB_DIR)\hbsix.lib
DBFFPT_LIB = $(HARBOUR_LIB_DIR)\dbffpt.lib
# Advantage libraries ########################################################
RDDADS_LIB = $(HARBOUR_LIB_DIR)\rddads.lib
ACE32_LIB = $(HARBOUR_LIB_DIR)\ace32.lib
# Borlanc directories & flags ################################################
BORLANDC_DIR = c:\bcc55
BORLANDC_INCLUDE_DIR = $(BORLANDC_DIR)\include
BORLANDC_EXE_DIR = $(BORLANDC_DIR)\bin
BORLANDC_LIB_DIR = $(BORLANDC_DIR)\lib
BORLANDC_COMP_FLAGS = -c -O2 -I$(HARBOUR_INCLUDE_DIR);$(BORLANDC_INCLUDE_DIR)
BORLANDC_COMP_EXE = $(BORLANDC_EXE_DIR)\bcc32.exe
!if $(LNK_FIVEWIN) == YES
BORLANDC_LINK_FLAGS = -Gn -aa -Tpe -s -I$(APP_OBJ_DIR)
!else
//BORLANDC_LINK_FLAGS = -Gn -ap -Tpe -s -I$(APP_OBJ_DIR)
BORLANDC_LINK_FLAGS = -Gn -ap -Tpe -s -I$(APP_OBJ_DIR)
!endif
BORLANDC_LINK_EXE = $(BORLANDC_EXE_DIR)\ilink32.exe
BORLANDC_RES_EXE = $(BORLANDC_EXE_DIR)\brc32.exe
!if $(MAP_FILE) != YES
BORLANDC_LINK_FLAGS = $(BORLANDC_LINK_FLAGS) -x
!endif
# Borland libraries & files ##################################################
!if $(LNK_FIVEWIN) == YES
STARTUP_OBJ = $(BORLANDC_LIB_DIR)\c0w32.obj
!else
STARTUP_OBJ = $(BORLANDC_LIB_DIR)\c0w32.obj
!endif
CW32_LIB = $(BORLANDC_LIB_DIR)\cw32.lib
IMPORT32_LIB = $(BORLANDC_LIB_DIR)\import32.lib
ODBC32_LIB = $(BORLANDC_LIB_DIR)\psdk\odbc32.lib
# Dependencies ###############################################################
all: $(APP_OBJS) $(APP_HRBS) $(APP_EXE)
!if $(RES_FILE) == YES
all: $(APP_RES)
!endif
# Implicit Rules #############################################################
.prg.hrb:
$(HARBOUR_EXE) $(HARBOUR_FLAGS) $** -o$@
.hrb.obj:
$(BORLANDC_COMP_EXE) $(BORLANDC_COMP_FLAGS) -o$@ $**
# Explicit Rules #############################################################
!if $(RES_FILE) == YES
$(APP_RES) : $(APP_RC)
$(BORLANDC_RES_EXE) -r $**
$(APP_EXE) :: $(APP_RES)
@if exist $(APP_EXE) del $(APP_EXE) > nul
!endif
$(APP_EXE) :: $(APP_OBJS)
@echo $(STARTUP_OBJ) + > make.tmp
@echo $(**), + >> make.tmp
@echo $(APP_EXE), + >> make.tmp
@echo $(APP_MAP), + >> make.tmp
!if $(LNK_FIVEWIN) == YES
@echo $(FIVE_LIB) + >> make.tmp
@echo $(FIVEC_LIB) + >> make.tmp
@echo $(FIVEWIN_LIB_DIR)\SBROWSEH.lib + >> make.tmp
@echo $(FIVEWIN_LIB_DIR)\BTNGET.lib + >> make.tmp
# @echo HBOLE.lib + >> make.tmp
!endif
@echo $(RTL_LIB) + >> make.tmp
@echo $(VM_LIB) + >> make.tmp
@echo $(GT_LIB) + >> make.tmp
@echo $(LANG_LIB) + >> make.tmp
@echo $(MACRO_LIB) + >> make.tmp
@echo $(RDD_LIB) + >> make.tmp
@echo zlib1.lib ziparchive.lib + >> make.tmp
!if $(LNK_XLS) == YES
@echo FileXLS.lib + >> make.tmp
!endif
!if $(LNK_DBFNTX) == YES
@echo $(DBFNTX_LIB) + >> make.tmp
# @echo $(DBFDBT_LIB) + >> make.tmp
!endif
!if $(LNK_DBFCDX) == YES
@echo $(DBFCDX_LIB) + >> make.tmp
!endif
!if $(LNK_DEBUG) == YES
@echo $(DEBUG_LIB) + >> make.tmp
!endif
@echo $(COMMON_LIB) + >> make.tmp
@echo $(PP_LIB) + >> make.tmp
@echo $(HBSIX_LIB) + >> make.tmp
@echo $(DBFFPT_LIB) + >> make.tmp
!if $(LNK_ADVANTAGE) == YES
@echo $(RDDADS_LIB) + >> make.tmp
@echo $(ACE32_LIB) + >> make.tmp
!endif
!if $(LNK_ODBC) == YES
@echo $(ODBC32_LIB) + >> make.tmp
!endif
@echo $(CW32_LIB) + >> make.tmp
@echo $(IMPORT32_LIB) + >> make.tmp
@echo $(BORLANDC_LIB_DIR)\ole2w32.lib, + >> make.tmp
!if $(RES_FILE) == YES
@echo ,$(APP_RES) >> make.tmp
!endif
$(BORLANDC_LINK_EXE) $(BORLANDC_LINK_FLAGS) @make.tmp
@del $(APP_EXE_DIR)\$(APP_NAME).tds
@rem del make.tmp