SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 29/01/2020, 02:17 PM   #1
Davi52
Little Clucker
 
Join Date: Sep 2018
Posts: 40
Reputation: 0
Default Converting to lower case errors

Hey, I have some errors and warnings regarding to this function:
Code:
21: CorrectCaps(const string[],dest[]="",len=0)
22: {
23:  	for(new i=1;i<strlen(string);i++)
24:		if(string[i]>64 && string[i]<94)
25:			string[i]+=32;
26:	dest[0]=EOS;
27:	strcat(dest,string,len);
28:	return string;
29: }
The errors:
Code:
(25) : error 022: must be lvalue (non-constant)
(25) : warning 217: loose indentation
(25) : error 017: undefined symbol "i"
(25) : warning 215: expression has no effect
(26) : warning 217: loose indentation
Davi52 is offline   Reply With Quote
Old 29/01/2020, 02:21 PM   #2
Proxus
Huge Clucker
 
Proxus's Avatar
 
Join Date: May 2018
Location: United Kingdom
Posts: 463
Reputation: 20
Default Re: Converting to lower case errors

Quote:
Originally Posted by Davi52 View Post
Hey, I have some errors and warnings regarding to this function:
Code:
21: CorrectCaps(const string[],dest[]="",len=0)
22: {
23:  	for(new i=1;i<strlen(string);i++)
24:		if(string[i]>64 && string[i]<94)
25:			string[i]+=32;
26:	dest[0]=EOS;
27:	strcat(dest,string,len);
28:	return string;
29: }
The errors:
Code:
(25) : error 022: must be lvalue (non-constant)
(25) : warning 217: loose indentation
(25) : error 017: undefined symbol "i"
(25) : warning 215: expression has no effect
(26) : warning 217: loose indentation
Possibly something to do with on this line:
Code:
CorrectCaps(const string[],dest[]="",len=0)
Perhaps it should be like this?:
Code:
CorrectCaps(const string[],dest[],len=0)
__________________
Developer @ Trucknation
"Never tell people how to do things. Tell them what to do and they will surprise you with their ingenuity"


IMPORTANT LINKS
An upcoming mix of trucking & light roleplay
Proxus is offline   Reply With Quote
Old 29/01/2020, 03:31 PM   #3
Calisthenics
High-roller
 
Join Date: May 2018
Posts: 1,228
Reputation: 205
Default Re: Converting to lower case errors

You modify `string` so it cannot be a const array. Also functions may not return arrays of unknown size. Last, you can store what `strlen` returns in a variable to avoid calling the function over and over again.
__________________
Calisthenics is offline   Reply With Quote
Old 29/01/2020, 06:56 PM   #4
Joe Staff
High-roller
 
Join Date: Aug 2007
Posts: 2,593
Reputation: 379
Default Re: Converting to lower case errors

Is there not a "tolower" method that you can call?
Joe Staff is offline   Reply With Quote
Old 29/01/2020, 06:56 PM   #5
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,860
Reputation: 1693
Default Re: Converting to lower case errors

Just wondering if you know this function or not. If you do, ignore this message. If you don't:
http://wiki.sa-mp.com/wiki/tolower
__________________
When the opportunity presents itself to flip-a da table, uh, you flip-a da table.

Discord: Kwarde#8009
Kwarde is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lower case detection. Exhibit Scripting Help 4 21/10/2018 09:30 AM
High/Lower case problem Sensation Scripting Help 2 14/02/2016 04:35 AM
Lower Case (tolower) Help alishvasis Scripting Help 5 22/02/2014 11:21 PM
Converting Nicks to lower case upon register/login Anak Scripting Help 6 24/07/2013 11:32 AM
[REP+] Dialog problem, case 1 causing errors, case 2 and 3 works fine, cant find problem niels44 Scripting Help 0 21/04/2012 06:44 PM


All times are GMT. The time now is 08:23 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.