### Bookstore

 Computer Math and Games in Pascal (preview) Lazarus Handbook

### Author Topic: pas2jni TClass error  (Read 605 times)

#### giahung1997

• Full Member
• Posts: 113
##### pas2jni TClass error
« on: June 21, 2019, 10:58:39 am »
Code: Pascal  [Select][+][-]
1. unit Unit1;
2.
3. {\$mode objfpc}{\$H+}
4.
5. interface
6.
7. uses
8.   Classes, SysUtils, math;
9.
10. function isNarcissistic(num: integer): boolean;
11. function ProperDivisors(num: integer): integer;
12. function UglyNumber(num: integer): boolean;
13.
14. implementation
15.
16. function isNarcissistic(num: integer): boolean;
17. var
18.   k, n, sum: integer;
19. begin
20.   if num <= 0 then result:= false
21.   else begin
22.     k:= trunc(log10(num)) + 1;
23.     n:= num;
24.     sum:= 0;
25.     while n > 0 do
26.       begin
27.         sum:= sum + trunc(intpower(n mod 10, k));
28.         n:= n div 10;
29.       end;
30.     result:= sum = num;
31.   end;
32. end;
33.
34. function ProperDivisors(num: integer): integer;
35. var
36.   i: integer;
37. begin
38.   result:= 0;
39.   if num <= 0 then result:= -1
40.   else if num = 1 then result:= 0
41.   else for i:= 1 to num div 2 do if num mod i = 0 then result:= result + i;
42. end;
43.
44. function UglyNumber(num: integer): boolean;
45. begin
46.   result:= true;
47.   if num <= 0 then result:= false
48.   else begin
49.     while num <> 1 do
50.     begin
51.       if num mod 2 = 0 then num:= num div 2
52.       else if num mod 3 = 0 then num:= num div 3
53.       else if num mod 5 = 0 then num:= num div 5
54.       else begin
55.         result:= false;
56.         break;
57.       end;
58.     end;
59.   end;
60. end;
61.
62. end.
63.
64.

Quote
Quote
Quote
Quote

fpc unit1jni.pas successful with no errors

Both above give the same result. Error when run javac system.java and javac unit1.java

If I use the eclipse ecj compiler which allow compilation of source files have errors and pack it using jar tool:
Quote
jar -cvf pas.jar system.class unit1.class
it will give me a pas.jar file which later I could add to my Java project and it will compile and run flawlessly.

« Last Edit: June 21, 2019, 11:00:14 am by giahung1997 »

#### giahung1997

• Full Member
• Posts: 113
##### Re: pas2jni TClass error
« Reply #1 on: June 21, 2019, 03:58:08 pm »
No one cares?  Are you hate me that much?

#### giahung1997

• Full Member
• Posts: 113
##### Re: pas2jni TClass error
« Reply #2 on: June 21, 2019, 04:17:02 pm »
If I comment out this line in system.java javac will happily compile system.java:
Quote
static TClass GetTClass(int index) { TClass c = new TClass(null); c._pasobj=GetClassRef(index); return c; }
Don't know if it affect anything.

#### giahung1997

• Full Member
• Posts: 113
##### Re: pas2jni TClass error
« Reply #3 on: June 22, 2019, 07:38:22 am »
Run fine when comment out this line. Anyway my small sample doesn't use any OOP. If I does use some, I think it will not run that happily without this fucking TClass