FP106: Error: Incompatible types: got "BYTE" expected "SHORTSTRING" 
Author Message
 FP106: Error: Incompatible types: got "BYTE" expected "SHORTSTRING"

Why do I get this error when concatenating strings?

const DEBUG=True;
        MAXNAME=30;

{Base Types}
type NameType=string[MAXNAME];

type WeaponType=record
        MagicBonus:byte; //Magical Dmg bonus, if any
        Name:NameType; //Name of weapon.
        DmgRoll:DieType; //Ex: 2d6
        DmgBonus:byte; //Add to base damage.
        Atks:byte; //Num times weapon can be fired per round.
        Myname:NameType;
        Qty:byte;
end;

type ArmorType=record
        Name,Myname:NameType;
        BaseAC,MagicBonus:byte; //Base AC and magical bonus.
        Qty:byte;
end;

                if Maparr[Player.posx,Player.posy].Itemtype=miWeapon then
                        begin
                        ts:='(';
//error here    s:=concat(Maparr[Player.posx,Player.posy].Weapon.Name,ts);
                        ts:=')';
//error here    s:=concat(s,Maparr[Player.posx,Player.posy].Weapon.Magicbonus,ts);
                        end;
                if Maparr[Player.posx,Player.posy].Itemtype=miArmor then
                        begin
                        s:=concat(Maparr[Player.posx,Player.posy].Armor.Name,'(');
                        s:=concat(s,Maparr[Player.posx,Player.posy].Armor.Magicbonus,')');
                        end;

Is there a compiler switch I must use? Thank you again.

--
Freezone Freeware and Free delphi Components
http://www.*-*-*.com/ http://www.*-*-*.com/
http://www.*-*-*.com/



Mon, 02 Jan 2006 03:47:01 GMT  
 FP106: Error: Incompatible types: got "BYTE" expected "SHORTSTRING"
Oops. Here are all the errors from this compile. Perhaps they are related.

Free Pascal Compiler version 1.0.6 [2002/04/23] for i386
Copyright (c) 1993-2002 by Florian Klaempfl
rpg.pas(209,29) Error: Illegal qualifier
rpg.pas(331,65) Error: Illegal parameter list
rpg.pas(336,64) Error: Illegal parameter list
rpg.pas(331,54) Error: Incompatible types: got "BYTE" expected "SHORTSTRING"
rpg.pas(336,53) Error: Incompatible types: got "BYTE" expected "SHORTSTRING"
rpg.pas(644,44) Error: Illegal qualifier
rpg.pas(884) Fatal: There were 6 errors compiling module, stopping

--
Freezone Freeware and Free Delphi Components
http://freezone.darksoft.co.nz http://chuckr.bravepages.com
http://www.bdsg.com/resources



Mon, 02 Jan 2006 03:49:03 GMT  
 FP106: Error: Incompatible types: got "BYTE" expected "SHORTSTRING"
 Oops. Here are all the errors from this compile. Perhaps they are related.

Quote:

> Free Pascal Compiler version 1.0.6 [2002/04/23] for i386
> Copyright (c) 1993-2002 by Florian Klaempfl
> rpg.pas(209,29) Error: Illegal qualifier
> rpg.pas(331,65) Error: Illegal parameter list
> rpg.pas(336,64) Error: Illegal parameter list
> rpg.pas(331,54) Error: Incompatible types: got "BYTE" expected
"SHORTSTRING"
> rpg.pas(336,53) Error: Incompatible types: got "BYTE" expected
"SHORTSTRING"
> rpg.pas(644,44) Error: Illegal qualifier
> rpg.pas(884) Fatal: There were 6 errors compiling module, stopping

use Maparr... +'(' instead of concat

--
Azarien

[delete the letter v in my e-mail address]



Mon, 02 Jan 2006 07:13:23 GMT  
 FP106: Error: Incompatible types: got "BYTE" expected "SHORTSTRING"
 Oops. Here are all the errors from this compile. Perhaps they are related.

Quote:

> Free Pascal Compiler version 1.0.6 [2002/04/23] for i386
> Copyright (c) 1993-2002 by Florian Klaempfl
> rpg.pas(209,29) Error: Illegal qualifier
> rpg.pas(331,65) Error: Illegal parameter list
> rpg.pas(336,64) Error: Illegal parameter list
> rpg.pas(331,54) Error: Incompatible types: got "BYTE" expected
"SHORTSTRING"
> rpg.pas(336,53) Error: Incompatible types: got "BYTE" expected
"SHORTSTRING"
> rpg.pas(644,44) Error: Illegal qualifier
> rpg.pas(884) Fatal: There were 6 errors compiling module, stopping

