Recent

Author Topic: Argument can`t be assigned to  (Read 5299 times)

nitinjain

  • Newbie
  • Posts: 3
Argument can`t be assigned to
« on: May 15, 2014, 02:45:10 pm »
Hi,

I am trying to implimenting the below code but there are showing error that is : "Argument can`t be assigned to ".

**Implimenting Code
-------------------------------------------------------
type Pbyte = ^Byte, Pword = ^Word, Pdword = ^LongWord;

function GetMem( addr: LongWord ) : Byte;
begin
var ptr : PByte;
ptr := PByte(addr)
GetMem := ptr^
end;

procedure SetMem( addr: LongWord; value: Byte );
begin
var ptr: PByte;
ptr := PWord(addr);
ptr^ := value
end;
-----------------------------------------------------

**And My code is shown below, where i want to implement the above code.
--------------------------------
BEGIN
MEMW[$B800:(width_offset-1)*2
+(height_offset-1)*160]:=current_locatio...
current_location:=current_location^.next...
END;
-----------------------------------
BEGIN
offset:=(top_left_x-1)*2
+(top_left_y-1)*160;
MEM[$B800:offset]:=top_left_corner[style...
MEM[$B800:offset+1]:=back*16+fore;
---------------------------------------...

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7356
Re: Argument can`t be assigned to
« Reply #1 on: May 15, 2014, 03:43:34 pm »
That code

1) doesn't compile, and fails basic syntax checks on several places.
2) will never be any use in implementing the bottom code anyway, since the textmode screen is not memory mapped in linear addres space in any modern system. (and even in Dos, there it is in the first MB)

nitinjain

  • Newbie
  • Posts: 3
Re: Argument can`t be assigned to
« Reply #2 on: May 15, 2014, 04:11:02 pm »
Yes, I agreed and i have fixed those basic errors and after that I got this error "Argument can`t be assigned to" on both places (at MEM and MEMW starting point)

**Implimanting Code after changed
----------------------------------------------------
TYPE Pbyte = ^Byte; Pword = ^Word; Pdword = ^LongWord;

FUNCTION GetMem( addr: LongWord ) : Byte;
var ptr : Pbyte;
BEGIN
        addr :=$B800;
   ptr := PByte(addr);
   GetMem := ptr^;
END;

PROCEDURE SetMem( addr: LongWord; value: Byte );
var ptr: Pbyte;
BEGIN
        addr :=$B800;
   ptr := Pbyte(addr);
   ptr^ := value;
END;

FUNCTION GetMemW( addr: LongWord ) : Word;
var ptr : Pword;
BEGIN
        addr :=$B800;
   ptr := Pword(addr);
   GetMemW := ptr^;
END;

PROCEDURE SetMemW( addr: LongWord; value: Word );
var ptr: Pword;
BEGIN
        addr :=$B800;
   ptr := Pword(addr);
   ptr^ := value;
END;
------------------------------------------

2) actually this code used for formating. If I commented this code (as you said), my messages box borders and colors not appeared.
« Last Edit: May 15, 2014, 04:15:19 pm by nitinjain »

typo

  • Hero Member
  • *****
  • Posts: 3051

nitinjain

  • Newbie
  • Posts: 3
Re: Argument can`t be assigned to
« Reply #4 on: May 15, 2014, 04:29:18 pm »
could you please guide me what and where I need to change in my code.

typo

  • Hero Member
  • *****
  • Posts: 3051
Re: Argument can`t be assigned to
« Reply #5 on: May 15, 2014, 04:36:05 pm »
In fact I can compile your code with no error messages, but with these hints:

Code: [Select]
type Pbyte = ^Byte;
     Pword = ^Word;
     Pdword = ^LongWord; // Hint: Local type "Pdword" is not used

FUNCTION GetMem( addr: LongWord ) : Byte;
var
  ptr : Pbyte;
BEGIN
  addr :=$B800;
  ptr := PByte(addr);  // <<<<< Hint: Conversion between ordinals and pointers is not portable
  GetMem := ptr^;
END;

PROCEDURE SetMem( addr: LongWord; value: Byte );
var
  ptr: Pbyte;
BEGIN
  addr :=$B800;
  ptr := Pbyte(addr);  // <<<<< Hint: Conversion between ordinals and pointers is not portable
  ptr^ := value;
END;

FUNCTION GetMemW( addr: LongWord ) : Word;
var
  ptr : Pword;
BEGIN
  addr :=$B800;
  ptr := Pword(addr); // <<<<< Hint: Conversion between ordinals and pointers is not portable
  GetMemW := ptr^;
END;

PROCEDURE SetMemW( addr: LongWord; value: Word );
var
  ptr: Pword;
BEGIN
  addr :=$B800;
  ptr := Pword(addr);  // <<<<< Hint: Conversion between ordinals and pointers is not portable
  ptr^ := value;
END;     

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 7356
Re: Argument can`t be assigned to
« Reply #6 on: May 15, 2014, 04:37:59 pm »
Yes, I agreed and i have fixed those basic errors and after that I got this error "Argument can`t be assigned to" on both places (at MEM and MEMW starting point)

See point (2).   memw is never going to work on something else than dos.
 
The whole "screen is at $B800" concept is a DOSism.