Forum > Operating Systems
Same Source - different OS - different results. (FileOpen Access Violation WinXP
ozznixon:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Begin S:='Hello World!'; Handle:=FileCreate('testing.123',2,438); FileWrite(Handle,@S[1],Length(S)); FileClose(Handle);End.
Run on Mac OSX - Success
Run on Linux - Success
Run on Windows - "Access Violation" (File Create).
* I have tried different 2nd Parameters, I changed to simply FileCreate('testing.123') - same error, same line.
If I change code to use Assign(File,'testing.123'); Rewrite(File,1); etc. works on Windows.
--- Quote ---Free Pascal Compiler version 3.0.4 [2017/10/06] for i386
Copyright (c) 1993-2017 by Florian Klaempfl and others
C:\FPC\3.0.4\bin\i386-Win32\fpc.exe [options] <inputfile> [options]
--- End quote ---
engkin:
Try:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} --- S:='Hello World!'; Handle:=FileCreate('testing.123',fmOpenReadWrite or fmShareDenyNone,438); FileWrite(Handle,S[1],Length(S)); FileClose(Handle);
ozznixon:
Thanks, tried that too. It is very odd, may be a 3.0.4 issue. I have had very odd problems with I port my working code to Windows. (rarely code for Windows for the past decade, but, this is simple file I/O 102.
Ozz
engkin:
Just tested this on WinXp:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program Project1; {$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Classes, sysutils { you can add units after this }; var S: string; Handle:THandle;begin S:='Hello World!'; Handle:=FileCreate('testing.123',fmOpenReadWrite or fmShareDenyNone,438); FileWrite(Handle,S[1],Length(S)); FileClose(Handle);end.
I guess your problem is outside this code.
ozznixon:
@engkin - thanks, I will synchronize to a newer build than 3.0.4 and see what happens. The code works fine on my Win10 64bit environment.
Thank you for your time!
Ozz
Navigation
[0] Message Index
[#] Next page