[fpc-pascal] Read() for multiple variables.

2008-04-02 Thread zaher dirkey
I am old pascal programmer, but now i teaching pascal and need to understand
the old input

program readtest;
var
  x:integer;
  y:integer;
  s:string;
begin
  read(x, y, s);
  writeln();
  writeln(x,y,'"',s,'"');
  readln;
end.
-
10 50 Hello

how to use read() procedure to read multiple variable one of them is string
type
in example above it read x, y correclty, but variable s take a first space
before the text.
How i can manage to read the string after integer with simple read?.


-- 
Zaher Dirkey
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Read() for multiple variables.

2008-04-02 Thread [EMAIL PROTECTED]

zaher dirkey wrote:
how to use read() procedure to read multiple variable one of them is 
string type


To read a string and then number it is possible only if the length of a 
line is precisely known and fixed.
I read out one string, and then I find in it numbers. Here an example 
for a finding of real:

--
procedure FindReal(Source: String; VAR Destign: Real;
VAR NBeg, CodeOp: Integer);
 CONST
 BegOfNumb: SET OF CHAR = ['0'..'9'];
 NumbChars: SET OF CHAR = ['0'..'9','E','e','+','-','.'];

 VAR
Buf_String: String;
Buf_Real  : Real;
len   : Integer;
 BEGIN
CodeOp:=-30;
 len:=LENGTH(Source);
if (NBeg<=0) then EXIT;
if NBeg>=len then EXIT;
   Buf_String:='';
   While (NOT (Source[NBeg] in BegOfNumb))
AND (NBeg < len) do INC(NBeg);
if NBeg=len then EXIT;
if NBeg>1 then
  if (Source[NBeg-1]='+') OR (Source[NBeg-1]='-') then 
DEC(NBeg,1);

While (Source[NBeg] in NumbChars) AND (NBeg<=len) do
begin
Buf_String:=Buf_String + Source[NBeg]; INC(NBeg)
end;
Val(Buf_String, Buf_Real, CodeOp);
if CodeOp=0 then Destign:=Buf_Real
 END;
---
Boris

___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] backport 2.3.1 fix to 2.2.x fixes branch?

2008-04-02 Thread Jonas Maebe


On 02 Apr 2008, at 01:22, Seth Grover wrote:

I've been tracking an issue for a while:
http://bugs.freepascal.org/view.php?id=8730
http://bugs.freepascal.org/view.php?id=9089
and am delighted to see it's been marked as fixed in 2.3.1.

I grabbed the fixes_2_2 branch in hopes the change had been
backported, but it doesn't appear the issue is resolved in that
branch. I'm trying to facilitate a switch from kylix to freepascal in
my company, and being able to have libraries initialize correctly is
really important, but I'm reluctant to suggest we use the 2.3.x trunk
in production.

So my question is, how generally does a fix get backported to the  
fixes branch?


If the fix is not too invasive (i.e., its effects are generally  
overseeable), and if it has been in 2.3.1 for a while and no bad  
effects are reported, then it will be merged after a while. These  
particular fixes will be merged at some time in the future, but I  
don't know when yet exactly. If you can test the fixes in trunk and  
report whether or not everything indeed works now for you, that would  
be very helpful.



Barring that, does anyone know of a way I can manually make sure the
initialization code gets called? Can I directly call "initialize"
somehow?


The problem was not that initialize wasn't called, but that many  
symbols in libraries were bound to same-named symbols in the main  
program (or in other libraries). There is no quick fix available,  
except possibly compiling the libraries with -k-Bsymbolic (although  
that breaks if you try to export variables from a library, see http://bugs.freepascal.org/view.php?id=8397)



Jonas 
___

fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Crash at startup with sqlite project

2008-04-02 Thread Felipe Monteiro de Carvalho
Hello,

I have a simple project with sqlite 3. It's running on Windows with
FPC 2.2.0 and svn Lazarus, and my DLL is version is 3_5_7 downloaded
from official sqlite website.

It crashes at startup at sqlite3ds.pas at:

procedure TSqlite3Dataset.InternalInitFieldDefs;

  sqlite3_step(vm);   // Here

With the message:

ntdll!RtlEnumerateGenericTableLikeADirectory

And this stack trace:

#0 ntdll!RtlEnumerateGenericTableLikeADirectory at :0
#1 sqlite3_mutex_enter at :0
#2 sqlite3_step at :0
#3 TSQLITE3DATASET__INTERNALINITFIELDDEFS at sqlite3ds.pas:115
#4 TCUSTOMSQLITEDATASET__INTERNALOPEN at customsqliteds.pas:845
#5 $CUSTOMSQLITEDS$_Ld21 at :0
#6 $DBCOMPONENTS$_Ld6 at :0
#7 $CUSTOMSQLITEDS$_Ld24 at :0
#8 ?? at :0
#9 TDATASET__CREATE((^TCOMPONENT) 0x7c9140bb, (POINTER) 0x1673b0) at
dataset.inc:25
#10 TCOMPONENTSDATABASE__CREATE((POINTER) 0x580774,
(TCOMPONENTSDATABASE) 0x8dae8) at dbcomponents.pas:43
#11 DBCOMPONENTS_init at dbcomponents.pas:92
#12 fpc_initializeunits at system.inc:668
#13 ?? at :0
#14 ?? at :0

The project sources can be download from sourceforge:

http://sourceforge.net/projects/turbocircuit

The strange part is that Lazarus runs fine with the sqlite package
installed and the same dll and also that I had already worked with
this project with all the same variables (except maybe sligtly
different sqlite3 version) on another windows xp machine and it all
worked fine.

