mirror of
https://github.com/irmen/prog8.git
synced 2025-01-10 20:30:23 +00:00
added string.isdigit, islower, isupper, isletter
This commit is contained in:
parent
f998888d6d
commit
afbc91d1fc
@ -383,4 +383,55 @@ fail clc ; yes, no match found, return with c=0
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub isdigit(ubyte character @A) -> bool @Pc {
|
||||
%asm {{
|
||||
cmp #'0'
|
||||
bcs +
|
||||
rts
|
||||
+ cmp #'9'+1
|
||||
bcc +
|
||||
clc
|
||||
rts
|
||||
+ sec
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub isupper(ubyte character @A) -> bool @Pc {
|
||||
%asm {{
|
||||
cmp #'A'
|
||||
bcs +
|
||||
rts
|
||||
+ cmp #'Z'+1
|
||||
bcc +
|
||||
clc
|
||||
rts
|
||||
+ sec
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub islower(ubyte character @A) -> bool @Pc {
|
||||
%asm {{
|
||||
cmp #'a'
|
||||
bcs +
|
||||
rts
|
||||
+ cmp #'z'+1
|
||||
bcc +
|
||||
clc
|
||||
rts
|
||||
+ sec
|
||||
rts
|
||||
}}
|
||||
}
|
||||
|
||||
asmsub isletter(ubyte character @A) -> bool @Pc {
|
||||
%asm {{
|
||||
jsr islower
|
||||
bcs +
|
||||
jmp isupper
|
||||
+ rts
|
||||
}}
|
||||
}
|
||||
}
|
||||
|
@ -174,4 +174,20 @@ string {
|
||||
return hashcode
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub isdigit(ubyte character) -> bool {
|
||||
return character>='0' and character<='9'
|
||||
}
|
||||
|
||||
sub isupper(ubyte character) -> bool {
|
||||
return character>='A' and character<='Z'
|
||||
}
|
||||
|
||||
sub islower(ubyte character) -> bool {
|
||||
return character>='a' and character<='z'
|
||||
}
|
||||
|
||||
sub isletter(ubyte character) -> bool {
|
||||
return islower(character) or isupper(character)
|
||||
}
|
||||
}
|
||||
|
@ -266,6 +266,9 @@ Provides string manipulation routines.
|
||||
``upperchar (char)``
|
||||
Returns uppercased character.
|
||||
|
||||
``isdigit (char)``, ``islower (char)``, ``isupper (char)``, ``isletter (char)``
|
||||
Returns boolean if the character is a numerical digit 0-0, lowercase letter, uppercase letter, or any letter.
|
||||
|
||||
``startswith (string, prefix) -> bool``
|
||||
Returns true if string starts with prefix, otherwise false
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user