Register | Login
Forum Index > Source Help > Trim function
Author Message
Pages: 1 2
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[188] Trim function - posted: 2011-10-28 18:02:48

here is the original code from bcx
Code:
function Trim (char* str)
{  
  while(*S==32 || *S==9 || *S==10 || *S==11 || *S==13)
    S++;     
  register int i = strlen(S);
  while( i>0 && (S[i-1]==32 || S[i-1]==9 || S[i-1]==10
             || S[i-1]==11 || S[i-1]==13))
    i--;
  char *strtmp=BCX_TmpStr(i);
  return (char*)memcpy(strtmp,S,i);  
}


so i start trying to convert it like this
Code:
function Trim (char* str)
{  
//  while(*S==32 || *S==9 || *S==10 || *S==11 || *S==13)
//    S++;
  Ebx = str;
  al = char[Ebx];
  while(al == 32 or al == 9 or al == 10 or al == 11 or al == 13) // error here
   {
     Ebx++;
     al = char[Ebx];
   }  
}


but it did not compiled any help please.


http://www.freewebs.com/ogremagic/index.htm
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[189] - posted: 2011-10-28 19:56:42
note that ors and ands must be parenthesized

Code:
while((al == 32) or (al == 9) or (al == 10) or (al == 11) or (al == 13))


Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[190] - posted: 2011-10-28 20:38:42

after made your notes still have this error

Expected ) but found or ?



http://www.freewebs.com/ogremagic/index.htm
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[191] - posted: 2011-10-28 20:58:51

any way i have solved it by this code , BTW if statement seems it support multi or without parenthesis.
Code:
/*
  while((al == 32) or (al == 9) or (al == 10) or (al == 11) or (al == 13))
   {
     Ebx++;
     al = char[Ebx];
   }
*/

@Rept:     
 if(al==32 or al==9 or al==10 or al==11 or al==13)
  { 
    Ebx++;
    al = char[Ebx];
    goto @Rept;
  }   


http://www.freewebs.com/ogremagic/index.htm
Admin
Site Admin

avatar

(send private message)

Posts: 933
Topics: 55

Location:
OverHertz Studio
[192] - posted: 2011-10-28 21:16:05
i will take a look into that thanks

Download Ziron
Get free hosting for Ziron related fan-sites and Ziron projects, contact me in private message.
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[193] - posted: 2011-10-28 21:57:10

ok here is the function
Code:
function Trim (char* str)
{  
  uses Ebx Ecx;
  Ebx = str;
  al = char[Ebx];
@Rept:     
 if(al==32 or al==9 or al==10 or al==11 or al==13)
  { 
    Ebx++;
    al = char[Ebx];
    goto @Rept;
  }     
 Ecx = Ebx;
 while(char[Ecx] != 0)
  {
     Ecx++;
  }
 sub Ecx,Ebx 
 Eax = GetTmpStr(Ecx);
 push Eax
 strlcpy(Eax,Ebx,Ecx);
 pop Eax
}


http://www.freewebs.com/ogremagic/index.htm
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[198] - posted: 2011-10-29 18:42:40

i have changed Trim so that you can supply a pointer to holed the length of trimed string.

but when i used the indirect pointer just like C&C++ Ziron didnot accept it.

any help please?
Code:
function Trim(char* str;int32* len)
{  
  uses Ebx Ecx;
  Ebx = str;
  al = char[Ebx];
@Rept:     
 if(al==32 or al==9 or al==10 or al==11 or al==13)
  { 
    Ebx++;
    al = char[Ebx];
    goto @Rept;
  }     
 Ecx = Ebx;
 while(char[Ecx] != 0)
  {
     Ecx++;
  }
 al = char[Ecx-1];
@Rept1:
  if(al==32 or al==9 or al==10 or al==11 or al==13)
  { 
    Ecx--;
    al = char[Ecx-1];
    goto @Rept1;
  }     
 sub Ecx,Ebx 
 if(len != nil )
  {
    *len = Ecx;  //-------------------- error here
  }
 Eax = GetTmpStr(Ecx);
 push Eax
 strlcpy(Eax,Ebx,Ecx);
 pop Eax
 char[Eax+Ecx]=0;
}


http://www.freewebs.com/ogremagic/index.htm
Emil_halim
Ziron Beta Tester

avatar

(send private message)

Posts: 639
Topics: 104

Location:
Alex, Egypt
[199] - posted: 2011-10-29 18:44:01

sorry i pushed '' instead # , and have on way to change previous post.

http://www.freewebs.com/ogremagic/index.htm
Pages: 1 2
create new reply


Quick reply:

Message:



Currently Active Users:
There are currently 6 user(s) online. 0 member(s) and 6 guest(s)
Most users ever online was 1046, January 28, 2022, 2:08 pm.


Statistics:
Threads: 225 | Posts: 1848 | Members: 51 | Active Members: 51
Welcome to our newest member, yecate
const Copyright = '2011-2024 © OverHertz Ltd. All rights reserved.';
Web development by OverHertz Ltd