use Maparr... +'(' instead of concat

--
Azarien

[delete the letter v in my e-mail address]



Mon, 02 Jan 2006 07:13:23 GMT  
 FP106: Error: Incompatible types: got "BYTE" expected "SHORTSTRING"

Quote:

> Why do I get this error when concatenating strings?
>            if Maparr[Player.posx,Player.posy].Itemtype=miWeapon then
>                    begin
>                    ts:='(';
> //error here       s:=concat(Maparr[Player.posx,Player.posy].Weapon.Name,ts);

What's ts ? Try to provide examples that show the bug when compiled that
are as small as possible. (p.s. 1.0.10 is out which ocntains the fixes of about
the last year)


Mon, 02 Jan 2006 07:17:05 GMT  
 FP106: Error: Incompatible types: got "BYTE" expected "SHORTSTRING"

Quote:

> Why do I get this error when concatenating strings?

> Is there a compiler switch I must use? Thank you again.

[saw this later]

If you want to use the Delphi dialect, you need

{$MODE Delphi} in all Delphi source, or -Sd as parameter on each compilation
(ideally once, when compiling the main program)



Mon, 02 Jan 2006 07:18:16 GMT  
 FP106: Error: Incompatible types: got "BYTE" expected "SHORTSTRING"

Quote:

> use Maparr... +'(' instead of concat

That gives me a compile error. "Invalid operator" or something like that. I
tried it.

--
Freezone Freeware and Free Delphi Components
http://freezone.darksoft.co.nz http://chuckr.bravepages.com
http://www.bdsg.com/resources



Mon, 02 Jan 2006 19:47:21 GMT  
 FP106: Error: Incompatible types: got "BYTE" expected "SHORTSTRING"

Quote:

> > Why do I get this error when concatenating strings?

> >               if Maparr[Player.posx,Player.posy].Itemtype=miWeapon then
> >                       begin
> >                       ts:='(';
> > //error here  s:=concat(Maparr[Player.posx,Player.posy].Weapon.Name,ts);

> What's ts ? Try to provide examples that show the bug when compiled that
> are as small as possible. (p.s. 1.0.10 is out which ocntains the fixes of
> about the last year)

I posted my file rpg.zip to http://chuckr.freeshell.org/rpg.zip. It has all the
units needed to compile.

ts is just a string. var ts:string;

--
Freezone Freeware and Free Delphi Components
http://freezone.darksoft.co.nz http://chuckr.bravepages.com
http://www.bdsg.com/resources



Mon, 02 Jan 2006 19:55:01 GMT  
 FP106: Error: Incompatible types: got "BYTE" expected "SHORTSTRING"
Source is at http://chuckr.freeshell.org/rpg.zip. It's about 16k zipped up.

--
Freezone Freeware and Free Delphi Components
http://freezone.darksoft.co.nz http://chuckr.bravepages.com
http://www.bdsg.com/resources



Mon, 02 Jan 2006 19:55:39 GMT  
 FP106: Error: Incompatible types: got "BYTE" expected "SHORTSTRING"

Quote:


>> > Why do I get this error when concatenating strings?

>> >           if Maparr[Player.posx,Player.posy].Itemtype=miWeapon then
>> >                   begin
>> >                   ts:='(';
>> > //error here      s:=concat(Maparr[Player.posx,Player.posy].Weapon.Name,ts);

>> What's ts ? Try to provide examples that show the bug when compiled that
>> are as small as possible. (p.s. 1.0.10 is out which ocntains the fixes of
>> about the last year)

>I posted my file rpg.zip to http://chuckr.freeshell.org/rpg.zip. It has all the
>units needed to compile.

>ts is just a string. var ts:string;

Shrink the example, don't post the whole thing.  You'll likely
discover for yourself what's wrong.

You do this by starting with the whole project, then removing big
chunks until it's down to a 20 line example, or until the error goes
away.  If the error goes away, then put things back and remove
something else, or figure out what's causing it.

Duncan Murdoch



Mon, 02 Jan 2006 20:23:14 GMT  
 FP106: Error: Incompatible types: got "BYTE" expected "SHORTSTRING"

Quote:

> Oops. Here are all the errors from this compile. Perhaps they are related.

