Register | Login
Forum Index > RTL > StrUtils
Author Message
Pages: 1
0CodErr
Ziron Guru
(send private message)

Posts: 197
Topics: 37

Location:
[1854] StrUtils - posted: 2016-05-03 18:51:42
Because some examples already uses this functions may be it will be useful to add them to StrUtils?
Code:
/*
/    Pads string to right with specific character
/    $src -- pointer to string 
/    $len -- length of result string
/    $fil -- specified padding character
/    Copyright (c) 0CodErr, KolibriOS team
*/
#set frame off;
function RPadStr(char* src; sysword len; char fil) {
  gp_ax = src; gp_ax--;
  repeat {gp_ax++;} until (byte[gp_ax] == 0)
  gp_cx = len; gp_cx -= gp_ax; gp_cx += src;
  dl = fil;
  repeat if ([sysint]gp_cx > 0) {
    byte[gp_ax] = dl;
    gp_ax++; gp_cx--;    
  } until (gp_cx == 0)
  byte[gp_ax] = 0;
  return src;
}
#set frame on;

/*
/    Pads string to left with specific character
/    $src -- pointer to string 
/    $len -- length of result string
/    $fil -- specified padding character
/    Copyright (c) 0CodErr, KolibriOS team
*/
#set frame off;
function LPadStr(char* src; sysword len; char fil) {
  gp_ax = src; gp_ax--;
  repeat {gp_ax++;} until (byte[gp_ax] == 0)
  gp_cx = len; gp_cx -= gp_ax; gp_cx += src;
  if ([sysint]gp_cx > 0) {
    using gp_cx {
      gp_cx += gp_ax;
      repeat {
        dl = byte[gp_ax]; byte[gp_cx] = dl;
        gp_ax--; gp_cx--;
      } until (gp_ax < src)
    }
    gp_ax++;
    dl = fil;
    repeat {
      byte[gp_ax] = dl;
      gp_ax++; gp_cx--;    
    } until (gp_cx == 0)  
  }
  return src;
}
#set frame on;
Admin
Site Admin

avatar

(send private message)

Posts: 923
Topics: 54

Location:
OverHertz Studio
[1868] - posted: 2016-12-13 00:47:30
OK, i have added these for next release.

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Pages: 1
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 1 user(s) online. 0 member(s) and 1 guest(s)
Most users ever online was 533, May 5, 2016, 7:19 am.


Statistics:
Threads: 223 | Posts: 1835 | Members: 50 | Active Members: 50
Welcome to our newest member, NobodyAtWork
const Copyright = '2011-2017 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd