translator, from BASIC to PASCAL (source code translator) lazarus / 21-General ---------------------------------------------------------------------- juanirias · 2021-08-16 16:17 Hi Please need to compile the code attached, is taken from : https://www.exmortis.narod.ru/src_translate_eng.html ---------------------------------------------------------------------- wp · 2021-08-16 16:28 Add {$mode tp} at the top of the file to make it compile. ---------------------------------------------------------------------- juanirias · 2021-08-16 16:59 Thanks, can see the comments? I have a lot of stranger symbols... ---------------------------------------------------------------------- wp · 2021-08-16 17:40 Open the file in Notepad++, in the statusbar you see that it detects the encoding of the file as OEM866. In Notepad++, select "Encoding" > "Convert to UTF8 without BOM", save. When you now open the file in Lazarus, the comments should be correct. ---------------------------------------------------------------------- winni · 2021-08-16 17:58 Hi! wp was faster but I've got a simple Lazarus solution: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TForm1.Button1Click(Sender: TObject);var st : TStringList;begin   st := TStringList.create;   st.LoadFromFile('./CROSS.PAS');   st.text := CP866ToUTF8(st.text);   showMessage (st.text);   st.saveToFile('./CROSSutf8.pas');   st.free;end;  Winni PS.: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses ...,LConvencoding; ---------------------------------------------------------------------- juanirias · 2021-08-16 21:47 Quote from: wp on August 16, 2021, 07:40:26 pmOpen the file in Notepad++, in the statusbar you see that it detects the encoding of the file as OEM866. In Notepad++, select "Encoding" > "Convert to UTF8 without BOM", save. When you now open the file in Lazarus, the comments should be correct. Could share the file, I'm under Linux, I cannot see anything! ---------------------------------------------------------------------- winni · 2021-08-16 22:10 Quote from: juanirias on August 16, 2021, 11:47:06 pm Could share the file, I'm under Linux, I cannot see anything! Use my shown solution. No problems with Linux. Winni ---------------------------------------------------------------------- wp · 2021-08-16 22:34 Once you know that the encoding of the file is OEM866, you can also load the file into the Lazarus IDE. Right-click on the editor and select "File Settings" > "Encoding" > "cp866" > "Reopen with another encoding". This tells the IDE the correct file encoding - the file should be displayed correctly now. However, since Lazarus normally works with UTF8 files you should convert the file to UTF8. Repeat "File Settings" > "Encoding", but now select the top item "UTF8" and click on "Change File" rather than "Reopen with another encoding"Make a backup copy of the original file - it is very easy to select the wrong steps here. ---------------------------------------------------------------------- juanirias · 2021-08-17 15:07 Thanks! I want to translate some old GW-BASIC source code, but cant with this.... regards ---------------------------------------------------------------------- winni · 2021-08-17 16:52 Quote from: jamie on August 17, 2021, 05:44:02 pmMemory tells me that gw basic was tokenized . Right! There was the  strange syntax in gwbasic to save as ASCII: Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i save  mybasic.bas,a  No "Basic" option in the Code Menu of the Forum software ..... Winni ---------------------------------------------------------------------- juanirias · 2021-08-17 17:04 Dear all Could you try to compile the source code *.pas I have this errors: bp.pas : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpc "bp.pas" (in directory: /home/developer/wip/MetOrbDet/BasPas)Free Pascal Compiler version 3.2.0+dfsg-12 [2021/01/25] for x86_64Copyright (c) 1993-2020 by Florian Klaempfl and othersTarget OS: Linux for x86-64Compiling bp.pasbp.pas(102,17) Warning: Local variable "a" of a managed type does not seem to be initializedbp.pas(185,33) Warning: Local variable "dummy3" of a managed type does not seem to be initializedbp.pas(358,55) Error: Call by var for arg no. 1 has to match exactly: Got "AnsiString" expected "ShortString"bp.pas(385,31) Error: Call by var for arg no. 1 has to match exactly: Got "AnsiString" expected "ShortString"bp.pas(405,37) Error: Call by var for arg no. 1 has to match exactly: Got "AnsiString" expected "ShortString"bp.pas(733,47) Error: Call by var for arg no. 1 has to match exactly: Got "AnsiString" expected "ShortString"bp.pas(738,47) Error: Call by var for arg no. 1 has to match exactly: Got "AnsiString" expected "ShortString"bp.pas(784,55) Error: Call by var for arg no. 1 has to match exactly: Got "AnsiString" expected "ShortString"bp.pas(1083,36) Error: String types have to match exactly in $V+ modebp.pas(1433) Fatal: There were 7 errors compiling module, stoppingFatal: Compilation abortedError: /usr/bin/ppcx64 returned an error exitcodeCompilation failed.  rbp.pas Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpc "rbp.pas" (in directory: /home/developer/wip/MetOrbDet/BasPas)Free Pascal Compiler version 3.2.0+dfsg-12 [2021/01/25] for x86_64Copyright (c) 1993-2020 by Florian Klaempfl and othersTarget OS: Linux for x86-64Compiling rbp.pasrbp.pas(93,40) Error: Call by var for arg no. 1 has to match exactly: Got "AnsiString" expected "ShortString"rbp.pas(132) Fatal: There were 1 errors compiling module, stoppingFatal: Compilation abortedError: /usr/bin/ppcx64 returned an error exitcodeCompilation failed.  thanks! ---------------------------------------------------------------------- winni · 2021-08-17 17:25 Hi! Turbo mode is not sufficent. You also have to activate  the shortstrings. Insert: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Program cross; {$mode tp}{$H-}  ......  Then everything compiles fine. Background: The source is often looking for myString[0]. This is the length byte with ShortStrings (Turbo days ) But this is not allowed with AnsiStrings. Winni ---------------------------------------------------------------------- juanirias · 2021-08-17 17:30 Please review the new attachment regards, Juan Quote from: juanirias on August 17, 2021, 07:04:55 pmDear all Could you try to compile the source code *.pas I have this errors: bp.pas : Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpc "bp.pas" (in directory: /home/developer/wip/MetOrbDet/BasPas)Free Pascal Compiler version 3.2.0+dfsg-12 [2021/01/25] for x86_64Copyright (c) 1993-2020 by Florian Klaempfl and othersTarget OS: Linux for x86-64Compiling bp.pasbp.pas(102,17) Warning: Local variable "a" of a managed type does not seem to be initializedbp.pas(185,33) Warning: Local variable "dummy3" of a managed type does not seem to be initializedbp.pas(358,55) Error: Call by var for arg no. 1 has to match exactly: Got "AnsiString" expected "ShortString"bp.pas(385,31) Error: Call by var for arg no. 1 has to match exactly: Got "AnsiString" expected "ShortString"bp.pas(405,37) Error: Call by var for arg no. 1 has to match exactly: Got "AnsiString" expected "ShortString"bp.pas(733,47) Error: Call by var for arg no. 1 has to match exactly: Got "AnsiString" expected "ShortString"bp.pas(738,47) Error: Call by var for arg no. 1 has to match exactly: Got "AnsiString" expected "ShortString"bp.pas(784,55) Error: Call by var for arg no. 1 has to match exactly: Got "AnsiString" expected "ShortString"bp.pas(1083,36) Error: String types have to match exactly in $V+ modebp.pas(1433) Fatal: There were 7 errors compiling module, stoppingFatal: Compilation abortedError: /usr/bin/ppcx64 returned an error exitcodeCompilation failed.  rbp.pas Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i fpc "rbp.pas" (in directory: /home/developer/wip/MetOrbDet/BasPas)Free Pascal Compiler version 3.2.0+dfsg-12 [2021/01/25] for x86_64Copyright (c) 1993-2020 by Florian Klaempfl and othersTarget OS: Linux for x86-64Compiling rbp.pasrbp.pas(93,40) Error: Call by var for arg no. 1 has to match exactly: Got "AnsiString" expected "ShortString"rbp.pas(132) Fatal: There were 1 errors compiling module, stoppingFatal: Compilation abortedError: /usr/bin/ppcx64 returned an error exitcodeCompilation failed.  thanks! ---------------------------------------------------------------------- juanirias · 2021-08-18 16:24 I cant compile ... Help please ---------------------------------------------------------------------- winni · 2021-08-18 16:37 Quote from: juanirias on August 18, 2021, 06:24:11 pmI cant compile ... I also cant compile. The compiler does it!!! Show us the error message. And get used to it! Winni ---------------------------------------------------------------------- wp · 2021-08-18 16:38 These are my steps: At the top of the file, add {$MODE TP}{$H-}Compilation attempt --> For variable basic Error "Got Ansitring expected ShortString". Solution: basfile, pasfile are declared as AnsiString. Not sure, but I think this type does not exist in Turbo Pascal mode -> declare them as StringNext compilation attempt --> Error in FSplit(...): "String types have to match exactly in $V+ mode" --> Declare bPath, bName and bExt as String rather than String[100]Next compilation attempt --> successfulI am attaching the modified file. ---------------------------------------------------------------------- juanirias · 2021-08-18 17:48 Thanks! now I have this error: developer@Nitro-AN515-54:~/wip/MetOrbDet/BasPas$ ./bp TAYLOR.BAS You compile TAYLOR.BAS with BasPas Version 0.602 Written by Andrea Tobian-Mezger 2003 Show also on:  http://groups.yahoo.com/group/BasPas for informations and files An unhandled exception occurred at $0000000000406505: EInOutError: File not open   $0000000000406505 ---------------------------------------------------------------------- juanirias · 2021-09-13 03:25 A kind reminder; I request help ---------------------------------------------------------------------- af0815 · 2021-09-13 05:29 BTW: Your link to the group is not working. QuoteEInOutError: File not openHave you looked for the file, which is not open. ---------------------------------------------------------------------- juanirias · 2021-09-14 03:37 is correct, the group no longer exists! the code was taken from here: https://www.exmortis.narod.ru/src_translate_eng.html/ regards, JUAN ---------------------------------------------------------------------- juanirias · 2022-04-18 02:50 Hi! Here 2 original source code for the same objective: take a BASIC file and convert to PASCAL. Please review and try to get working please  regards, JUAN ---------------------------------------------------------------------- Handoko · 2022-04-18 07:21 Thank  you for sharing it. Unfortunately I can't compile it using Lazarus 2.2.0. Got a compile- time error in ReplaceOutSBP function in bp.pas because it breaks the rule of immutable requirement. See the screenshot below and read the link: https://wiki.freepascal.org/For#immutable_requirement ---------------------------------------------------------------------- juanirias · 2022-04-21 22:38 Thanks for answer... regards, Juan ---------------------------------------------------------------------- Zvoni · 2022-04-22 06:23 Quote from: juanirias on April 22, 2022, 12:38:23 amThanks for answer... regards, Juan Never change the iteration-variable of a For-loop in code Use Do While/Repeat Until ---------------------------------------------------------------------- juanirias · 2022-04-25 00:43 I cant understand well, you can compile it ?! It works ? regards, Juan ---------------------------------------------------------------------- Handoko · 2022-04-25 05:11 I cannot compile it. The error is in the line #188 in ReplaceOutSBP function in bp.pas. I tested it using Lazarus 2.2.0 FPC 3.2.2. ---------------------------------------------------------------------- juanirias · 2022-04-26 23:38 Thanks for answer.