Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Bugs and Fixes

Expected identifier error

A community discussion post from the original code:zIRON forum.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

Expected identifier error

hi

when compiling GuestMode.zpr that in projects section i got that error,

Ziron Compiler 1.1.23.0a

Copyright (C) 2011. OverHertz OOD. All rights reserved.

[41,23]: Expected identifier or calling metho but found strLunarize in [zirutils.zir]

code:

  procedure strLunarize(char* str) {

Emil.

http://www.freewebs.com/ogremagic/index.htm

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

because that project is old, i have updated RoleX' code.

program WIN32DLL 'AutoMode';

#cpu 486;

#include 'messages.zir';
#include 'ziron32.zir';
#include 'smm32.zir';
#include 'zirutils.zir';
#include 'inifiles.zir';

#resource 'GuestMode.res';

function* GetFunction(Pointer sFunc): Pointer; stdcall;
function* SetMode(DWord iUser; Pointer sMode): DWord; stdcall;
function* GetAccountId(DWord iUser): DWord; stdcall;
function* GetHubWindow: DWord; stdcall;

const IDD_MODEDLG = 1000;
const IDC_MODEBTN = 1001;
const IDC_MODEEDT = 1002;

const sPlug = 'Guest mode plugin written in zIRON';
const sAbout = '2011, Bulldozer™';

DWord iHandle;
Char sMode[5];

entry function DLLMain(DWord iDLL; DWord iReason; Pointer iResult) {
  if (iReason == DLL_PROCESS_ATTACH) {
    iHandle = iDLL;
    return true;
  }

  return false;
}

function DialogFunc(DWord iDlg; DWord iMsg; DWord wPar; DWord lPar) {
  if (iMsg == WM_COMMAND) {
    if (wPar == IDC_MODEBTN) {
      GetDlgItemText(iDlg, IDC_MODEEDT, @sMode, 4);
      EndDialog(iDlg, 0);
    }
  } elseif (iMsg == WM_CLOSE) {
    GetDlgItemText(iDlg, IDC_MODEEDT, @sMode, 4);
    EndDialog(iDlg, 0);
  } elseif (iMsg == WM_INITDIALOG) {
    SetDlgItemText(iDlg, IDC_MODEEDT, @sMode);
    ShowWindow(iDlg, SW_SHOWNORMAL);
  }

  return false;
}

procedure LoadSettings {
  eax = Ini_ReadString('.\\GuestMode.ini', @sMode, 'Main', 'Mode', 'd', 5);
  ret;
}

procedure SaveSettings {
  eax = Ini_WriteString('.\\GuestMode.ini', 'Main', 'Mode', @sMode);
  ret;
}

function InitPlugin(Pointer sFunc) {
  GetFunction = sFunc;
  SetMode = GetFunction('SetMode');
  GetAccountId = GetFunction('GetAccountId');
  GetHubWindow = GetFunction('GetHubWindow');
  LoadSettings;
  return sPlug;
}

procedure UnloadPlugin {
  SaveSettings;
  ret;
}

function GetAboutText {
  return sAbout;
}

procedure GetConfig(DWord iParent) {
  DialogBoxParamA(iHandle, IDD_MODEDLG, iParent, @DialogFunc, 0);
  ret;
}

function onNicklistChange(DWord iUser; Boolean bAdded) {
  if (bAdded == true) {
    GetAccountId(iUser);

    if (EAX == 0) {
      SetMode(iUser, @sMode);
    }
  }

  return true;
}

exports
  InitPlugin, UnloadPlugin, onNicklistChange, GetAboutText, GetConfig, SaveSettings;

this i have compiled and it works correctly, a few changes have been made that prevented the older version from compiling.

1 thing to note is macros, any inline macro function returns whatever is returned from the macro

so

Ini_WriteString('.\\GuestMode.ini', 'Main', 'Mode', @sMode);

actually becomes

eax;

so by writing eax = ...., the eax = eax will never happen, therefore canceling it out.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

now compiler gives this error

Access violation at address 004DE556 in module 'Ziron,exe'. Read of address 00000000

thanks for macro explanation.

Emil.

http://www.freewebs.com/ogremagic/index.htm

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

i have removed all eax= from macro , also removed ret; instruction from end of procedures,

but got that error

Expected >> or << or = or as or ++ or -- but found ; in [GuestMode.zpr]

Code:

Ini_ReadString('.\\GuestMode.ini', @sMode, 'Main', 'Mode', 'd', 5);

here is the code

program WIN32DLL 'AutoMode';

#cpu 486;

#include 'messages.zir';
#include 'ziron32.zir';
#include 'smm32.zir';
#include 'zirutils.zir';
#include 'inifiles.zir';

#resource 'GuestMode.res';

function* GetFunction(Pointer sFunc): Pointer; stdcall;
function* SetMode(DWord iUser; Pointer sMode): DWord; stdcall;
function* GetAccountId(DWord iUser): DWord; stdcall;
function* GetHubWindow: DWord; stdcall;

const IDD_MODEDLG = 1000;
const IDC_MODEBTN = 1001;
const IDC_MODEEDT = 1002;

const sPlug = 'Guest mode plugin written in zIRON';
const sAbout = '2011, Bulldozer™';

DWord iHandle;
Char sMode[5];

entry function DLLMain(DWord iDLL; DWord iReason; Pointer iResult) {
  if (iReason == DLL_PROCESS_ATTACH) {
    iHandle = iDLL;
    return true;
  }

  return false;
}

function DialogFunc(DWord iDlg; DWord iMsg; DWord wPar; DWord lPar) {
  if (iMsg == WM_COMMAND) {
    if (wPar == IDC_MODEBTN) {
      GetDlgItemText(iDlg, IDC_MODEEDT, @sMode, 4);
      EndDialog(iDlg, 0);
    }
  } elseif (iMsg == WM_CLOSE) {
    GetDlgItemText(iDlg, IDC_MODEEDT, @sMode, 4);
    EndDialog(iDlg, 0);
  } elseif (iMsg == WM_INITDIALOG) {
    SetDlgItemText(iDlg, IDC_MODEEDT, @sMode);
    ShowWindow(iDlg, SW_SHOWNORMAL);
  }

  return false;
}

procedure LoadSettings {
  Ini_ReadString('.\\GuestMode.ini', @sMode, 'Main', 'Mode', 'd', 5);
}

procedure SaveSettings {
  Ini_WriteString('.\\GuestMode.ini', 'Main', 'Mode', @sMode);
}

function InitPlugin(Pointer sFunc) {
  GetFunction = sFunc;
  SetMode = GetFunction('SetMode');
  GetAccountId = GetFunction('GetAccountId');
  GetHubWindow = GetFunction('GetHubWindow');
  LoadSettings;
  return sPlug;
}

procedure UnloadPlugin {
  SaveSettings;
}

function GetAboutText {
  return sAbout;
}

procedure GetConfig(DWord iParent) {
  DialogBoxParamA(iHandle, IDD_MODEDLG, iParent, @DialogFunc, 0);
}

function onNicklistChange(DWord iUser; Boolean bAdded) {
  if (bAdded == true) {
    GetAccountId(iUser);

    if (EAX == 0) {
      SetMode(iUser, @sMode);
    }
  }

  return true;
}

exports
  InitPlugin, UnloadPlugin, onNicklistChange, GetAboutText, GetConfig, SaveSettings;

so what is the problem here ?

Emil.

http://www.freewebs.com/ogremagic/index.htm

Colin admin
Posts
928
Threads
49
Location
Bulgaria

The 2 following functions are calling a return macro

procedure LoadSettings {
  Ini_ReadString('.\\GuestMode.ini', @sMode, 'Main', 'Mode', 'd', 5);
}

procedure SaveSettings {
  Ini_WriteString('.\\GuestMode.ini', 'Main', 'Mode', @sMode);
}

which are becoming

procedure LoadSettings {
  eax;
}

procedure SaveSettings {
  eax;
}

what is needed is to return the value so they need to be

procedure LoadSettings {
  eax = Ini_ReadString('.\\GuestMode.ini', @sMode, 'Main', 'Mode', 'd', 5);
}

procedure SaveSettings {
  eax = Ini_WriteString('.\\GuestMode.ini', 'Main', 'Mode', @sMode);
}

or you can use return

  return Ini_ReadString('.\\GuestMode.ini', @sMode, 'Main', 'Mode', 'd', 5);

I will try come up with a better solution for this. But for now this should work fine :)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

oh.......

when change it like that

procedure LoadSettings {
  eax = Ini_ReadString('.\\GuestMode.ini', @sMode, 'Main', 'Mode', 'd', 5);
}

procedure SaveSettings {
  eax = Ini_WriteString('.\\GuestMode.ini', 'Main', 'Mode', @sMode);
}

i got that error

Access violation at address 004DE556 in module 'Ziron,exe'. Read of address 00000000

Emil.

http://www.freewebs.com/ogremagic/index.htm

Colin admin
Posts
928
Threads
49
Location
Bulgaria

can you try comment out the resource file (lets see if it is a problem related to that)

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

cemented it and have the same error.

http://www.freewebs.com/ogremagic/index.htm