2

I have a test code on Remix and have been getting ParseError: Expected Primary Expression. The error happens in function Enquiry -- at event definition - line.

ParserError: Expected primary expression. event itemsListDisplay (bytes32 itemId, bytes32 itemDescription, bytes32 auctionStatus); ^

My reason for using event is to display a listing when the function is called by an approved participant. Each listing of items would be in a new line.

Any other suggestion for improved code style will also help.

Thanks. Below is the test code.

contract Request is MasterContract, 
ApprovedParticipantsContract, ApprovedItemsContract {


    function Enquiry (address _address) returns (bool flag) {

    event itemsListDisplay (bytes32 itemId, bytes32 itemDescription, bytes32 auctionStatus);        


    if (approvedParticipantsList[_address].isValue) {

        uint len = itemsList.keys.length;

        for (uint i = 0; i < len; i++)  {

            bytes32 myItemId = itemsList.keys[i].itemId;
            bytes32 myItemDescription = itemsList.keys[i].itemDescription;
            bytes32 myAuctionStatus = itemsList.keys[i].auctionStatus;

            itemsListDisplay(myItemId, myItemDescription, myAuctionStatus);


        }



        return true;

    }

    return false;

    }

}

1 Answer 1

0

You should define the event log outside the function with/after your state variables. Then emit events as transactions happen.

contract Thing {

  event LogSomethingHappened(address sender, uint amount);

  function doSomething(uint qty) public returns(bool success) {
    LogSomethingHappened(msg.sender, qty);
    return true;
  }
}

Hope it helps.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.