[fpc-pascal] Assigning string constant to a WideString and the Format function

2015-12-23 Thread Lubos Pintes
Hello, I have a text in the WideString variable. I want to send this text to a SAPI5 synthesizer. I am doing this as follows: WideStr := Format('%s', [Pitch, Text]); Pitch is integer, Text is WideString. The result is incorrect, only a half of the Text contents is copied to the result. Tested

[fpc-pascal] Problem with objects

2015-12-23 Thread Santiago Amposta
Hello: I use fpc 2.6.4 and I have a problem of memory leaks, strange errors, etc. Finally I have tracked it to this: TSimpleArrayString=object List:array of String; end; TDerivedArrayString=object(TSimpleArrayString) other_field:integer; end; procedure TestSimple; var A:TSimpleArrayStri

Re: [fpc-pascal] Assigning string constant to a WideString and the Format function

2015-12-23 Thread Mark Morgan Lloyd
Lubos Pintes wrote: Hello, I have a text in the WideString variable. I want to send this text to a SAPI5 synthesizer. I am doing this as follows: WideStr := Format('%s', [Pitch, Text]); Pitch is integer, Text is WideString. The result is incorrect, only a half of the Text contents is copied to

Re: [fpc-pascal] Assigning string constant to a WideString and the Format function

2015-12-23 Thread Lubos Pintes
Hello Mark, The result isthe same, I tried it before I wrote my message. I even tried to temporarily write ordinal codes of characters, it seems that a string is not automatically converted to a WideString when assigned, there wereno zeros, like H#0e#0l#0, etc. Dňa 23. 12. 2015 o 11:07 Mark Mo

Re: [fpc-pascal] Assigning string constant to a WideString and the Format function

2015-12-23 Thread Michael Van Canneyt
On Wed, 23 Dec 2015, Lubos Pintes wrote: Hello Mark, The result isthe same, I tried it before I wrote my message. I even tried to temporarily write ordinal codes of characters, it seems that a string is not automatically converted to a WideString when assigned, there wereno zeros, like H#0e#

Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Dennis Poon
Santiago Amposta wrote: Hello: I use fpc 2.6.4 and I have a problem of memory leaks, strange errors, etc. Finally I have tracked it to this: TSimpleArrayString=object List:array of String; end; TDerivedArrayString=object(TSimpleArrayString) other_field:integer; end; procedure TestS

Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Santiago A.
El 23/12/2015 a las 12:13, Dennis Poon escribió: > > > Santiago Amposta wrote: >> Hello: >> I use fpc 2.6.4 and I have a problem of memory leaks, strange errors, >> etc. Finally I have tracked it to this: >> >> TSimpleArrayString=object >> List:array of String; >> end; >> >> TDerivedArrayStrin

Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Howard Page-Clark
On 23/12/2015 11:40, Santiago A. wrote: It's an object, not a class inherited from Tobject, so it hasn't create constructor. Try this: program simpleObjConsole; type { TSimpleArrayString } TSimpleArrayString=object public List:array of String; constructor Init; destructo

Re: [fpc-pascal] Assigning string constant to a WideString and the Format function

2015-12-23 Thread Lubos Pintes
I tried it now, and it doesn't work. I also tried all string variables changed to WideString. Dňa 23. 12. 2015 o 11:59 Michael Van Canneyt napísal(a): On Wed, 23 Dec 2015, Lubos Pintes wrote: Hello Mark, The result isthe same, I tried it before I wrote my message. I even tried to temporarily

Re: [fpc-pascal] Assigning string constant to a WideString and the Format function

2015-12-23 Thread Michael Van Canneyt
On Wed, 23 Dec 2015, Lubos Pintes wrote: I tried it now, and it doesn't work. I also tried all string variables changed to WideString. In that case, please file a bugreport with an example console program for FPC. Michael. y ___ fpc-pascal maillis

Re: [fpc-pascal] Assigning string constant to a WideString and the Format function

