SA-MP Forums Can please someone explain this function? Thanks
 New Account Members List Search Today's Posts Mark Forums Read

 27/05/2019, 07:29 AM #1 StRaphael Big Clucker     Join Date: Nov 2016 Posts: 124 Reputation: 0 Can please someone explain this function? Thanks Hello, can someone explain the role of single quotes(') in this function please? PHP Code: ``` IsANumber(const inputtext[]) {     for(new i; i < strlen(inputtext); i++)     {         if(inputtext[i] > '9' || inputtext[i] < '0') return 0;     }     return 1; }  ``` What are single quotes used for in pawn scripting? And how does the check work here(I mean how can this function check if a string is a numeral or not and calculate if a letter is higher or lower than 9 or 0)? Thank you
 27/05/2019, 07:47 AM #2 Calisthenics Gangsta   Join Date: May 2018 Posts: 680 Reputation: 111 Re: Can please someone explain this function? Thanks Text is Ascii characters. Number 0 is 48 in ascii and number 9 is 57 in ascii. You can do: pawn Code: `if(inputtext[i] > 57 || inputtext[i] < 48) return 0;` But is it easier to remember those numbers? We use single quote to make it a literal character. Character '9' converts to 57. Character 'A' convers to 65. Reference: http://www.asciitable.com/
27/05/2019, 08:59 AM   #3
StRaphael
Big Clucker

Join Date: Nov 2016
Posts: 124
Reputation: 0
Re: Can please someone explain this function? Thanks

Quote:
 Originally Posted by Calisthenics Text is Ascii characters. Number 0 is 48 in ascii and number 9 is 57 in ascii. You can do: pawn Code: `if(inputtext[i] > 57 || inputtext[i] < 48) return 0;` But is it easier to remember those numbers? We use single quote to make it a literal character. Character '9' converts to 57. Character 'A' convers to 65. Reference: http://www.asciitable.com/
Alright, thank you, that's all what I needed!
+rep

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post akib Scripting Help 3 12/05/2017 05:57 PM Fancy Server Support 3 28/08/2015 06:03 PM MR_MAN Scripting Help 4 11/06/2012 02:00 PM Artie_Scorpion Scripting Help 6 02/01/2012 05:04 PM Rensy Help Archive 1 18/03/2010 08:51 PM

All times are GMT. The time now is 10:42 PM.

 -- (EN) English -- (RU) Русски SA-MP - Archive - Top