Recent

Author Topic: jvm IntToStr function  (Read 7237 times)

m.abudrais

  • Jr. Member
  • **
  • Posts: 54
jvm IntToStr function
« on: January 18, 2019, 10:09:18 am »
Hi
I created an Android project  using ppcjvm.exe
but i miss many basic function, how i can convert integer to string?
Code: Pascal  [Select][+][-]
  1. procedure MainActivity.onClick(para1: AVView);
  2. var
  3.   but: AWButton;
  4.   ClickNum, k: integer;
  5.   Ones: String;
  6. begin
  7.  
  8.   Inc(GlobalClickNum);
  9.  
  10.   but := para1 as AWButton;
  11. // i want to convert  GlobalClickNum to string
  12.   but.setText(JLString( 'kkk'));
  13. end;  

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11944
  • FPC developer.
Re: jvm IntToStr function
« Reply #1 on: January 18, 2019, 12:13:44 pm »

inttostr()   (possibly unit sysutils)
.tostring

Thaddy

  • Hero Member
  • *****
  • Posts: 16194
  • Censorship about opinions does not belong here.
Re: jvm IntToStr function
« Reply #2 on: January 18, 2019, 01:08:01 pm »
Both will do. Both require sysutils. And both work  8-)
There are other options too, like using jlInteger and call the Java methods on it (these are supported). And val and str also work.
« Last Edit: January 18, 2019, 01:11:35 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

m.abudrais

  • Jr. Member
  • **
  • Posts: 54
Re: jvm IntToStr function
« Reply #3 on: January 18, 2019, 01:31:59 pm »
JLInteger.Create(GlobalClickNum).toString(); worked for me thanks.
but when I try sysutils I get this Error :
unit1.pas(7,17) Fatal: Cannot find sysutils used by Unit1 of the Project Inspector.
I searched the C:\FPC\3.0.4\units but I didn't find sysutils.pp file.
may be I have problem in the compiler installation?
« Last Edit: January 18, 2019, 01:58:49 pm by m.abudrais »

 

TinyPortal © 2005-2018