How to convert array to list and list to yail list? extension development

@SimpleFunction(description = "This function prepares the ESC_POS commands to send to printer. in feedPaper, it will feed 2 lines after text. in printCount, it will print X copies one after another.")
  public YailList prepareTextToPrint(String text, int printCount, boolean feedPaper, boolean bold, boolean underline) {         
		char ch = 'a';
		int[] resultInt = new int[text.length()];
		for(int i=0; i<text.length(); i++) //רוץ מספר פעמים של אורך המחרוזת הנדרשת המרה	  
			{
		        ch = text.charAt(i); 
				resultInt[i] = (int)ch;
				//System.out.println(resultInt[i]); //הדפסה של תאי המערך
		    } 	 			
				 List<Integer> list = new ArrayList<>(Arrays.asList(resultInt));
			return resultInt.asList;
	} 

i need yail list of rresultInt array. how?
all what i did not helping and im stuck… help?

Use YailList.makeList(Object[] objects), yourYailList.toArray() that’ll return Object[]. If you are expecting a particular data type like Integer or Strings, you can cast them while looping on the Object[] returned by yourYailList.toArray() method.

2 Likes

And don’t forget to follow the naming conventions…

Taifun

1 Like

it works.
another issue: the thermal printer prints the word in decimal byte, but all over the line like hihihihihihi
how to make it correct print? only one hi per line and spacing between words…

this is code

and this is java

@SimpleFunction(description = "This function prepares the ESC_POS commands to send to printer.")
  public YailList PrepareTextToPrint(String text) {         
		char ch = 'a';
		Integer[] resultInt = new Integer[text.length()];
		for(int i=0; i<text.length(); i++) //רוץ מספר פעמים של אורך המחרוזת הנדרשת המרה	  
			{
		        ch = text.charAt(i); 
				resultInt[i] = (int)ch;
		    } 	 			
			
			YailList.makeList(resultInt);
			return YailList.makeList(resultInt);
	} 


This is what i said about…

That’s your job to find out how these printers work.
Your code to convert text into array is completely fine.

It is your Bluetooth setup or way of handling.

I dont get what exactly you want to do. You just need to set the right bytes.

when i do the function, it prints like: “hihihihihihihi” instead of one “hi” in the line.
i want to correct it and print only one.
how and why this is happen?

see the photo
it is 2 lines that incorrect and without spacing

Maybe you did not add a new line character? decimal 10 and char representation \n

where to put it?
when i write: hi 10 hi
i doesnt work

In the texbox, “hello\nworld” like this and it would print:

hello
world

not working
i know new line is 10 decimal, but cant put it
i did /n it prints
also html code: br<> (it cant write normmaly here)
doesnt work
some other?

Hmm it is your printer configuration. You may need to test with different spacing to find out the right way.

which spacing more? what to seach?
also the printer not responiding to first sending, only after 9 times
why that?

i understand that i need to put 0A in decimal, giving me not 10… giving 48 65
so how to convert? what type exatctly it is?

It is

Taifun

i did


this is not 10
so how?

i dont understand how to do it… what i need to do?
convert ascii to decimal not work also hex to dec not work
what does work?