Eiffel - Don't know why I have syntax error - syntax

I'm new to Eiffel and I'm trying to create a simple class called "Monomio", I have 3 features that are attributes and a feature that's a function. The problem is that I'm getting a syntax error, I compared it to other classes I found but can't find the error here. This is my code
class
MONOMIO
create
make
feature {NONE} -- Initialization
make
-- Initialization for `Current'.
do
end;
coeficiente: INTEGER;
-- El número que será el coeficiente del monomio
exponenteX: INTEGER;
-- El exponente de la variable X
exponenteY: INTEGER;
-- El exponente de la variable Y
evaluar(valX: INTEGER; valY: INTEGER): INTEGER is
do
Result := coeficiente*(valX^expX)*(valY^expY)
end;
end
And this is the error I'm getting:
Syntax error at line 28 in class MONOMIO
evaluar(valX: INTEGER; valY: INTEGER): INTEGER is
---------------------------------------------^
do
I hope anyone can help me with this. Thanks.

I think the problem is the keyword "is". This has been deprecated, and if you are compiling with standard syntax (as you will be by default), then it is an error.
Just remove "is".
The problem of "syntax error" as an uninformative error message is one I have long been complaining about. It is entirely fixable, and no compiler should use it.

Related

how the 'tmpdata' and 'Get_Parameter_List' works in OracleForm?

I am new in OracleForms and Plsql, i found this code in a proyect:
PROCEDURE grabar IS
...
Pl_id paramlist;
...
BEGIN
pl_id := Get_Parameter_List ('tmpdata');
IF NOT Id_Null(pl_id) THEN
Destroy_Parameter_List( pl_id );
END IF;
pl_id := Create_Parameter_List('tmpdata');
i want to konw that if 'tmpdata' does not exist i will get an error?
whit the line:
pl_id := Get_Parameter_List ('tmpdata');
am i inserting the data of 'tmpdata' in 'PL_id'
it is the 'tmpdata' a default variable of Oracleforms or something?
it is not OracleForms but it is a tool based in it so is so similar
I proved to change to:
pl_id := Get_Parameter_List ('tmpdata_HELLO');
enter code hereand the program passed to of this
the console show me this:
may 25, 2018 4:46:30 PM org.apache.tomcat.util.http.Parameters processParameters
INFORMACIÓN: Character decoding failed. Parameter [value] with value [%null] has been ignored. Note that the name and value quoted here may be corrupted due to the failed decoding. Use debug level logging to see the original, non-corrupted values.
Note: further occurrences of Parameter errors will be logged at DEBUG level.
In this example, "tmpdata" is the name of a parameter list that may or may not exist. The "ID_NULL" is checking for the existence of the parameter list by checking of the ID returned has a value or not. If it has a value (ie, ID_NULL returns FALSE), then the parameter list is destroyed so that the "Create_Parameter_List" command will not get an error.
"Get_Parameter_List" will not throw an error if there is no parameter list by the given name ("tmpdata", in this case); it just returns null.

FreePascal / Lazarus and implementing nsurlconnectiondatadelegate

I am trying to implement nsurlconnectiondatadelegate as I need to support async mode - in synchronous mode redirects are followed automatically which I do not want.
For reference I have the code working in synchronous mode with urlRequest etc.
The problem is I can not get FPC/Lazarus to compile my code.
...
Code snippets
{$mode objfpc}
{$modeswitch objectivec1}
{$modeswitch objectivec2}
...
// We need to implement support for NSURLConnectionDelegate and NSURLConnectionDataDelegate
TmsMacRequestDelegate = objcclass(NSObject)
public
// this will set flag when done
procedure connectionDidFinishLoading(ANSUC: NSURLConnection); message onnectionDidFinishLoading:'; override;
// ... implement rest?
end;
...
requestDelegate := TmsMacRequestDelegate.alloc.init;
urlConnection := NSURLConnection.connectionWithRequest_delegate(urlRequest, requestDelegate);
// ... setup flag
urlConnection.start;
// ... wait here in loop checking flag set by "finish loading"
...
With the above, initial testing seems going-not-so-well. We reach urlConnection.start; but connectionDidFinishLoading never gets called. My theory is that it may be because we do not fully implement the delegate. However, doing so gives me other problems - here is declaration:
TmsMacRequestDelegate = objcclass(NSObject)
public
procedure connectionDidFinishLoading(ANSUC: NSURLConnection); message 'connectionDidFinishLoading:'; override;
procedure connection(ANSUC: NSURLConnection; didReceive: NSURLResponse); message 'connection::';
procedure connection(ANSUC: NSURLConnection; didReceive: NSData); message 'connection::';
procedure connection(ANSUC: NSURLConnection; didSendBodyData: Integer; totalBytesWritten: Integer; totalBytesExpectedToWrite: Integer); message 'connection::::';
procedure connection(ANSUC: NSURLConnection; willSend: NSURLRequest; redirectResponse: PNSURLResponse); message 'connection:::';
procedure connection(ANSUC: NSURLConnection; willCacheResponse: NSCachedURLResponse); message 'connection::';
end;
In one function I have translated NSURLResponse? as a pointer to
NSURLResponse... But not sure what is correct here?
Compiler complains that I have to add "override" on my first function (although none of the functions are implemented in NSObject?) with this message:
Error: Inherited methods can only be overridden in Objective-C and
Java, add "override" (inherited method defined in
NSURLConnectionDelegateCategory
If I add "override" like suggested I get:
Error: :219:1: error: invalid symbol redefinition
Error: "-TmsMacRequestDeletegate connection::]":
Error: ^
Sorry for the late reply. I don't actively follow SO, but someone just pointed me to this post.
The declaration of the NSURLConnectionDataDelegateProtocol is available in the CocoaAll unit that ships with FPC. You can declare your delegate as objcclass(NSObject, NSURLConnectionDataDelegateProtocol) so
you don't need to specify the message name for each method/message (the compiler will take them from the protocol/interface)
the compiler can point out any errors in terms of missing methods/clashing message names
The main issue is that your message names are incomplete. E.g. for your first "connection" method, it has to be 'connection:didReceiveResponse:'. That's why the runtime is not finding them.

Pascal unhandles exception occured

When I run this procedure
procedure displaydir;
var count:integer;
directoryfile: file of tdir;
directory:array [1..100] of tdir;
begin
assignfile(directoryfile, 'directory.bin');
reset(directoryfile);
count:=0;
repeat
read(directoryfile,directory[count]);
writeln('Name: ',directory[count].name);
writeln('Telephone number: ',directory[count].tel);
writeln('Job title: ',directory[count].jobtitle);
writeln;
writeln;
count:=count+1;
until (directory[count-1].name = 'q');
end;
I get the error
An unhandled exception occurred at $00000000:
EAccessViolation: Access violation
$00000000
$2A005640
$B6F83F97
Unfortunately I couldn't find a solution on the internet, help is much appreciated!
You've declared an array directory as 1..100, but set count to 0 on first run through. directory[ 0] is out of range. You're probably trying to write to read only memory.

How to show only error message oracle raise application error

I am writing oracle triggers and i have some error messages.
I use this code for handling error:
raise_application_error(-20001, 'error message, please do not this');
But this shows very lot info;
For example:
ora-20001: <<custom message>>.
ora-06512: at <<package.procedure_name>>, line 100
I want only show error message body: "error message, please do not this"
Is there a way to do this?
Since I found this question pretty high in my Google search, here is a simple method to just get the error message:
declare
procedure test is
begin
raise_application_error(-20222, 'This is an error');
end test;
begin
test;
exception
when others then
dbms_output.put_line(replace(sqlerrm, 'ORA' || sqlcode || ': ', ''));
end;
Will output:
This is an error
DBMS_OUTPUT.PUT_LINE(REGEXP_REPLACE(SQLERRM, '^ORA-[0-9]+: ', ''));
You can use the SQLERRM function, which will return the exception number and the message, without the lines. There's no function for returning only the text, but you can use SQLCODE function to do that like the second example in this article.
Just remember that this data is mainly intended to help you to cope with unexpected situations in debugging, logging, etc., so most of the time you should consider writing all of the exception info to your log.

BCB: from BDE to dbexpress, BCD exception

I'm having some problem about TSQLStoredProcedure. Here is the code:
storedproc->ParamByName("A")->AsInteger = adataset->FieldByName("AA")->AsInteger;
storedproc->ExecProc();
param "A" is declared integer in the form (and it's 29 in the program). Also the stored procedure has no errors. I'm sure of it. Database is Oracle 11g. By the way, as storedproc is executed an exception occurred:
...
EBcdException with message '<0000001:000000010000000:00000063612>' is not a valid BCD value
...
All was working fine with BDE but now, using dbexpress, there is this problem. I searched over the internet for some days and I did not find an answer.
I thank you in advance and beg a pardon for my English.
Francesco
Update
I searched over the web. I found something interesting at:
https://forums.codegear.com/thread.jspa?messageID=43223&tstart=0
http://www.delphigroups.info/2/8/750511.html
I decide to make some test:
SQLQuery->ParamByName("f1")->AsString = Edit1->Text;
SQLQuery->ExecSQL();
It works. Not the same for
SQLQuery->ParamByName("f1")->AsInteger = StrToInt(Edit1->Text); //ERROR DBX Error: Invalid Field Type.
SQLQuery->ParamByName("f1")->AsFloat = StrToFloat(Edit1->Text); //ERROR DBX Error: Invalid Field Type.
SQLQuery->ParamByName("f1")->AsBCD = StrToInt(Edit1->Text); //ERROR ORA-06502: PL/SQL: error: ... ORA-06512: at line 1.
SQLQuery->ParamByName("f1")->AsFMTBCD = StrToBcd(Edit2->Text); //ERROR ORA-06502: PL/SQL: error: ... ORA-06512: at line 1.
or by using TSQLStoredProc.
So now I call my pl/sql stored proc by TSQLQuery. I use "AsString" to pass values to parameters. Weird. How does dbexpress map types? Thanks in advance.

Resources