Any ideas?

thanks,
-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


[fpc-pascal] Re: backport 2.3.1 fix to 2.2.x fixes branch?

2008-04-02 Thread Seth Grover
>  If the fix is not too invasive (i.e., its effects are generally
>  overseeable), and if it has been in 2.3.1 for a while and no bad
>  effects are reported, then it will be merged after a while. These
>  particular fixes will be merged at some time in the future, but I
>  don't know when yet exactly. If you can test the fixes in trunk and
>  report whether or not everything indeed works now for you, that would
>  be very helpful.
>
Jonas,

Thank you for your response! I grabbed 2.3.1 from subversion and ran
both tests attached to bug 9089. The initialization code in the .so's
are indeed being called now. Finalization is not, but I read somewhere
else that that is another known issue, and, for me at least, that's
not as big a deal.

I would have reported these results in the bug itself, but I can't
seem to find a way for mantis to let me comment on them now that it's
closed.

My setup is Free Pascal Compiler version 2.3.1 [2008/04/01] for i386,
running on Ubuntu Linux 2.6.22-14-generic 7.10 kernel.

Thanks again for your help and for explaining how the merge process
works. Hopefully in a while we'll see it merged back!

Cheers,

Seth
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Crash at startup with sqlite project

2008-04-02 Thread Denis Golovan
On Wed, Apr 02, 2008 at 08:31:01AM -0300, Felipe Monteiro de Carvalho wrote:
> Hello,
> 
> I have a simple project with sqlite 3. It's running on Windows with
> FPC 2.2.0 and svn Lazarus, and my DLL is version is 3_5_7 downloaded
> from official sqlite website.
> 
> It crashes at startup at sqlite3ds.pas at:
> 
> procedure TSqlite3Dataset.InternalInitFieldDefs;
> 
>   sqlite3_step(vm);   // Here
> 
 
  Try using FPC svn. Several changes were commited recently.

-- 
Best regards,
Denis Golovan aka MageSlayer
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Re: backport 2.3.1 fix to 2.2.x fixes branch?

2008-04-02 Thread Jonas Maebe


On 02 Apr 2008, at 14:23, Seth Grover wrote:


If the fix is not too invasive (i.e., its effects are generally
overseeable), and if it has been in 2.3.1 for a while and no bad
effects are reported, then it will be merged after a while. These
particular fixes will be merged at some time in the future, but I
don't know when yet exactly. If you can test the fixes in trunk and
report whether or not everything indeed works now for you, that would
be very helpful.



Thank you for your response! I grabbed 2.3.1 from subversion and ran
both tests attached to bug 9089. The initialization code in the .so's
are indeed being called now. Finalization is not, but I read somewhere
else that that is another known issue, and, for me at least, that's
not as big a deal.


Actually, finalization should also work in the mean time. But I mainly  
meant verifying the fix with your own program. The tests themselves  
are run automatically every night.



I would have reported these results in the bug itself, but I can't
seem to find a way for mantis to let me comment on them now that it's
closed.


No, that's indeed not possible.


Jonas
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Crash at startup with sqlite project

2008-04-02 Thread Luiz Americo Pereira Camara

Felipe Monteiro de Carvalho wrote:

Hello,

I have a simple project with sqlite 3. It's running on Windows with
FPC 2.2.0 and svn Lazarus, and my DLL is version is 3_5_7 downloaded
from official sqlite website.

It crashes at startup at sqlite3ds.pas at:

  



The strange part is that Lazarus runs fine with the sqlite package
installed and the same dll and also that I had already worked with
this project with all the same variables (except maybe sligtly
different sqlite3 version) on another windows xp machine and it all
worked fine.

Any ideas?
  


The db filename is hardcoded.

See 
http://www.geocities.com/camara_luiz/docs/dataset/dataset-tutorial-01.html 
to know how to setup a db file dinamically


Luiz
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Crash at startup with sqlite project

2008-04-02 Thread Felipe Monteiro de Carvalho
On Wed, Apr 2, 2008 at 7:46 PM, Luiz Americo Pereira Camara
<[EMAIL PROTECTED]> wrote:
>  See
> http://www.geocities.com/camara_luiz/docs/dataset/dataset-tutorial-01.html
> to know how to setup a db file dinamically

Thanks, that was indeed true, and the filename was hardcoded, but I
fixed it and the error persists ... The dataset starts not Actived
anyway, and the code to activate it isn't called in the startup.

I think I was using a more recent Free Pascal on the other computer
... I'll try with 2.2.1

-- 
Felipe Monteiro de Carvalho
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] Crash at startup with sqlite project

2008-04-02 Thread Luiz Americo Pereira Camara

Felipe Monteiro de Carvalho wrote:

On Wed, Apr 2, 2008 at 7:46 PM, Luiz Americo Pereira Camara
<[EMAIL PROTECTED]> wrote:
  

 See
http://www.geocities.com/camara_luiz/docs/dataset/dataset-tutorial-01.html
to know how to setup a db file dinamically



Thanks, that was indeed true, and the filename was hardcoded, but I
fixed it and the error persists ... The dataset starts not Actived
anyway, and the code to activate it isn't called in the startup.

I think I was using a more recent Free Pascal on the other computer
... I'll try with 2.2.1
  


Here works fine both with fpc 2.2.0 and with a newer sqlitedataset 
version after dinamically setting the filename.


PS: With more recent versions of sqlitedataset you get meaningful error 
messages.


Luiz
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal