Index: trunk/Assembly_Library/Src/File/FileIO.asm
===================================================================
--- trunk/Assembly_Library/Src/File/FileIO.asm	(revision 50)
+++ trunk/Assembly_Library/Src/File/FileIO.asm	(revision 51)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	1.9.2010
-; Last update	:	8.10.2010
+; Last update	:	10.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Functions for file access.
@@ -28,4 +28,5 @@
 	int		DOS_INTERRUPT_21h
 	xchg	si, dx
+	mov		bx, ax		; Copy file handle to BX
 	ret
 
@@ -68,5 +69,5 @@
 ALIGN JUMP_ALIGN
 FileIO_ReadCXbytesToDSSIusingHandleFromBX:
-	xchg	dx, si				; DS:DX now points to source buffer
+	xchg	dx, si				; DS:DX now points to destination buffer
 	mov		ah, READ_FROM_FILE_OR_DEVICE
 	int		DOS_INTERRUPT_21h
@@ -102,11 +103,49 @@
 
 ;--------------------------------------------------------------------
+; FileIO_GetFileSizeToDXAXusingHandleFromBXandResetFilePosition:
+;	Parameters:
+;		BX:		File handle
+;	Returns:
+;		DX:AX:	Signed file size (if CF cleared)
+;		AX:		DOS error code (if CF set)
+;		CF:		Clear if successfull
+;				Set if error
+;	Corrupts registers:
+;		Nothing
+;--------------------------------------------------------------------
+ALIGN JUMP_ALIGN
+FileIO_GetFileSizeToDXAXusingHandleFromBXandResetFilePosition:
+	push	cx
+
+	; Get file size to DX:AX
+	xor		cx, cx
+	xor		dx, dx
+	mov		al, SEEK_FROM.endOfFile
+	call	FileIO_SeekFromOriginInALtoOffsetInDXAXusingHandleFromBX
+	jc		SHORT .ReturnFileError
+	push	dx
+	push	ax
+
+	; Reset file position
+	xor		dx, dx
+	mov		al, SEEK_FROM.startOfFile
+	call	FileIO_SeekFromOriginInALtoOffsetInDXAXusingHandleFromBX
+	pop		ax
+	pop		dx
+
+.ReturnFileError:
+	pop		cx
+	ret
+
+
+;--------------------------------------------------------------------
 ; FileIO_SeekFromOriginInALtoOffsetInDXAXusingHandleFromBX:
 ;	Parameters:
 ;		AL:		SEEK_FROM.(origin)
 ;		BX:		File handle
-;		DX:AX:	Seek offset (signed)
+;		CX:DX:	Signed offset to seek starting from AL
 ;	Returns:
-;		AX:		DOS error code if CF set
+;		DX:AX:	New file position in bytes from start of file (if CF cleared)
+;		AX:		DOS error code (if CF set)
 ;		CF:		Clear if successfull
 ;				Set if error
@@ -116,13 +155,5 @@
 ALIGN JUMP_ALIGN
 FileIO_SeekFromOriginInALtoOffsetInDXAXusingHandleFromBX:
-	push	dx
-	push	cx
-
-	mov		cx, dx				; DOS wants high word in CX
-	xchg	dx, ax				; DOS wants low word in DX
 	mov		ah, SET_CURRENT_FILE_POSITION
 	int		DOS_INTERRUPT_21h
-
-	pop		cx
-	pop		dx
 	ret
Index: trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm	(revision 50)
+++ trunk/Assembly_Library/Src/Menu/Dialog/DialogFile.asm	(revision 51)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	6.9.2010
-; Last update	:	9.10.2010
+; Last update	:	10.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Displays file dialog.
@@ -523,4 +523,6 @@
 ALIGN JUMP_ALIGN
 .ChangeToUpdir:
+	push	cs
+	pop		ds
 	mov		si, g_szUpdir
 	jmp		SHORT .ChangeDirectoryToDSSI
Index: trunk/Assembly_Library/Src/Menu/Dialog/LineSplitter.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/Dialog/LineSplitter.asm	(revision 50)
+++ trunk/Assembly_Library/Src/Menu/Dialog/LineSplitter.asm	(revision 51)
@@ -148,8 +148,5 @@
 ALIGN JUMP_ALIGN
 .RemoveEmptyLinesAtTheEndIfAnyExists:
-	mov		al, [si-2]			; Load character before NULL
-	cmp		al, SOH
-	je		SHORT .RemoveEmptyLineAtTheEndOfString
-	cmp		al, LF
+	cmp		BYTE [si-2], SOH	; Character before NULL
 	je		SHORT .RemoveEmptyLineAtTheEndOfString
 	ret
@@ -203,12 +200,12 @@
 	mov		si, di				; SI points to start of first line
 	mov		al, STX				; Last control character to scan for
-	inc		cx					; Increment CX to get length for first line
+	inc		cx					; Increment CX to line count
 	cld
 ALIGN JUMP_ALIGN
 .LineScanLoop:
 	scasb						; cmp al, [es:di]. Increment DI
-	jb		SHORT .LineScanLoop	; Non control character
-
-	; Our end of line characters or NULL character
+	jb		SHORT .LineScanLoop	; Ignore all above STX
+
+	; NULL, SOH or STX
 	dec		cx					; Decrement lines to scan through
 	jz		SHORT .WantedLineFound
@@ -223,6 +220,6 @@
 .EndOfString:
 	lahf						; Load FLAGS low to AH
-	lea		cx, [di-1]			; We don't want control character to be printed
-	sub		cx, si				; String length to CX
+	lea		cx, [di-1]			; CX = offset to NULL, SOH or STX
+	sub		cx, si				; CX = string length
 	sahf						; Store AH to FLAGS low
 	ret
Index: trunk/Assembly_Library/Src/Menu/MenuCharOut.asm
===================================================================
--- trunk/Assembly_Library/Src/Menu/MenuCharOut.asm	(revision 50)
+++ trunk/Assembly_Library/Src/Menu/MenuCharOut.asm	(revision 51)
@@ -2,5 +2,5 @@
 ; Project name	:	Assembly Library
 ; Created date	:	15.7.2010
-; Last update	:	8.10.2010
+; Last update	:	10.10.2010
 ; Author		:	Tomi Tilli
 ; Description	:	Character out function for printing withing menu window.
@@ -80,6 +80,6 @@
 ALIGN JUMP_ALIGN
 MovePartialWordToNewTextLineAndPrintCharacterFromAX:
-	cmp		al, ' '
-	je		SHORT .MoveCursorInDItoBeginningOfNextLine
+	cmp		al, ' '		; Space or any control character
+	jb		SHORT .MoveCursorInDItoBeginningOfNextLine
 	push	si
 	push	cx
