Forgot?

Register
1 ·
Are all my bases covered?
Posts: 351
Status: Offline
Group: Member
Member: #13
if (vButtonMode) {     vButtonMode = 0;     vSubjectX = string_digits(get_string("Sprite width? Letters and symbols will be ignored.","32"));     if (vSubjectX == "")     || (round(real(vSubjectX)) != real(vSubjectX))     {         do         {             vReady = 0;             vSubjectX = string_digits(get_string("I need whole digits, wisenheimer.","32"));             if (vSubjectX != "")             && (round(real(vSubjectX)) == real(vSubjectX))             {                 vReady = 1;             }                     }         until (vReady)     }     }


EDIT: Whoops, I just realized this still makes decimals like 4.59 return to 459.
Posts: 351
Status: Offline
Group: Member
Member: #13
Here's what I was after:

if (vButtonMode) {     vButtonMode = 0;     vSubjectX = get_string("Sprite width? Digits only please.","32");     if (string_digits(vSubjectX) != string(vSubjectX))     {         do         {             vSubjectX = get_string("Whole digits only, wisenheimer.","32");                     }         until (string_digits(vSubjectX) == string(vSubjectX))     }     }
Posts: 351
Status: Offline
Group: Member
Member: #13
Wait, one more fix:

if (vButtonMode) {     vButtonMode = 0;     do     {         vSubjectX = get_string("Sprite width? Whole digits only, please.","32");                 }     until (string_digits(vSubjectX) == string(vSubjectX))   }


I guess I can remove the wisenheimer remark for the sake of more efficient coding.
Posts: 342
Status: Offline
Group: Member
Member: #42
Hmm, I'm kinda confused here. What's the code for?

Posts: 351
Status: Offline
Group: Member
Member: #13
Nothing important. But I was being stupid, I wanted it to get a string from a user and reject any non-digit strings, and it took me all that just to figure out I could have done it much simpler.
Posts: 195
Status: Offline
Group: Member
Member: #19
i have no idea what language this is but i'm going to pretend to improve it
if (vButtonMode) {     vButtonMode = 0;     do     {         vSubjectXtest = get_string("Sprite width? Whole digits only, please.","32");         vSubjectX = string_digits(vSubjectX);                 }     until (vSubjectX == vSubjectXtest)   }

I assume you'll want the variable that's the digits in the end anyway, so you might as well set the digit one to the variable name beforehand

also im gonna assume since there's a get_string function there's probably a get_integer function of some kind so that's probably what you want?

also you might want only positive integers because i'm sure negative numbers would be weird too
Posts: 351
Status: Offline
Group: Member
Member: #13
Whoops I thought I posted this in the spam forum.

Anyway, string_digits doesn't accept decimal points or minus signs anyway.

You're right, there is a get_integer function.
-/+
Users Viewing This Topic
1 ·