> Free Pascal Compiler version 1.0.6 [2002/04/23] for i386
> Copyright (c) 1993-2002 by Florian Klaempfl
> rpg.pas(209,29) Error: Illegal qualifier

I found this one. It is because you are using a WITH statement, and then use
the identifier that exists both in the WITH'ed record and a global variable.

In pascal, the highest scope always has precendence (so local vars before
globals etc). So the name of the identifiers in the WITH block has
precendence over the one in unit vars.  This can be easily remedied by saying
to the compiler that the var that you want is in unit vars:

. ...  GenWeapon(Vars.Player.dlvl);

This problem is a direct result of your old Skool Basicish programming style
with a lot of global variables, and hardly any parameters to the procedures.

I'm still looking at the problem with concat, but I think that is indeed a
bug.

Concat is usually not used often, and it seems not to be fixed for
ansistrings. I'll do some testing with it, and if it is indeed the case,
I'll open a trouble ticket for it. (though I think a fix will only get
included in the 1.1.x compiler series)

The bug is probably gone unnoticed for so long because people usually prefer
"+", which can be a workaround, simply use

s:=s+maparr[...]+ts;
)



Mon, 02 Jan 2006 20:40:19 GMT  
 FP106: Error: Incompatible types: got "BYTE" expected "SHORTSTRING"

Quote:
> rpg.pas(209,29) Error: Illegal qualifier
> rpg.pas(644,44) Error: Illegal qualifier

# Weapon:=GenWeapon(Player.dlvl);

there's no dlvl field in CharacterType.

Quote:
> rpg.pas(331,65) Error: Illegal parameter list
> rpg.pas(336,64) Error: Illegal parameter list

# s:=concat(s, Maparr[Player.posx,Player.posy].Weapon.Magicbonus, ts);

concat takes two parameters, not three as in the above line.

Quote:
> rpg.pas(331,54) Error: Incompatible types: got "BYTE" expected
"SHORTSTRING"
> rpg.pas(336,53) Error: Incompatible types: got "BYTE" expected

"SHORTSTRING"

These errors do not occur in FPC 1.0.8 and 1.0.10

--
Azarien

[delete the letter v in my e-mail address]



Mon, 02 Jan 2006 20:41:20 GMT  
 FP106: Error: Incompatible types: got "BYTE" expected "SHORTSTRING"

Quote:
> concat takes two parameters, not three as in the above line.

Well.. never mind ;-)

--
Azarien

[delete the letter v in my e-mail address]



Mon, 02 Jan 2006 20:46:54 GMT  
 FP106: Error: Incompatible types: got "BYTE" expected "SHORTSTRING"

Quote:

> Oops. Here are all the errors from this compile. Perhaps they are related.

> Free Pascal Compiler version 1.0.6 [2002/04/23] for i386
> Copyright (c) 1993-2002 by Florian Klaempfl
> rpg.pas(209,29) Error: Illegal qualifier
> rpg.pas(331,65) Error: Illegal parameter list
> rpg.pas(336,64) Error: Illegal parameter list
> rpg.pas(331,54) Error: Incompatible types: got "BYTE" expected "SHORTSTRING"
> rpg.pas(336,53) Error: Incompatible types: got "BYTE" expected "SHORTSTRING"

Hmm no bug in FPC You are trying to add a byte ("magicbonus") to strings
here. This is not possible, only the error is a bit strange because you use
concat (which I'm not used too) Afaik no Pascal dialect allows this.

You can't add/concat apples and oranges. (strings and bytes), convert the
byte to string first with str()
( http://www.freepascal.org/docs-html/ref/refsu177.html#x261-26700013.3)

E.g. for line 331:

// ts:=')';                                                     // I need this helpstring
str(Maparr[Player.posx,Player.posy].Weapon.Magicbonus,ts);      // byte to str.
s:=concat(s,ts,')');                                            // concat all together.



Mon, 02 Jan 2006 20:49:04 GMT  
 
 [ 14 post ] 

 Relevant Pages 

1. The keys "-"/"+"/"*"

2. Error 85 ";" expected

3. Units and "type mismatch" error

4. ""256 Color Mouse""

5. "Parsing" through bits in a byte

6. Getting "long" file names

7. "Syntax Error in expression" strange error

8. mssql uniqueidentifier causes "invalid field type"

9. "word" data type

10. "Invalid field type" exception

11. Spooky "Type Mismatch in Expression" problem

12. "Field not of expected type" error??

 

 
Powered by phpBB® Forum Software