RANDOM:X:<chars> for special characters

I’m using V4, I did search for random tutorial in forum.
There are 3 syntax: RANDOM, RANDOM:X, and RANDOMC:X work well with V4
so I want to know the syntax of (RANDOM:X:chars) will it work for V4?
I tried to print template but it always gave me 8 random (numeric and alphanumeric) characters event I code {RANDOM:3:abcdefgh}
Another search is alternate characters, I tried to print out random some special characters but it doesn’t work.
example {RANDOM:1:€₭₮₰₳₴₵₸₹₺₻₼₽₾} --> it gave me 8 random (numeric and alphanumeric) characters.
I want to print out RANDOM 5 special characters on the bill (make it looks difference with other restaurant bill).
Are there any RULE or ACTION can create button for random special characters to print out?
Thanks for your times
Have a great day

That is not possible sorry.

Thanks for your rapid reply.

In v5 you could look at using a script to generate instead but since your on v4 :frowning:


After a month research and study, I’m learning more about SCRIPT but I don’t know how to use it for printer template?
Could you please show me more about this?
I learn coding PHP and code it in SCRIPT (save it with name: random - handler: rand)
function randstr ($len=4, $spec=“€₭₮₰₳₴₵₸₹₺₻₼₽₾0123456789”)
$letters = str_split($spec);
$str = “”;
for ($i=0; $i<=$len; $i++)
$str .= $letters[rand(0, count($letters)-1)];
return $str;

I put it in template [{call:random.randstr}] --> it was printout with syntax, it didn’t printout with special characters.
Is it missing something? Thanks for your time

Its not a valid call, thats why.
You need to have () at minimum,


Also pretty sure you shouldnt put var=xx in the function, at least not seen it done that way before;

function randstr(){
    $len = 4;
    $spec = “€₭₮₰₳₴₵₸₹₺₻₼₽₾0123456789”;
    $letters = str_split($spec);
    $str = “”;
    for ($i=0; $i<=$len; $i++){
        $str .= $letters[rand(0, count($letters)-1)];
    return $str;

or feed in vars;


function randstr(len,spec){
    $letters = str_split($spec);
    $str = “”;
    for ($i=0; $i<=$len; $i++){
        $str .= $letters[rand(0, count($letters)-1)];
    return $str;

Thanks @JTRTech
I did test the code in SCRIPT but it gave “Invalid character”. I did change new character such as “abcdef” but it stile gave “Invalid character”.
Then I tried to printout by {CALL:X()} syntax but I gave 1 row blank space (nothing print out)
Do you have any idea?
I will try another code to find the new way.
Thanks a lot and have a great weekend

I had an issue with formatting my receipt print where code copied and pasted from the forum messed up the apostrophes, when I re-typed them all was well. Maybe this is the same cause?

In test on script tab you just fo functionName()
No handler or CALL:

Thanks @JTRTech
I used syntax {CALL:x} in print template but nothing print out (just blank space)

So either it’s not right call or script has an issue.
Show the call in template and script.

Help me take a look this new code
function randalpha(){
$len = 10;
$str = ‘abcdefghijklmn0123456789’;
$alpha.=substr(str, rand(0, strlen($str)), 1);
return $alpha;
I tried to test randalpha() in script tab --> it showed ‘Expected identifier’
Then I used syntax in print template {CALL: random.randalpha()} --> it printed out nothing (just blank space)
thanks for your time to help me out

I dknt think you alpha line is right.
For one I’m pretty sure you need to define the variable before using a add to type expression.
Also not sure .= is right

Also highlight code and click code button on forum before posting as keeps formatting and doesnt strip anything.

Also show screenshot of testing script.

We do not support php in Sambapos. Are you trying to use php script syntax?

Oh also it says your using v4. None of this is available in v4. You must upgrade to v5 however even In v5 we do not support php. It’s jscript and it’s specific helpers etc.

Thanks @Jesse
I did upgrade V5 and I test script for print bill with random special characters.
I thought script using PHP so I tried with PHP script syntax.
jscript is java script right?
I will change and test my code for jscript.
Thanks for your remind jscript

Thanks @JTRTech
I will pay more attention for the next reply with coding.

No but kinda, its microsoft’s version pretty much but it is 99% similar.
Most common functions will be available and work exactly the same.
I will be down to Samba using .net framework.
But yes, generally a sample code for java will most likely work fine.

The best thing to do is look at the many examples of scripts built by forum members. You will see syntax available.

My PMS integration topic below is a good example of working development of scripts as started it with little understanding so covers quite allot of principles.

Oh, yes. My knowledge just like a grain of sand in desert.
I’m really appreciate master Emre Eren, who born SAMBAPOS software and community.
Also, I’m really appreciate 2 of you Jesse and JTRTech, who spend most of the time for reply all types of questions.
I will take more time to look at SCRIPTS code.
Hopefully, everyone, who uses SAMBAPOS, has good health to build SAMBAPOS more useful and powerful.