2015-12-23 Thread Tomas Hajny
On Wed, December 23, 2015 11:41, Lubos Pintes wrote: Hello Lubos, > The result isthe same, I tried it before I wrote my message. > I even tried to temporarily write ordinal codes of characters, it seems > that a string is not automatically converted to a WideString when > assigned, there wereno

Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Lukasz Sokol
On 23/12/15 09:37, Santiago Amposta wrote: > Hello: > I use fpc 2.6.4 and I have a problem of memory leaks, strange errors, > etc. Finally I have tracked it to this: > > TSimpleArrayString=object > List:array of String; > end; > > TDerivedArrayString=object(TSimpleArrayString) > other_fie

Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Dennis Poon
Santiago A. wrote: El 23/12/2015 a las 12:13, Dennis Poon escribió: Did you call A.Create before calling TestDerived? Maybe A.List was not initialized (which is done in constructor Create) and contains an invalid pointer (to dynamic array of string). When you call SetLength, it decrements the

Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Santiago A.
El 23/12/2015 a las 16:24, Lukasz Sokol escribió: > On 23/12/15 09:37, Santiago Amposta wrote: > I might be wrong... but I just tried: > > ... What's the conclusion? As far as I see, there is some kind of bug. There is no reason for getting different results depending on how you execute two

Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Santiago A.
El 23/12/2015 a las 16:49, Dennis Poon escribió: > > > Even if it is an object, you can still define a constructor. > A constructor should initialize the memory area of the object to 0, > even if you don't explicitly assign List := nil; > It is safer to call this constructor before you handle the L

Re: [fpc-pascal] Assigning string constant to a WideString and the Format function

2015-12-23 Thread Mark Morgan Lloyd
Lubos Pintes wrote: Hello Mark,The result isthe same, I tried it before I wrote my message.I even tried to temporarily write ordinal codes of characters, it seems that a string is not automatically converted to a WideString when assigned, there wereno zeros, like H#0e#0l#0, etc. Dňa 23. 12. 201

Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Dennis Poon
I think for both Record or Object, you need to initialize any dynamic array or strings fields before using them. If you don't use any constructor , you need to initialize the fields yourself. Being an object, just gives you the added automatic zeroing of its content. Advanced Record does not

Re: [fpc-pascal] Assigning string constant to a WideString and the Format function

2015-12-23 Thread silvioprog
On Wed, Dec 23, 2015 at 6:35 AM, Lubos Pintes wrote: > Hello, > I have a text in the WideString variable. I want to send this text to a > SAPI5 synthesizer. I am doing this as follows: > WideStr := Format('%s', [Pitch, Text]); [...] Assuming that you tested it on Windows, you can't copy a Ansi

Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Lukasz Sokol
On 23/12/15 16:06, Santiago A. wrote: > El 23/12/2015 a las 16:24, Lukasz Sokol escribió: >> On 23/12/15 09:37, Santiago Amposta wrote: >> I might be wrong... but I just tried: >> >> ... > > What's the conclusion? As far as I see, there is some kind of bug. > > There is no reason for getting

Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Jonas Maebe
Santiago Amposta wrote: I use fpc 2.6.4 and I have a problem of memory leaks, strange errors, etc. Finally I have tracked it to this: TSimpleArrayString=object List:array of String; end; TDerivedArrayString=object(TSimpleArrayString) other_field:integer; end; procedure TestSimple; v

Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Santiago A.
El 23/12/2015 a las 18:24, Jonas Maebe escribió: > Santiago Amposta wrote: > > > This is a bug in FPC 2.6.4 (it did not initialise managed fields of > parent objects for child objects that do not declare extra managed > fields). It is fixed in FPC 3.0. > I have used constructors as a workaround no

Re: [fpc-pascal] Problem with objects

2015-12-23 Thread Jonas Maebe
Santiago A. wrote: In TDerivedArrayString I need to manually set the length of the list to zero. If I don't, the memory is not freed, but in TSimpleArrayString it frees memory. Is it also a known bug of 2.6.4? Yes, it was fixed at the same time IIRC. Jonas ___

[fpc-pascal] FreeGLUT on Windows

2015-12-23 Thread Ryan Joseph
I’m trying to learn some basics of Windows and porting some OpenGL code. The first step is getting an OpenGL context prepared but I’m already stuck here. 1) GLUT is long dead it looks like and I probably shouldn’t be using it since there’s no official .dll available except from dodgy looking dow

Re: [fpc-pascal] FreeGLUT on Windows

2015-12-23 Thread Anthony Walter
I recommend SDL 2.0. https://www.libsdl.org/download-2.0.php I have a complete pascal source code declaration of it here: http://github.com/sysrpl/Bare.Game/blob/master/source/bare.interop.sdl2.pas I also have an object orient wrapper if you want to get straight into OpenGL: immediate mode cu

Re: [fpc-pascal] FreeGLUT on Windows

2015-12-23 Thread leledumbo
> There is a FreeGLUT package which it looks like FPC supports and I was able to find the units and download a recent .dll but it complains about missing symbols unless I add the glut unit which then attempts to load the glut32.dll and fails FreeGLUT is a drop-in replacement for GLUT (well, minus