Skip to content

64-bit bugs #40

@maxkleiner

Description

@maxkleiner

With the Release of 5.1.4.80 we fixed following:
5.1.4.70 XN Resource Editor & Game of Life
5.1.4.75 Unit Dependency Analyzer & TADOCommands & SQL Workbench for 64bit ODBC
5.1.4.80 Geocoding IV Unit & fix main bugfixing
5.1.4.80 IV ADODB OLE Object bugfixing
5.1.4.90 ADOQuery SQL property, UC Save
5.1.4.90 II Geocoding V & 0Auth HMAC_SHA1
5.1.4.90 III ClientDataSet fix, TDataset functions, CSVBase
5.1.4.98 VII Resource Explorer as XN and Delphi Regular Expressions as PCRE16
5.1.4.98 XII Char2() instead of inttoascii() - FormatJSON - findUtf8BOM -mcJSON Lib

I wanna mention general bugs found since version 5.0.2.70 to 5.1.6.98 🐞

warning: log10, log bug use gllog10() or gllog2()

  1. [P4M] Python for maXbox

  2. When Python Version > 3.11.9. like 3.12.4 then you have to set autofinalize:= false;

    with TPythonEngine.Create(Nil) do begin
    //pythonhome:= PYHOME64;  optional 
    //opendll(PYDLL64)
    loadDLL;
    autofinalize:= false;
    try
  3. [var as word type] Having a var as word type you get a type mismatch unless you change word to dword (list below)
    Example: DecodeDate( Date : TDateTime; var Year, Month, Day : Word);
    change var ttyear, ttMonth, ttDay : dWord;
    DecodeDate(now, ttYear,ttMonth, ttDay);
    use floatIsNan instead of isNan()
    use floorj() instead of floor()

  4. [inttoAscii instead of chr] some functions need IntToAscii( Value : Int64; Digits : Int) :Str; instead of chr() function
    2a // if (ex[2]) in strtochars(DIGISET) then writeln('in digiset'); wont work assign with c: char 👍
    c := ex[2];
    if c in strtochars(DIGISET) then writeln('in digiset');
    function IntToBinStr(AInt : LongWord) : string;
    begin
    Result := '';
    repeat
    Result := inttoAscii(Ord('0')+(AInt and 1),1)+Result;
    AInt := AInt div 2;
    until (AInt = 0);
    end;

  5. [enums or set] a few properties cant load a set of like //Font.Style:= [fsBold];
    just uncomment helps - on progress
    use Font.Style2:= FSStrikeout2;
    3b. [turtle lib] replace position with setpos()
    mp.x:= round(60p+300); //position on canvas
    mp.y:= round(60
    (11-q));
    //position:= mp
    setpos(mp.x, mp.y)

  6. [No mapping for the Unicode] debug: 341-No mapping for the Unicode character exists in the target multi-byte code page 863 err:20
    Then you have to save the file as UTF-8
    In menu ../Options/Saveas Unicode/ you can save code to UTF-8 with one click
    Attention it switches back to ANSI with another click! (no autocheck)
    if file load raise Exception: No mapping for the Unicode character exists
    in the target multi-byte code page at 0.146
    Then you must save the file as utf-8 with notepad or saveStringUC(path):
    procedure SaveString2(const AFile, AText: string);
    procedure SaveString3(const AFile, AText: string; Append: Boolean); //UTF8
    procedure SaveStringUC(const AFile, AText: string; Append: Boolean); //UTF8 - Unicode
    function LoadFile3(const FileName: TFileName): string;
    function LoadFileUC(const FileName: TFileName): string;
    combination test:
    writeln(loadfileUC(ExePath+’upsi_allfunctionslist2.txt’));
    sleep(700)
    savestringUC(ExePath+’upsi_allfunctionslist2save.txt’,
    loadfileUC(ExePath+’upsi_allfunctionslist2.txt’),true) //append
    Charset Function:
    function WideCharsInSet( wcstr:WideString; wcset:TBits):Boolean;
    function JSONUnescape(const Source: string; CRLF: string{ = Fillrect and windows.FillRect #13#10}): string;
    function ParseJsonvalue(jsonutf8: string): string;
    procedure setdebugcheck(false);
    Here you can find a completer UTF-8 chars conversion list:
    http://bueltge.de/wp-content/download/wk/utf-8_kodierungen.pdf
    look at in built mX5 class at the bottom
    SIRegister_flcUnicodeCodecs

  7. Use Saveloadlibrary() or teeloadlibrary instead loadlibrary; Use isinternerconnected instead of isinternet

Example with CharsetConversion from call to google translator REST API:

  1. trans atext:= 'bonjour mes amis da la ville of coding avec design';
  2. json escaped utf8 ["Hola mis amigos en la ciudad de codificaci\u00c3\u00b3n con dise\u00c3\u00b1o","fr"]
  3. trans back ParseJsonValue(): ["Hola mis amigos en la ciudad de codificación con diseño","fr"]
    writeln('mimecharset '+
    CharsetConversion(ParseJsonValue(Text_to_translate_API2(AURL,'dict-chrome-ex','auto','es',
    (atext))),UTF_8, ISO_8859_1));
  4. mimecharset ["Hola mis amigos en la ciudad de codificación con diseño","fr"]
    Example Parse JSON Array:
    writeln('len node names: '+itoa(ajar.length))
    for it:= 0 to jo2.length-1 do begin
    //writeln(JSONUnescape(jo2.getstring(jo2.keys[it]), Fillrect and windows.FillRect #13#10));
    writeln(CharsetConversion(parsejsonvalue(jo2.getstring(jo2.keys[it])),UTF_8,ISO_8859_1));
    //savstr:= savstr + jo2.getstring(jo2.keys[it]);
    savstr:= savstr +CharsetConversion(parsejsonvalue(jo2.getstring(jo2.keys[it])),UTF_8,ISO_8859_1);
    end;

StreamtoString new functions:

[Function TryMemoryStreamToString(const MS: TMemoryStream; var s: string): Boolean;
  begin
    Result:= False; if(MS=Nil) then Exit;
    try
      SetLength(s, MS.Size - MS.Position);
      writeln('debug size: '+itoa(length(s)));
      MS.Read(s, Length(s));
      Result:= True;
    except
      Result:= False;
    end;
  end;

Function TryStringToMemoryStream(const s: string; var MS: TMemoryStream):Boolean;
  begin
    Result:= False; if(MS=Nil) then Exit;
    try
      //SetLength(s, MS.Size - MS.Position);
      writeln('debug size2: '+itoa(length(s)));
      MS.Write(s, Length(s));
      Result:= True;
    except
      Result:= False;
    end;
  end;
](url)

Exception: Cannot assign a TStringList to a TStringList at 853.2446
Then you can change the stringlist to another stringlist for example THashedStringList.create;

 writ(MIDINoteToStr(note+36));
  mlist:= THashedStringList.create;
  GetMidiOutputs(mlist);
  writeln(mlist.text)
  mlist.free;

BmptoJPG is missing:
procedure Bmp2Jpeg_(const BmpFileName, JpgFileName: string);
  var
    Bmp: TBitmap; Jpg: TJPEGImage;
  begin
    Bmp := TBitmap.Create;
    Jpg := TJPEGImage.Create;
    try
      Bmp.LoadFromFile(BmpFileName);
      Jpg.Assign(Bmp);
      Jpg.SaveToFile(JpgFileName);
    finally
      Jpg.Free;
      Bmp.Free;
    end;
  end;

  procedure Jpeg2Bmp(const BmpFileName, JpgFileName: string);
  var
    Bmp: TBitmap; Jpg: TJPEGImage;
  begin
    Bmp := TBitmap.Create;
    Jpg := TJPEGImage.Create;
    try
      Jpg.LoadFromFile(JpgFileName);
      Bmp.Assign(Jpg);
      Bmp.SaveToFile(BmpFileName);
    finally
      Jpg.Free;
      Bmp.Free;
    end;
  end;

Unicode Encoding Decoding Charset UTF-8 Detection

In menu ../Options/Saveas Unicode/ you can save code to UTF-8 with one click
Attention it switches back to ANSI with another click! (no autocheck)
if file load raise Exception: No mapping for the Unicode character exists
in the target multi-byte code page at 0.146
Then you must save the file as utf-8 with notepad or saveStringUC(path):
procedure SaveString2(const AFile, AText: string);
procedure SaveString3(const AFile, AText: string; Append: Boolean); //UTF8
procedure SaveStringUC(const AFile, AText: string; Append: Boolean); //UTF8 - Unicode
function LoadFile3(const FileName: TFileName): string;
function LoadFileUC(const FileName: TFileName): string;
combination test:
writeln(loadfileUC(ExePath+’upsi_allfunctionslist2.txt’));
sleep(700)
savestringUC(ExePath+’upsi_allfunctionslist2save.txt’,
loadfileUC(ExePath+’upsi_allfunctionslist2.txt’),true) //append
Charset Function:
function WideCharsInSet( wcstr:WideString; wcset:TBits):Boolean;
function JSONUnescape(const Source: string; CRLF: string{ = #13#10}): string;
function ParseJsonvalue(jsonutf8: string): string;
procedure setdebugcheck(false);
Here you can find a completer UTF-8 chars conversion list:
http://bueltge.de/wp-content/download/wk/utf-8_kodierungen.pdf
look at in built mX5 class at the bottom
SIRegister_flcUnicodeCodecs

Example with CharsetConversion from call to google translator REST API:

  1. trans atext:= 'bonjour mes amis da la ville of coding avec design';
  2. json escaped utf8 ["Hola mis amigos en la ciudad de codificaci\u00c3\u00b3n con dise\u00c3\u00b1o","fr"]
  3. trans back ParseJsonValue(): ["Hola mis amigos en la ciudad de codificación con diseño","fr"]
    writeln('mimecharset '+
    CharsetConversion(ParseJsonValue(Text_to_translate_API2(AURL,'dict-chrome-ex','auto','es',
    (atext))),UTF_8, ISO_8859_1));
  4. mimecharset ["Hola mis amigos en la ciudad de codificación con diseño","fr"]

Example Parse JSON Array:
writeln('len node names: '+itoa(ajar.length))
for it:= 0 to jo2.length-1 do begin
//writeln(JSONUnescape(jo2.getstring(jo2.keys[it]), #13#10));
writeln(CharsetConversion(parsejsonvalue(jo2.getstring(jo2.keys[it])),UTF_8,ISO_8859_1));
//savstr:= savstr + jo2.getstring(jo2.keys[it]);
savstr:= savstr +CharsetConversion(parsejsonvalue(jo2.getstring(jo2.keys[it])),UTF_8,ISO_8859_1);
end;

const tname= 'Subject: =?iso-8859-1?Q?Die_besten_W=FCnsche_zum_Neuen_Jahr_2021?=';

writeln('mimecharset '+CharsetConversion(tn,ISO_8859_1, UTF_8));
writeln('mimecharset '+CharsetConversion(tname,ISO_8859_1, win_1252));
writeln( MimeCharsetToCharsetString(ISO_8859_1) );

solution: writeln(DecodeHeader(tname)); or writeln(ForceDecodeHeader(tname));
-----> Subject: Die besten Wünsche zum Neuen Jahr 2021
writeln(UTF8toAnsi(ALUTF8HTMLdecode('Kaufbestätigung')))
-----> Kaufbestätigung

Inconsistent Case with Charset Detection:
//UTF-8 -> Windows-1251 -> UTF-8 -> Windows-1256 ?
sr:= 'Desinfektionslösungstücher für Flächen';
//sr:= CharsetConversion(sr,UTF_8, win_1251)
writeln('mimecharset2 '+CharsetConversion(sr,UTF_8, win_1256));

mimecharset2 DesinfektionslÃ_sungstÃ_cher fÃ_r FlÃ_chen

  1. [SRE module mismatch] ebug: 59-AssertionError: SRE module mismatch 849 err:20 849 err:20
    Then its a python4delphi issue in multiinstaller of several 64-bit installation like
    C:\maxbox\maxbox5>py -0
    -V:3.12 * Python 3.12 (64-bit)
    -V:3.11 Python 3.11 (64-bit)
    -V:3.11-32 Python 3.11 (32-bit)
    -V:3.10-32 Python 3.10 (32-bit)
    -V:3.8 Python 3.8 (64-bit)
    The best you can get is to rename the last directory of Python install for exxample:
    C:\Users\User\AppData\Local\Programs\Python\Python312
    rename to C:\Users\User\AppData\Local\Programs\Python\Python312_
    then the remote interpreter shell uses V3.11 and so on

ordered list of [var as word type] in maxbox_functions
http://www.[softwareschule.ch/maxbox_functions.htm](http://www.softwareschule.ch/maxbox_functions.htm)
//line regex: Rex.Regex:= '(?i)(\bVar\b.*\bWord\b)'; not right

match all var of type :word but only of type word in a line
line regex: Rex.Regex:= '(?i)(\bVar\b([\w\s,]+(\s*:\s*))\bWord\b)';

0 648 Func DecLimit3( var B : Word; const Limit : Word; const Decr : Word) : Word;
1 655 Func DecLimitClamp3(var B:Word;const Limit: Word; const Decr : Word) : Word;
2 659 Func DecodeDateFully(DateTime: TDateTime; var Year,Month,Day,DOW:Word):Bool
3 1597 Func IncLimit3( var B : Word; const Limit : Word; const Incr : Word) : Word;
4 1604 Func IncLimitClamp3( var B : Word; const Limit : Word; const Incr : Word) : Word;
5 1689 Func InternalDecodeDate(DateTime:TDateTime;var Year,Month,Day,DOW:Word):Boolean
6 3073 Func WeekOfTheMonth1( const AValue : TDateTime; var AYear, AMonth : Word) : Word;
7 3075 Func WeekOfTheYear1( const AValue : TDateTime; var AYear : Word) : Word;
8 3424 Proc JDecodeDate( Date : TDateTime; var Year, Month, Day : Word);
9 3425 Proc DecodeDate1( Date : TDateTime; var Year : Int; var Month, Day : Word);
10 3475 Proc FileTimeToDosDateTime1( const FileTime : TFileTime; var Date, Time: Word);
11 3770 Proc DateDiff(Date1, Date2: TDateTime; var Days, Months, Years: Word);
12 4944 Proc DateDiff(Date1, Date2: TDateTime; var Days, Months, Years: Word);
13 5462 Proc IncLimW( var B : Word; const Limit : Word)
14 5467 Proc DecLimW( var B : Word; const Limit : Word)
15 5482 Proc SwapW( var B1, B2 : Word)
16 5887 Func Str2WordS(const S: ShortString; var I : Word) :Bool
17 5999 Proc SetFlag( var Flags : Word; FlagMask : Word)
18 6000 Proc ClearFlag( var Flags : Word; FlagMask : Word)
19 6009 Proc ExchangeWords( var I, J : Word)
20 6245 Proc ValWord( const S : ShortString; var Wd : word; var ErrorCode : Int)
21 6708 Func ExtractAssociatedIcon(hInst:HINST;lpIconPath:PChar;var lpiIcon:Word):HICON
22 8371 Proc ISOWeekNumber( const D : TDateTime; var WeekNumber, WeekYear : Word)
23 12860 Proc PtrInc( var P, Delta : Word)
24 12861 Proc PtrDec( var P, Delta : Word)
25 14514 //Proc VersionExtractFileInfo(const FixedInfo:TVSFixedFileInfo;var Major,Minor,Build,Revision:Word);
26 14515 //Proc VersionExtractProductInfo(const FixedInfo:TVSFixedFileInfo;var Major,Minor,Build,Revision:Word);
27 15207 Proc glDivMod( Dividend : Int; Divisor : Word; var Result, Remainder : Word)
28 16233 Proc cyAddMonths( var aMonth, aYear : Word; Months : Int);
29 18441 Func Str2WordL( const S : Ansistr; var I : Word) :Bool;
30 20444 Func GetAppVersion(const ALibName:str;var MajorVersion,MinorVersion,BuildNumber,RevisionNumber:Word):Bool;
31 21535 Proc SwapWord2( var x : word);
32 21607 Proc DecodeDatereal( Date : TDatetimeReal; var Year, Month, Day : Word);
33 21608 Proc DecodeDateTimereal(const AValue:TDatetimeReal;var Year,Month,Day,Hour,Minute,Second,MilliSecond:Word);
34 21609 Proc DecodeTimereal( Time : TDatetimeReal; var Hour, Min, Sec, MSec : Word);
35 21640 Func parsetimeISO(timestr:str;var hourval,minval,secval:word;var offsethourval,offsetminval:Int;var UTC:bool):bool;
36 21641 Func parsedateISO( datestr :Str; var yearval, monthval, dayval : word) :Bool;
37 21643 Proc jdtodate(jday:float; var year, month, day, hour, minute, second, msec : word);
38 21647 Proc getdatedos( var year, month, mday, wday : word);
39 21648 Proc gettimedos( var hour, minute, second, sec100 : word);
40 21664 Proc JulianToGregorian(JulianDN:big_Int_t;var Year,Month,Day:Word);;
41 21673 Func IsValidISODateStringExt(datestr:shortstring;strict:bool;var Year,Month,Day:word):bool;
42 21675 Func IsValidISOTimeStringExt(timestr:shortstring;strict:boolean;var hour,min,sec:word;var offhour,offmin: smallint):bool;
43 21680 Proc UNIXToDateTime2(epoch:big_Int_t; var year,month,day,hour,minute,second: Word);
44 22597 CRC16Init( var CRC16 : Word);
45 27738 Function GetHotkey( var pwHotkey : word) : HResult');
46 27786 Function azuJPEGDimensions( Filename : string; var X, Y : Word) : boolean');
47 30255 Procedure apiOsBuildInfo( var v1, v2, v3, v4 : word)');
48 31215 procedure(Sender: TObject; var Key: Word; Shift: TShiftState);
49 31328 Proc BooleansToBits1( var Dest : Word; const B : TBooleanArray);
50 31360 Proc cbPathKeyDown( Sender : TObject; var Key : Word; Shift : TShiftState)
51 31415 Proc ColorRGBToHLS( clrRGB : TColorRef; var Hue, Luminance, Saturation : Word)
52 31440 Proc CopyBytesToHostWord(const ASource:TIdBytes;const ASourceIndex:Int;var VDest: Word)
53 31480 Proc DecodeDate( DateTime : TDateTime; var Year, Month, Day : Word)
54 31481 Proc DecodeDate(const DateTime: TDateTime; var Year, Month, Day: Word);
55 31487 Proc DecodeTime( DateTime : TDateTime; var Hour, Min, Sec, MSec : Word)
56 31488 Proc DecodeTime(const DateTime: TDateTime; var Hour, Min, Sec, MSec: Word);
57 31525 Proc DivMod( Dividend : Int; Divisor : Word; var Result, Remainder : Word)
58 31769 Proc IncAMonth( var Year, Month, Day : Word; NumberOfMonths : Int)
59 31835 Proc ListViewKeyDown( Sender : TObject; var Key : Word; Shift : TShiftState)
60 32153 Proc SaveToClipboardFormat(var AFormat:Word; var AData: THandle; var APalette: HPALETTE)
61 32154 Proc SaveToClipboardFormat(var Format: Word; var Data : THandle; var APalette: HPALETTE)
62 32266 Proc SHORTCUTTOKEY( SHORTCUT : TSHORTCUT; var KEY : WORD; var SHIFT : TSHIFTSTATE)
63 32343 Proc SwapOrd3( var I, J : Word);
64 33099 Func WordIsOk(const AWord:Str; var VW: Word):Bool;
65 38410 Proc GetJPGSize(const sFile:Str; var wWidth, wHeight: Word);
66 38411 Proc GetPNGSize(const sFile:Str; var wWidth, wHeight: Word);
67 38413 Proc GetGIFSize(const sGIFFile:Str; var wWidth, wHeight: Word);
68 38667 Func ScanNumber(const S:Str; var Pos: Int; var Number: Word):Bool;
69 39130 Proc DecDay( var Year : Int; var Month, Day : Word);
70 39131 Proc DecDays( var Year : Int; var Month, Day : Word; const Days : Int);
71 39138 Proc FirstDayOfWeekYmd( var Year : Int; var Month, Day : Word);
72 39169 Proc diIncMonth( var Year : Int; var Month, Day : Word);
73 39170 Proc diIncMonths(var Year :Int; var Month, Day:Word; const NumberOfMonths:Int);
74 39171 Proc diIncDay( var Year : Int; var Month, Day : Word);
75 39172 Proc IncDays( var Year : Int; var Month, Day : Word; const Days : Int);
76 39199 Proc LastDayOfWeekYmd( var Year : Int; var Month, Day : Word);
77 43845 Example: DecodeDate( Date : TDateTime; var Year, Month, Day : Word);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions