Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows
On Sa, 2016-07-23 at 05:55 +0200, Marc Santhoff wrote: > On Fr, 2016-07-22 at 18:20 -0400, James Richters wrote: > > I'm trying to avoid custom hardware if possible. I have always used > > parallel ports and never had a problem with them until now. I like the > > idea of a parallel port because they are still built onto motherboards, and > > there are also a TON of USB to parallel port adapters out there. I'm > > trying to keep this simple. > > > > I put a repository of my test program here: > > https://github.com/Zaaphod/FPC-Parallel-Port. Perhaps someone can see what > > I'm doing wrong.I'm reading 255s no matter what I do.I included my > > old turbo pascal test program. I would normally specify the port in hex > > with a $ like this $378. I could write to the port then read back what I > > just wrote.. which is what I am trying to do now.. I don't have anything > > hooked up to the port yet, I should be able to write to it and read it back. > > > > I seem to be accessing the DLL correctly, because I tried it on a windows 7 > > computer and IsInpOutDriverOpen was false, because I forgot to install the > > driver, once I installed the driver IsInpOutDriverOpen is now true, so that > > tells me I'm accessing the DLL and the DLL is confirming the driver is open. > > >From what I know, although it may be a bit outdated, on windows external > functions have to be declared 'cdecl'. Which isn't so in the library > port to pascal. > > One example: > > implementation > Function IsInpOutDriverOpen; external 'inpout32.DLL'; > > would then be: > > implementation > Function IsInpOutDriverOpen; cdecl; external 'inpout32.DLL'; No, sorry. It has to be the other way round: Function IsInpOutDriverOpen; {$ifndef Win32}cdecl{$else}stdcall{$endif}; external 'inpout32.DLL'; I didn't recognize that it is $ifndef, not $ifdef. Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows
On Fr, 2016-07-22 at 18:20 -0400, James Richters wrote: > I'm trying to avoid custom hardware if possible. I have always used > parallel ports and never had a problem with them until now. I like the > idea of a parallel port because they are still built onto motherboards, and > there are also a TON of USB to parallel port adapters out there. I'm > trying to keep this simple. > > I put a repository of my test program here: > https://github.com/Zaaphod/FPC-Parallel-Port. Perhaps someone can see what > I'm doing wrong.I'm reading 255s no matter what I do.I included my > old turbo pascal test program. I would normally specify the port in hex > with a $ like this $378. I could write to the port then read back what I > just wrote.. which is what I am trying to do now.. I don't have anything > hooked up to the port yet, I should be able to write to it and read it back. > > I seem to be accessing the DLL correctly, because I tried it on a windows 7 > computer and IsInpOutDriverOpen was false, because I forgot to install the > driver, once I installed the driver IsInpOutDriverOpen is now true, so that > tells me I'm accessing the DLL and the DLL is confirming the driver is open. >From what I know, although it may be a bit outdated, on windows external functions have to be declared 'cdecl'. Which isn't so in the library port to pascal. One example: implementation Function IsInpOutDriverOpen; external 'inpout32.DLL'; would then be: implementation Function IsInpOutDriverOpen; cdecl; external 'inpout32.DLL'; HTH, Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Linux Port help
On 2016-07-23 01:15, James Richters wrote: > forgetting that linux is extremely case sensitive with everything.. I saved > one with a .pas extention, closed it then opened it and now that one file > has the highlight, the others do not.. easy enough to fix that though. You can also tell Text IDE what file extensions are Pascal files. I saw the setting somewhere under Options -> Environment I think. But I would recommend you stick to all lowercase filenames. > I can't figure out how to do that with windows. You can't with the default console window. You need to download a 3rd party console program. They tend to be MUCH better that the stock console under Windows. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Linux Port help
I checked and syntax highlight was already checked.. I did figure it out though.. all my pascal files were named with a .PAS extension and I keep forgetting that linux is extremely case sensitive with everything.. I saved one with a .pas extention, closed it then opened it and now that one file has the highlight, the others do not.. easy enough to fix that though. Thank you for the help and suggestions to tweak the colors! I would have never figured that out! Nice I can customize it too. I can't figure out how to do that with windows. I would like to get a black background instead of blue. Thanks also for the suggestion of MSEIde I will check it out! -Original Message- From: fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of Graeme Geldenhuys Sent: Friday, July 22, 2016 7:41 PM To: fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] Linux Port help On 2016-07-22 23:33, James Richters wrote: > Here are screenshots: > https://github.com/Zaaphod/FPC-Parallel-Port/issues/1 I just checked. My FreeBSD version looks like the Windows screenshot. Also under Linux, load the IDE, then go to Options -> Environment -> Editor. Then under "Editor options" make sure "Syntax highlighting" is checked. If I uncheck that and open a new *.pas file, then mine is all blue and yellow text. Something else to tweak. If you prefer the darker blue (Windows screenshot) instead of the lighter blue (Linux screenshot). Those colors are affected by your terminal program's console theme. eg: I use Mate Terminal here. Go to Edit -> Profile Preferences -> Colours. Change the Palette scheme to "Linux console" or "Rxvt". Those are my preferences. Some Linux systems default that to "Tango" which are much lighter colours. > I like the text ide because I understand it, it's pretty much like > the Turbo Pascal ide. I fully understand. Sometimes I use the Text IDE too, to get rid of all clutter and distractions seen so often in other IDE's or text editors. But I forgot all the keyboard shortcuts, then I get frustrated with it, and switch back to Lazarus or MSEide. MSEide is also a very nice, flexible and super fast IDE. They can all handle console programs without problems. MSEide https://sourceforge.net/projects/mseide-msegui/ You can download the IDE zip archive, unpack and run the binary. No need for any installations. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Linux Port help
On 2016-07-22 23:33, James Richters wrote: > Here are screenshots: > https://github.com/Zaaphod/FPC-Parallel-Port/issues/1 I just checked. My FreeBSD version looks like the Windows screenshot. Also under Linux, load the IDE, then go to Options -> Environment -> Editor. Then under "Editor options" make sure "Syntax highlighting" is checked. If I uncheck that and open a new *.pas file, then mine is all blue and yellow text. Something else to tweak. If you prefer the darker blue (Windows screenshot) instead of the lighter blue (Linux screenshot). Those colors are affected by your terminal program's console theme. eg: I use Mate Terminal here. Go to Edit -> Profile Preferences -> Colours. Change the Palette scheme to "Linux console" or "Rxvt". Those are my preferences. Some Linux systems default that to "Tango" which are much lighter colours. > I like the text ide because I understand it, it's pretty much like the > Turbo Pascal ide. I fully understand. Sometimes I use the Text IDE too, to get rid of all clutter and distractions seen so often in other IDE's or text editors. But I forgot all the keyboard shortcuts, then I get frustrated with it, and switch back to Lazarus or MSEide. MSEide is also a very nice, flexible and super fast IDE. They can all handle console programs without problems. MSEide https://sourceforge.net/projects/mseide-msegui/ You can download the IDE zip archive, unpack and run the binary. No need for any installations. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Linux Port help
Yes, they are both 1.0.12 included with fpc 3.0.0 Here are screenshots: https://github.com/Zaaphod/FPC-Parallel-Port/issues/1 I like the text ide because I understand it, it's pretty much like the Turbo Pascal ide. I tried installing lazerus and I cannot even compile my program with that... but it's not a windows program, it's a console application, so that's probably why I couldn't get it to compile with lazerus. -Original Message- From: fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of Graeme Geldenhuys Sent: Friday, July 22, 2016 6:18 PM To: fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] Linux Port help On 2016-07-22 21:38, James Richters wrote: > Linux is just all yellow on light blue. The windows one for example > will show comments in grey reserved words in white.. ect.. > it makes it a lot easier to follow Are they the same versions of the IDE? I don't really use the Text IDE, but I can say that the FreeBSD version behaves like the Linux version you describe the old Turbo Pascal IDE look and feel. I've never tried the Text IDE under Windows. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Vehicle Routing Problem with Time Windows
As you might know, the VRP and many of its variants are NP-Complete problems. So one could solve an instance of these problems by generating an ILP instance(https://en.wikipedia.org/wiki/Vehicle_routing_problem). There are many academic publications about how to find a sub-optimal solution in polynomial time (just search scholar.google.com). It looks like Wikipedia listed a couple of open source/free software for solving this problem. Amir On 07/22/2016 06:14 AM, Dimitrios Chr. Ioannidis wrote: Hi, does anyone knows any object pascal or c ( not c++, java, lisp ... ) library that can solve the Vehicle Routing Problem with Time Windows, open source or not ? Searched but couldn't find any ... regards, ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
On 7/22/16, Jonas Maebewrote: >> ResultA := AnsiToUTF8(AnsiStrA + AnsiStrA); // UTF-8 ResultB := >> AnsiToUTF8(AnsiStrA) + AnsiToUTF8(AnsiStrA); // Win-1252 >> >> >> And resultA is not equal to ResultB >> >> It doesn't look like too intuitive. > > It would be good if someone with access to Delphi 2009+ could test this. I asked on Dutch Delphi forum if someone could test with D2009 or up. Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows
I'm trying to avoid custom hardware if possible. I have always used parallel ports and never had a problem with them until now. I like the idea of a parallel port because they are still built onto motherboards, and there are also a TON of USB to parallel port adapters out there. I'm trying to keep this simple. I put a repository of my test program here: https://github.com/Zaaphod/FPC-Parallel-Port. Perhaps someone can see what I'm doing wrong.I'm reading 255s no matter what I do.I included my old turbo pascal test program. I would normally specify the port in hex with a $ like this $378. I could write to the port then read back what I just wrote.. which is what I am trying to do now.. I don't have anything hooked up to the port yet, I should be able to write to it and read it back. I seem to be accessing the DLL correctly, because I tried it on a windows 7 computer and IsInpOutDriverOpen was false, because I forgot to install the driver, once I installed the driver IsInpOutDriverOpen is now true, so that tells me I'm accessing the DLL and the DLL is confirming the driver is open. -Original Message- From: fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of Mark Morgan Lloyd Sent: Friday, July 22, 2016 5:39 PM To: fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows James Richters wrote: I was rather rushed earlier for reasons that would probably amuse but would be vastly OT (shoving sheep around Sussex since we're shearing Saturday...). > I like the looks of that Velleman K8055, that would do the job for me if I > can get it to work. I would actually prefer a linux port of my program The Velleman boards usually come as kits, but they use PTH components and are a doddle to assemble. My recollection is that the K8055 came with something crude that allowed you to interface from e.g. Visual Basic, however I found that somebody had reverse-engineered it and produced a library (?) for Linux... I can't remember whether this was C or Pascal. I used this with Lazarus (the IDE and class library that sits on top of FPC) to produce something similar to Velleman's own demo app, you'd obviously be welcome to this. However in the general case I think it would be worth bearing in mind that functionality of the Velleman board could fairly easily be implemented using appropriate firmware on an Arduino, and this is likely to be more "future proof" than a demo kit. But I don't have any ready URLs etc. > however I keep hitting a roadblock when I try to use the graph unit. > My program used the turbo pascal graph unit exclusively for it's user > interface and I'm trying to avoid re-writing the entire thing. It > works fine in windows, but when I try to run it on linux I can't get > it to compile, it can't find the graph unit. I may have some > directories set wrong or something, I'm not sure, but that's what's holding me up on a linux port. Can't comment on that, but I see Graham's lending a hand. Particularly if you're porting to Linux you do need to consider whether you're planning to run in the context of a GUI or over SSH etc, what /exactly/ are you trying to display and on what sort of system? -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Linux Port help
On 2016-07-22 21:38, James Richters wrote: > Linux is just all yellow on light blue. The windows > one for example will show comments in grey reserved words in white.. ect.. > it makes it a lot easier to follow Are they the same versions of the IDE? I don't really use the Text IDE, but I can say that the FreeBSD version behaves like the Linux version you describe the old Turbo Pascal IDE look and feel. I've never tried the Text IDE under Windows. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows
James Richters wrote: I was rather rushed earlier for reasons that would probably amuse but would be vastly OT (shoving sheep around Sussex since we're shearing Saturday...). I like the looks of that Velleman K8055, that would do the job for me if I can get it to work. I would actually prefer a linux port of my program The Velleman boards usually come as kits, but they use PTH components and are a doddle to assemble. My recollection is that the K8055 came with something crude that allowed you to interface from e.g. Visual Basic, however I found that somebody had reverse-engineered it and produced a library (?) for Linux... I can't remember whether this was C or Pascal. I used this with Lazarus (the IDE and class library that sits on top of FPC) to produce something similar to Velleman's own demo app, you'd obviously be welcome to this. However in the general case I think it would be worth bearing in mind that functionality of the Velleman board could fairly easily be implemented using appropriate firmware on an Arduino, and this is likely to be more "future proof" than a demo kit. But I don't have any ready URLs etc. however I keep hitting a roadblock when I try to use the graph unit. My program used the turbo pascal graph unit exclusively for it's user interface and I'm trying to avoid re-writing the entire thing. It works fine in windows, but when I try to run it on linux I can't get it to compile, it can't find the graph unit. I may have some directories set wrong or something, I'm not sure, but that's what's holding me up on a linux port. Can't comment on that, but I see Graham's lending a hand. Particularly if you're porting to Linux you do need to consider whether you're planning to run in the context of a GUI or over SSH etc, what /exactly/ are you trying to display and on what sort of system? -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
On 22/07/16 21:49, Santiago A. wrote: El 22/07/2016 a las 17:56, Jonas Maebe escribió: There is no hidden secret knowledge. Everything is documented and the information is linked from the release notes. The "principle of least surprise" has been applied in the sense that we didn't invent our own system that introduces small or large differences compared to how Delphi behaves in the same situation (and if there are differences, then those are bugs in our implementation). With hidden knowledge I don't mean it's not documented, I mean that's like small print in contracts. How much more prominent can it be when it's in the release notes? Only those who know there is trick with adding are going to check manual. Complex things and pushing the language to its limits could require reading manual, adding two strings shouldn't. You don't have to read the manual. You have to read the release notes. MyString := expression I really shouldn't need to know if right expression uses '+', or the result of a function, or '*', to guess what MyString type is. And maybe you shouldn't, because maybe there is a bug in FPC. But I don't have Delphi 2009 and hence I cannot test. In addition, changing the codepage on the fly if a bad idea. If I cant change the codepage dynamically (I don't like it, but let's live with it), let me assign it explicitly, don't change it on the fly. You can do that if you only use RawByteString. I doubt you'll find it very convenient. I don't like automatic conversion, but let's live with it. But I think that automatic change of var type is really wrong. I don't understand what you mean with this. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Linux Port help
Thank you for the F11 suggestion.. F11 does make the IDE window full screen, Thanks!! That's very helpful. My program however does not respond to F11. There is no way to resize the window, make it larger or smaller or full screen, it's just a fixed size window.. this is the version using ptcgraph Is there a way to get the linux text mode IDE to colorize things like the windows text mode IDE? Linux is just all yellow on light blue. The windows one for example will show comments in grey reserved words in white.. ect.. it makes it a lot easier to follow -Original Message- From: fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of Graeme Geldenhuys Sent: Friday, July 22, 2016 4:28 PM To: fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] Linux Port help On 2016-07-22 20:59, James Richters wrote: > 4. not full screen. For some reason I can't get it to be full screen > in linux at all.. Press F11. That is a almost universal shortcut for any X11 desktop environment and Window Manager to switch the active program to full screen. If you are running the program in a Console login (ie: no X11 running), then in should be fullscreen as standard. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
On 2016-07-22 20:49, Santiago A. wrote: > In addition, changing the codepage on the fly if a bad idea. +1 I think that is very much the wrong behaviour too. As I mentioned before is this mailing list. I think the FPC 3.x with these codepage aware AnsiStrings is a damn mess. As far as I can see, FPC is now worse that Delphi 2009 was. And NO, don't tell me everything should work as it did before... It doesn't!! This thread just proves that one more time. Regards, Graeme ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Linux Port help
On 2016-07-22 20:59, James Richters wrote: > 4. not full screen. For some reason I can't get it to be full screen in > linux at all.. Press F11. That is a almost universal shortcut for any X11 desktop environment and Window Manager to switch the active program to full screen. If you are running the program in a Console login (ie: no X11 running), then in should be fullscreen as standard. Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Linux Port help
I'm a newbie trying to port an old turbo pascal program to FreePascal in linux. My reasons for doing this is old Pentium 233 motherboards are getting harder to keep running and I need be running on more modern hardware.. It's a massive program and I just don't have time to re-write the whole thing, that's why freepascal seems like a good solution. I have it working fairly well on windows, but I'm trying to get away from windows, and get it working on linux instead. I've managed to get free pascal installed on an Ubuntu x64 virtualbox VM and I can run the IDE, but I'm having difficulty getting it to work. I have several issues I just don't know how to solve 1. graph unit issues.In my windows port I'm able to use graph unit, in linux there is no graph unit in the x86_64-linux folder. It does exist in i386-linux, but I can't seem to compile my program for 386. In the windows version I have an option to use 80386, in linux I do not. I have tried to use the other graphic units found in graph under x86_64 linux. I was able to successfully compile with ptcgraph, but everything is blue, I figure it is using more colors than my old 16, so I changed a few colors to larger numbers and sure enough I can get other colors... so I could do global searches and replaces to solve the color issue.. but I have other issues with ptcgraph and/or linux. If I try to use ggigraph, I cannot even compile it. It says "Error while linking" and it references the END. Line at the end of my main program.. I don't know why, there is nothing wrong with that line and it compiles with ptcgraph just fine. 2. I can't get my fonts to work with ptcgraph. I was using the turbo pascal graphic fonts, I was able to get them working in windows, but not in the linux version. I'm not sure if it's an issue with ptcgraph or linux or how to even start to figure out the problem. 3. with ptcgraph, I have no control of the keyboard. When I run from the compiler, I must pop up the terminal window on top of my graphics window to be able to use the keyboard, however if I try to run the compiled program on it's own, I don't have a terminal window.. and I just have no control over the program.. I have my graphic screen, but it ignores the keyboard, and I can't do anything with it. The windows version also has the Dos window, but it allows it to remain behind the graphic window and my keyboard still works. 4. not full screen. For some reason I can't get it to be full screen in linux at all.. Its always in a window. The windows version is ALMOST full screen, I would like to get rid of the windows bar across the top and make it truly full screen. I don't need a way to minimize it or to use any windows controls, when I'm done with it I can just close it and be back in windows. Any suggestions on how to either use the original 'graph' unit or how to change to something else and retain functionality? All I want to do is make my program look and operate the way it did on DOS with turbo pascal. I don't want to redesign the entire thing. The windows version is close but as I mentioned I would love to get rid of the windows bar across the top of the screen and make it truly full screen. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
El 22/07/2016 a las 17:56, Jonas Maebe escribió: > > There is no hidden secret knowledge. Everything is documented and the > information is linked from the release notes. The "principle of least > surprise" has been applied in the sense that we didn't invent our own > system that introduces small or large differences compared to how > Delphi behaves in the same situation (and if there are differences, > then those are bugs in our implementation). With hidden knowledge I don't mean it's not documented, I mean that's like small print in contracts. Only those who know there is trick with adding are going to check manual. Complex things and pushing the language to its limits could require reading manual, adding two strings shouldn't. MyString := expression I really shouldn't need to know if right expression uses '+', or the result of a function, or '*', to guess what MyString type is. In addition, changing the codepage on the fly if a bad idea. If I cant change the codepage dynamically (I don't like it, but let's live with it), let me assign it explicitly, don't change it on the fly. SetCodePage(MyString,win1252); MyString := AnsiToUTF8(Ansi1 + Ansi2); // Automatically converted to Win-1252 before assign MyString := AnsiToUTF8(Ansi1) + AnsiToUTF8(Ansi2); // Automatically converted to Win-1252 before assign SetCodePage(MyString,utf8); MyString := AnsiToUTF8(Ansi1 + Ansi2); // No conversion needed MyString := AnsiToUTF8(Ansi2) + AnsiToUTF8(Ansi2); // No conversion needed MyString := Ansi1 + Ansi2; // Automatically converted to Utf8 before assign None changes the codepage of the String but me I don't like automatic conversion, but let's live with it. But I think that automatic change of var type is really wrong. This is Pascal, not bash or PHP. -- Saludos Santiago A. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows
I like the looks of that Velleman K8055, that would do the job for me if I can get it to work. I would actually prefer a linux port of my program however I keep hitting a roadblock when I try to use the graph unit. My program used the turbo pascal graph unit exclusively for it's user interface and I'm trying to avoid re-writing the entire thing. It works fine in windows, but when I try to run it on linux I can't get it to compile, it can't find the graph unit. I may have some directories set wrong or something, I'm not sure, but that's what's holding me up on a linux port. -Original Message- From: fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of Mark Morgan Lloyd Sent: Friday, July 22, 2016 10:19 AM To: fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows James Richters wrote: > What I need to do is be able to read some 5v TTL Inputs in and write > some 5v TTL outputs out. The parallel port always worked when my > program was a DOS program.. it was so simple, just do Port[$378]:= data to set the bits on the > port or data:=port[$378] to read some bits from the port. I'm not opposed > to some hardware other than a parallel port if it will be able to interface > with freepascal easily, if anyone can make a recommendation. Serial ports > won't work because they are not made to just read and write bits like > the parallel port and they are not TTL voltage levels. Something like a Velleman K8055, which I've talked to using libusb on Linux. Or an Arduino with appropriate firmware. Or go the whole hog and port the program onto a Raspberry Pi: Bo's doing something like you're asking. Any of those have the advantage that the electronics can be positioned to minimise the signal run carrying TTL. Long printer cables are generally bad news. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows
Thank you! I was indeed trying to use the 64bit DLL.. I mistakenly thought you were supposed to use the version of the operating system, not the program. I have absolutely zero experience with windows programs. I am able to run my program now, but still not working exactly as I want it to work.. but I think I might need to set my port to the right mode.. so I'll see if that works. -Original Message- From: fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of Marc Santhoff Sent: Friday, July 22, 2016 10:56 AM To: fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows > > When I try to run it, I get a windows message The application was > unable to > > start correctly (0xc07b). click ok to close the application. > > You could search Microsofts web site to decode this error. Or use a search engine: http://www.techanges.com/fix-error-0xc7b/ http://stackoverflow.com/questions/10492037/the-application-was-unable-to-st art-correctly-0xc07b Looks like you are using a 32 Bit version on 64 bit or the like. The original site tells about similar error: http://www.highrez.co.uk/downloads/inpout32/ Look at the update history... Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
On 22/07/16 17:33, Santiago A. wrote: So ResultA := AnsiToUTF8(AnsiStrA + AnsiStrA); // UTF-8 ResultB := AnsiToUTF8(AnsiStrA) + AnsiToUTF8(AnsiStrA); // Win-1252 And resultA is not equal to ResultB It doesn't look like too intuitive. It would be good if someone with access to Delphi 2009+ could test this. It is possible that the result of concatenating two RawByteStrings should again be a RawByteString and that hence no conversion should happen on assignment here either. I would say that it is closer to "hidden secret knowledge" than to the "Principle of least surprise". There is no hidden secret knowledge. Everything is documented and the information is linked from the release notes. The "principle of least surprise" has been applied in the sense that we didn't invent our own system that introduces small or large differences compared to how Delphi behaves in the same situation (and if there are differences, then those are bugs in our implementation). Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
El 22/07/2016 a las 15:03, Jonas Maebe escribió: > > See again > http://wiki.freepascal.org/FPC_Unicode_support#String_concatenations > (same as before). So ResultA := AnsiToUTF8(AnsiStrA + AnsiStrA); // UTF-8 ResultB := AnsiToUTF8(AnsiStrA) + AnsiToUTF8(AnsiStrA); // Win-1252 And resultA is not equal to ResultB It doesn't look like too intuitive. I would say that it is closer to "hidden secret knowledge" than to the "Principle of least surprise". -- Saludos Santiago A. s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows
On Do, 2016-07-21 at 05:29 +0200, Marc Santhoff wrote: > On Fr, 2016-07-15 at 14:59 -0700, Zaaphod wrote: > > I am trying to get access to the parallel port with Free Pascal. > > > > I'm trying to use this version of inpout32 (x64) > > http://www.highrez.co.uk/downloads/inpout32/ > > > > Here's my program: > > http://pastebin.com/facf6EFc > > > > Here's my Unit: > > http://pastebin.com/XR0aYUPR > > > > When I try to run it, I get a windows message The application was > unable to > > start correctly (0xc07b). click ok to close the application. > > You could search Microsofts web site to decode this error. Or use a search engine: http://www.techanges.com/fix-error-0xc7b/ http://stackoverflow.com/questions/10492037/the-application-was-unable-to-start-correctly-0xc07b Looks like you are using a 32 Bit version on 64 bit or the like. The original site tells about similar error: http://www.highrez.co.uk/downloads/inpout32/ Look at the update history... Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows
James Richters wrote: What I need to do is be able to read some 5v TTL Inputs in and write some 5v TTL outputs out. The parallel port always worked when my program was a DOS program.. it was so simple, just do Port[$378]:= data to set the bits on the port or data:=port[$378] to read some bits from the port. I'm not opposed to some hardware other than a parallel port if it will be able to interface with freepascal easily, if anyone can make a recommendation. Serial ports won't work because they are not made to just read and write bits like the parallel port and they are not TTL voltage levels. Something like a Velleman K8055, which I've talked to using libusb on Linux. Or an Arduino with appropriate firmware. Or go the whole hog and port the program onto a Raspberry Pi: Bo's doing something like you're asking. Any of those have the advantage that the electronics can be positioned to minimise the signal run carrying TTL. Long printer cables are generally bad news. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FPC allows modifying loop variable
On 2016-07-22 14:04, Jonas Maebe wrote: > FPC has no interprocedural dataflow analysis that could catch something > like that. I just tested with Delphi 7, and FPC is Delphi compatible. ;-) D7 doesn't seem to have inter-procedural dataflow analysis either. Regards, Graeme ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows
What I need to do is be able to read some 5v TTL Inputs in and write some 5v TTL outputs out. The parallel port always worked when my program was a DOS program.. it was so simple, just do Port[$378]:= data to set the bits on the port or data:=port[$378] to read some bits from the port. I'm not opposed to some hardware other than a parallel port if it will be able to interface with freepascal easily, if anyone can make a recommendation. Serial ports won't work because they are not made to just read and write bits like the parallel port and they are not TTL voltage levels. -Original Message- From: fpc-pascal-boun...@lists.freepascal.org [mailto:fpc-pascal-boun...@lists.freepascal.org] On Behalf Of Marc Santhoff Sent: Wednesday, July 20, 2016 11:29 PM To: fpc-pascal@lists.freepascal.org Subject: Re: [fpc-pascal] Parallel Port Access with Free Pascal - windows On Fr, 2016-07-15 at 14:59 -0700, Zaaphod wrote: > I am trying to get access to the parallel port with Free Pascal. > > I'm trying to use this version of inpout32 (x64) > http://www.highrez.co.uk/downloads/inpout32/ > > Here's my program: > http://pastebin.com/facf6EFc > > Here's my Unit: > http://pastebin.com/XR0aYUPR > > When I try to run it, I get a windows message The application was > unable to start correctly (0xc07b). click ok to close the application. You could search Microsofts web site to decode this error. > then I get Exitcode 123 in the Free Pascal IDE. 123 is decimal of 7b. > > Does anyone know how to get this to work? reading and writing the parallel > port used to be so easy, now it's extremely confusing, thanks windows! Didn't test, but as a remark: parallel port is dead and it has been a constant source of problems. First the access rights problems you know of. Second it has no fixed timing, so you're in trouble when e.g. flashing a microcontroller works on one machine and refuses to on another one. Third it is not electrically protected, if you fry it, the mainboard is dead by chance or you have to insert an extension board - which is hard to find nowadays, too. Depending on your needs I'd suggest using a USB-to-serial-Adapter or similar. They are cheap and well supported (e.g. using CP2102). As an alternative FTDI has some nice USB-to-anything (including parallel) chips and they sell modules with mil spacing pins for easy breadboarding. HTH somehow, Marc ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] Vehicle Routing Problem with Time Windows
Hi, does anyone knows any object pascal or c ( not c++, java, lisp ... ) library that can solve the Vehicle Routing Problem with Time Windows, open source or not ? Searched but couldn't find any ... regards, -- Dimitrios Chr. Ioannidis ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FPC allows modifying loop variable
On 22/07/16 14:49, Graeme Geldenhuys wrote: I just discovered a surprising bug in my application. I had a variable "b" defined which I used in a FOR loop. FPC forbids you to modify that loop variable inside the for loop - which is understandable. However, the loop called a local procedure, and that local procedure modified the loop variable. FPC never complained about it. Is this a FPC bug? FPC has no interprocedural dataflow analysis that could catch something like that. Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
On 22/07/16 14:14, Santiago A. wrote: program testconvertstr; You are missing {$h+} here. When posting programs, always include all switches and/or all command line options. The program also compiles with string = shortstring (the default), but has different behaviour in that case. var AnsiStrA:string; ResultA:string; begin writeln('Not Initialized'); writeln(' AnsiStrA: ',stringcodepage(ansistra)); writeln(' ResultA: ',stringcodepage(ResultA)); The string code page of an empty string is always DefaultSystemCodePage. Writeln;writeln('AnsiStrA:='' '''); AnsiStrA:=' '; writeln(' AnsiStrA: ',stringcodepage(ansistra)); The string code page of constant strings is described at http://wiki.freepascal.org/FPC_Unicode_support#String_constants . In this case, it is CP_ACP (= 0) because no source file code page has been set. Writeln;writeln('AnsiStrA[1]:=#243; // o acute win-1252'); AnsiStrA[1]:=#243; // o acute win-1252 writeln(' AnsiStrA: ',stringcodepage(ansistra)); Changing an individual byte of a string has no influence on its code page. Writeln;writeln('ResultA:=AnsiStrA'); ResultA:=AnsiStrA; writeln(' ResultA: ',stringcodepage(ResultA)); Assigning a ansistring to another ansistring with the same declared code page (both AnsiStrA and ResultA have CP_ACP as declared code page) won't change the (dynamic) string code page (see http://wiki.freepascal.org/FPC_Unicode_support#Dynamic_code_page ). Writeln;writeln('ResultA := AnsiStrA + '' '''); ResultA:=AnsiStrA+' '; writeln(' ResultA: ',stringcodepage(ResultA)); See http://wiki.freepascal.org/FPC_Unicode_support#String_concatenation : the result of a string concatenation will always be converted to the declared code page of the destination (and CP_ACP represents the current value of DefaultSystemCodePage, see http://wiki.freepascal.org/FPC_Unicode_support#Code_page_identifiers ). Writeln;Writeln('ResultA:=AnsiToUtf8(AnsiStrA);'); ResultA:=AnsiToUtf8(AnsiStrA); writeln(' ResultA: ',stringcodepage(ResultA)); AnsiToUtf8() returns a RawByteString with dynamic code page CP_UTF8 (so that the dynamic code page matches the actual string encoding). Assigning a RawByteString to any other string type never results in a string code page conversion (see http://wiki.freepascal.org/FPC_Unicode_support#RawByteString ). Writeln;writeln('ResultA:= AnsiToUtf8(AnsiStrA) + AnsiToUtf8(AnsiStrA);'); ResultA:=AnsiToUtf8(AnsiStrA)+AnsiToUtf8(AnsiStrA); writeln(' ResultA: ',stringcodepage(ResultA)); See again http://wiki.freepascal.org/FPC_Unicode_support#String_concatenations (same as before). Jonas ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] FPC allows modifying loop variable
On 2016-07-22 13:49, Graeme Geldenhuys wrote: > However, the loop called a local procedure, and that local procedure > modified the loop variable. FPC never complained about it. Is this a FPC > bug? I forgot to mention, I used FPC 2.6.4. Regards, Graeme ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
[fpc-pascal] FPC allows modifying loop variable
Hi, I just discovered a surprising bug in my application. I had a variable "b" defined which I used in a FOR loop. FPC forbids you to modify that loop variable inside the for loop - which is understandable. However, the loop called a local procedure, and that local procedure modified the loop variable. FPC never complained about it. Is this a FPC bug? Here is a test program to show the issue. = program test; {$mode objfpc}{$H+} uses SysUtils, classes; type TMyTest = class(TObject) public procedure Run; end; procedure TMyTest.Run; var b: integer; procedure ModifyB; begin b := 5; // FPC never complains - BUG? end; begin for b := 1 to 10 do begin writeln(b); // b := 5; // FPC will give a compiler error. CORRECT. ModifyB; end; end; var t: TMyTest; begin t := TMyTest.Create; t.Run; t.Free; end. = Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
On 2016-07-22 13:14, Santiago A. wrote: > I'm definitively completely lost :) So am I. Regards, Graeme ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
El 22/07/2016 a las 12:55, Bart escribió: > Just check the vaue of StringCodePage(Utf8StrA). Not Initialized AnsiStrA: 1252 ResultA: 1252 AnsiStrA:=' ' AnsiStrA: 0 AnsiStrA[1]:=#243; // o acute win-1252 AnsiStrA: 0 ResultA:=AnsiStrA ResultA: 0 ResultA := AnsiStrA + ' ' ResultA: 1252 ResultA:=AnsiToUtf8(AnsiStrA); ResultA: 65001 ResultA:= AnsiToUtf8(AnsiStrA) + AnsiToUtf8(AnsiStrA); ResultA: 1252 I'm definitively completely lost --- program testconvertstr; var AnsiStrA:string; ResultA:string; begin writeln('Not Initialized'); writeln(' AnsiStrA: ',stringcodepage(ansistra)); writeln(' ResultA: ',stringcodepage(ResultA)); Writeln;writeln('AnsiStrA:='' '''); AnsiStrA:=' '; writeln(' AnsiStrA: ',stringcodepage(ansistra)); Writeln;writeln('AnsiStrA[1]:=#243; // o acute win-1252'); AnsiStrA[1]:=#243; // o acute win-1252 writeln(' AnsiStrA: ',stringcodepage(ansistra)); Writeln;writeln('ResultA:=AnsiStrA'); ResultA:=AnsiStrA; writeln(' ResultA: ',stringcodepage(ResultA)); Writeln;writeln('ResultA := AnsiStrA + '' '''); ResultA:=AnsiStrA+' '; writeln(' ResultA: ',stringcodepage(ResultA)); Writeln;Writeln('ResultA:=AnsiToUtf8(AnsiStrA);'); ResultA:=AnsiToUtf8(AnsiStrA); writeln(' ResultA: ',stringcodepage(ResultA)); Writeln;writeln('ResultA:= AnsiToUtf8(AnsiStrA) + AnsiToUtf8(AnsiStrA);'); ResultA:=AnsiToUtf8(AnsiStrA)+AnsiToUtf8(AnsiStrA); writeln(' ResultA: ',stringcodepage(ResultA)); Readln; end. -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Initialization of packed record local variables?
Michael Van Canneyt wrote: On Fri, 22 Jul 2016, Mark Morgan Lloyd wrote: Michael Van Canneyt wrote: Or better yet, the official documentation: http://www.freepascal.org/docs-html/current/rtl/system/default.html Question please. Using the official documentation as linked to above, how does one find out what versions of the compiler/rtl/fcl support something? One does not - yet. I am working on leaving the various versions available (notice the 'current' in the URL) and then you could view previous versions... I started hacking through trying to produce at least a list of functions/procedures and a permuted index from different versions, but I got bogged down in an apparent requirement that the documentation files needed to be processed by the corresponding version of supplied utilities. I'm sure what I did was of little value since I was attacking the problem with insufficient understanding of "the right way to do it" and I'm not even sure where it's got to. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
On 2016-07-22 11:55, Bart wrote: > Gives: > StringCodePage(AnsiStrA) now is: 65001 > AnsiStrA: 195 179 I don't understand, why did AnsiStrA change its codepage type after the 3rd assignment to it? Here is the results on my Windows 7 system. == $ codepagestring.exe StringCodePage(AnsiStrA) now is: 1252 StringCodePage(AnsiStrA) now is: 65001 AnsiStrA: 195 179 == All I did to the last code example was duplicate the line of code that calls stringcodepage() as shown here... So I get a before and after result. == program codepagestring; {$mode objfpc}{$H+} procedure DisplayBytes(S:RawByteString); var i:Integer; begin Write(' '); for i:=1 to length(s) do write(ord(s[i]),' '); writeln; end; var AnsiStrA: String; begin writeln('StringCodePage(AnsiStrA) now is: ',stringcodepage(ansistra)); AnsiStrA:=' '; AnsiStrA[1]:=#243; // o acute win-1252 AnsiStrA := AnsiToUtf8(AnsiStrA); writeln('StringCodePage(AnsiStrA) now is: ',stringcodepage(ansistra)); Write('AnsiStrA: '); DisplayBytes(AnsiStrA); end. == Regards, Graeme -- fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal http://fpgui.sourceforge.net/ My public PGP key: http://tinyurl.com/graeme-pgp ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
On 7/22/16, Santiago A.wrote: > // is Utf8StrA now utf8string? or something similar like Ansistring(UTF_8) > // is Utf8StrB now utf8string? or something similar like Ansistring(UTF_8) Just check the vaue of StringCodePage(Utf8StrA). procedure DisplayBytes(S:RawByteString); var i:Integer; begin Write(' '); for i:=1 to length(s) do write(ord(s[i]),' '); writeln; end; var AnsiStrA: String; begin AnsiStrA:=' '; AnsiStrA[1]:=#243; // o acute win-1252 AnsiStrA := AnsiToUtf8(AnsiStrA); writeln('StringCodePage(AnsiStrA) now is: ',stringcodepage(ansistra)); Write('AnsiStrA: ');DisplayBytes(AnsiStrA); end. Gives: StringCodePage(AnsiStrA) now is: 65001 AnsiStrA: 195 179 Notice that your original problem was mainly due to the fact that DisplayBytes used a String parameter, which lead to automatically converting everything back to your Windows codepage. Bart ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Initialization of packed record local variables?
On Fri, 22 Jul 2016 08:12:01 +0200, Bo Berglundwrote: >>you need to assign it a value, you can assign it default(yourtype) >> > >Is "default" zero? >i.e. > >var > HD: TSSReadingHeader; > .. >begin > HD := Default(TSSReadingHeader); > >And now HD.anything is zero? I made a test once I got the other issues solved and indeed Default() on my packed records seems to zero out the memory! Very good to know! :) Thanks for pointing it out! -- Bo Berglund Developer in Sweden ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Initialization of packed record local variables?
On Fri, 22 Jul 2016, Mark Morgan Lloyd wrote: Michael Van Canneyt wrote: Or better yet, the official documentation: http://www.freepascal.org/docs-html/current/rtl/system/default.html Question please. Using the official documentation as linked to above, how does one find out what versions of the compiler/rtl/fcl support something? One does not - yet. I am working on leaving the various versions available (notice the 'current' in the URL) and then you could view previous versions... Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Initialization of packed record local variables?
Michael Van Canneyt wrote: Or better yet, the official documentation: http://www.freepascal.org/docs-html/current/rtl/system/default.html Question please. Using the official documentation as linked to above, how does one find out what versions of the compiler/rtl/fcl support something? -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues] ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Initialization of packed record local variables?
On Fri, 22 Jul 2016, Mattias Gaertner wrote: On Fri, 22 Jul 2016 11:03:23 +0200 (CEST) Michael Van Canneytwrote: On Fri, 22 Jul 2016, leledumbo wrote: OK, I did not know about the default keyword. Is "default" zero? http://wiki.lazarus.freepascal.org/FPC_New_Features_3.0#New_compiler_intrinsic_Default Or better yet, the official documentation: http://www.freepascal.org/docs-html/current/rtl/system/default.html Can the examples be added to official docs? Good point, will do ! Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Initialization of packed record local variables?
On Fri, 22 Jul 2016 11:03:23 +0200 (CEST) Michael Van Canneytwrote: > On Fri, 22 Jul 2016, leledumbo wrote: > > >> OK, I did not know about the default keyword. > >> > >> Is "default" zero? > > > > http://wiki.lazarus.freepascal.org/FPC_New_Features_3.0#New_compiler_intrinsic_Default > > > > Or better yet, the official documentation: > > http://www.freepascal.org/docs-html/current/rtl/system/default.html Can the examples be added to official docs? Mattias ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Initialization of packed record local variables?
On Fri, 22 Jul 2016, leledumbo wrote: OK, I did not know about the default keyword. Is "default" zero? http://wiki.lazarus.freepascal.org/FPC_New_Features_3.0#New_compiler_intrinsic_Default Or better yet, the official documentation: http://www.freepascal.org/docs-html/current/rtl/system/default.html Michael. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Initialization of packed record local variables?
> OK, I did not know about the default keyword. > > Is "default" zero? http://wiki.lazarus.freepascal.org/FPC_New_Features_3.0#New_compiler_intrinsic_Default -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/Initialization-of-packed-record-local-variables-tp5725737p5725759.html Sent from the Free Pascal - General mailing list archive at Nabble.com. ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Weird string behavior
El 22/07/2016 a las 0:32, Bart escribió: > On 7/21/16, Santiago A.wrote: > >> I've come across this issue: When I concatenate two strings in UTF8 they >> are converted to ansi (Win-1252) . > You have declared all string variables as plain "string", which is the > same as AnsiString(CP_ACP). So all string variables have the encoding > of your active codepage. > > Declare Utf8StrA and related as Utf8String. > In DisplayBytes do not use "String" as parametertype, since this will > again automatically convert things. > The AnsiToUtf8 is not necessary anymore if done this way: var AnsiStrA:string; // AnsiString(CP_ACP) AnsiStrB:string; // AnsiString(CP_ACP) Utf8StrA: string; // AnsiString(CP_ACP) Utf8StrB: string; // AnsiString(CP_ACP) Utf8StrConcat:string; // AnsiString(CP_ACP) begin AnsiStrA:=' '; AnsiStrA[1]:=#243; // o acute win-1252 AnsiStrB:='A'; // AnsiStrA is AnsiString(CP_ACP) // AnsiStrB is AnsiString(CP_ACP) Utf8StrA:=AnsiToUtf8(AnsiStrA); // 195 179 Utf8StrB:=AnsiToUtf8(AnsiStrB); // 65 // is Utf8StrA now utf8string? or something similar like Ansistring(UTF_8) // is Utf8StrB now utf8string? or something similar like Ansistring(UTF_8) Utf8StrConcat:=Utf8StrA+Utf8StrB; // AnsiString(CP_ACP) = UTF8 + UT8 // automatic Conversion to ansiString(CP_ACP) ? end; -- Saludos Santi s...@ciberpiula.net ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Re: [fpc-pascal] Initialization of packed record local variables?
On Mon, 18 Jul 2016 23:30:47 +0200 (CEST), Michael Van Canneytwrote: >> Are there other commands it does detect as initialization of the >> variable? > >not that I know of. > >you need to assign it a value, you can assign it default(yourtype) > OK, I did not know about the default keyword. Is "default" zero? i.e. var HD: TSSReadingHeader; .. begin HD := Default(TSSReadingHeader); And now HD.anything is zero? -- Bo Berglund Developer in Sweden ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal