How to test if String contains a number?

Talk about whatever topic you'd like, RPG related or not. (But please discuss things related to our software in the Tools section, below.)

Moderators: Azhrei, dorpond, trevor

Post Reply
Merudo
Giant
Posts: 228
Joined: Wed Jun 05, 2019 7:06 am

How to test if String contains a number?

Post by Merudo »

How can I test if a string contains a number?

I want to use the "eval" function on a string, but when I do it on a string without numbers I get the following:

Invalid number of parameters 0, expected at least 1 parameters

User avatar
aliasmask
Deity
Posts: 8580
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: How to test if String contains a number?

Post by aliasmask »

You can use Wiki: isNumber() or you can use this trick.

Code: Select all

[H: result = eval(""+value)]
OR
[H: result = eval(string(value))]

Post Reply

Return to “General Discussion”