Re: [fpc-pascal]runtime 201 with swapword function

2003-07-25 Thread James Mills
On Fri, Jul 25, 2003 at 04:36:39PM +0100, Matt Emson wrote: > > > Doesn't system contain a routine called 'swap' that does this exact thing?? > > This program would seem to work in both Delphi and FPC1.1: > > program test; > {$APPTYPE CONSOLE} > > uses > sysutils; > > var > i, j: word; >

Re: [fpc-pascal]runtime 201 with swapword function

2003-07-25 Thread Matt Emson
Doesn't system contain a routine called 'swap' that does this exact thing?? This program would seem to work in both Delphi and FPC1.1: program test; {$APPTYPE CONSOLE} uses sysutils; var i, j: word; begin i := $9988; writeln( IntToHex(i, 4) ); //output '9988' j := swap( i ); writ

Re: [fpc-pascal]runtime 201 with swapword function

2003-07-25 Thread Michael Van Canneyt
On Sat, 26 Jul 2003, James Mills wrote: > Hi, > > Why does the following result in a runtime error ? > > program example; > > const > THE_PORT = ; > > function swapWord(w: Word): Word; > begin > swapWord := (w SHL 8) OR (w SHR 8); > end; > > var > port: Word; > begin >

Re: [fpc-pascal]runtime 201 with swapword function

2003-07-25 Thread James Mills
On Fri, Jul 25, 2003 at 04:30:35PM +0200, Florian Klaempfl wrote: > James Mills wrote: > >On Fri, Jul 25, 2003 at 04:21:36PM +0200, Jonas Maebe wrote: > > > >>On vrijdag, jul 25, 2003, at 16:22 Europe/Brussels, James Mills wrote: > >> > >> > >>>Why does the following result in a runtime error ? > >

Re: [fpc-pascal]runtime 201 with swapword function

2003-07-25 Thread Marco van de Voort
> On Fri, Jul 25, 2003 at 04:21:36PM +0200, Jonas Maebe wrote: > > > > On vrijdag, jul 25, 2003, at 16:22 Europe/Brussels, James Mills wrote: > > > > >Why does the following result in a runtime error ? > > > > > >program example; > > > > > >const > > > THE_PORT = ; > > > > > >function swapW

Re: [fpc-pascal]runtime 201 with swapword function

2003-07-25 Thread James Mills
On Fri, Jul 25, 2003 at 04:30:24PM +0200, Jonas Maebe wrote: > > On vrijdag, jul 25, 2003, at 16:32 Europe/Brussels, James Mills wrote: > > >>In Pascal, all calculations are performed using the base type (which > >>is > >>longint in FPC), so if w > 255, then w shl 8 > high(word) and will > >>res

Re: [fpc-pascal]runtime 201 with swapword function

2003-07-25 Thread Florian Klaempfl
James Mills wrote: On Fri, Jul 25, 2003 at 04:21:36PM +0200, Jonas Maebe wrote: On vrijdag, jul 25, 2003, at 16:22 Europe/Brussels, James Mills wrote: Why does the following result in a runtime error ? program example; const THE_PORT = ; function swapWord(w: Word): Word; begin

Re: [fpc-pascal]runtime 201 with swapword function

2003-07-25 Thread Nikolay Nikolov
[EMAIL PROTECTED] wrote: Why does the following result in a runtime error ? program example; const THE_PORT = ; function swapWord(w: Word): Word; begin swapWord := (w SHL 8) OR (w SHR 8); end; How can I correct this ? This bit of code was taken directly from server.pp in one of the old 2002

Re: [fpc-pascal]runtime 201 with swapword function

2003-07-25 Thread Jonas Maebe
On vrijdag, jul 25, 2003, at 16:32 Europe/Brussels, James Mills wrote: In Pascal, all calculations are performed using the base type (which is longint in FPC), so if w > 255, then w shl 8 > high(word) and will result in a range check error when assigning to swapWord. Even if we calculated everyth

Re: [fpc-pascal]runtime 201 with swapword function

2003-07-25 Thread Jonas Maebe
On vrijdag, jul 25, 2003, at 16:22 Europe/Brussels, James Mills wrote: Why does the following result in a runtime error ? program example; const THE_PORT = ; function swapWord(w: Word): Word; begin swapWord := (w SHL 8) OR (w SHR 8); end; In Pascal, all calculations are perfo

Re: [fpc-pascal]runtime 201 with swapword function

2003-07-25 Thread James Mills
On Fri, Jul 25, 2003 at 04:21:36PM +0200, Jonas Maebe wrote: > > On vrijdag, jul 25, 2003, at 16:22 Europe/Brussels, James Mills wrote: > > >Why does the following result in a runtime error ? > > > >program example; > > > >const > > THE_PORT = ; > > > >function swapWord(w: Word): Word; >