Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,549 guests, and 14 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
different letters in a word string #366694
04/06/11 13:09
04/06/11 13:09
Joined: Feb 2007
Posts: 146
UK
robertbruce Offline OP
Member
robertbruce  Offline OP
Member

Joined: Feb 2007
Posts: 146
UK
Hello,

Trying to get my head around this. If I have a word string that can contain any word how can I return a variable that provides the number of different letters contained in that word.

Example:

var number_of_different_letters;

string myword = "potatoe"; // the word
string myword2 = "rocket"; // another word

Is it possible to assign the number of different letters from these strings into the variable number_of_different_letters?


So for

myword: number_of_different_letters = 5; since there are 2 instances of t and 0

myword2: number_of_different_letters = 6;// all different letters


Would appreciate any help.

best regards,

Rob

Re: different letters in a word string [Re: robertbruce] #366697
04/06/11 13:52
04/06/11 13:52
Joined: Nov 2010
Posts: 96
Vienna
S
Schubido Offline
Junior Member
Schubido  Offline
Junior Member
S

Joined: Nov 2010
Posts: 96
Vienna
Hi,

during a boring telephone conference I typed this in notepad - so it is neither tested nor compiled, but the principle should work.

Code:
var different_letters(char* s)
{
  var letterflag[256];
  var count = 0;
  var i,l;
  l=str_len(s);
  for (i=0;i<l;i++) {letterflag[i]=TRUE};
  for (i=0;i<l;i++)
  {
    if (letterflag[(integer)(s[i])])
      count++;
    else
      letterflag[(integer)(s[i])]=FALSE;
  }
  return (count);
}



Re: different letters in a word string [Re: Schubido] #366838
04/07/11 16:18
04/07/11 16:18
Joined: Feb 2007
Posts: 146
UK
robertbruce Offline OP
Member
robertbruce  Offline OP
Member

Joined: Feb 2007
Posts: 146
UK
must have been some meeting.

Thanks for the code. Just need to convert to c-script,

Rob

Re: different letters in a word string [Re: robertbruce] #366942
04/08/11 07:32
04/08/11 07:32
Joined: Nov 2010
Posts: 96
Vienna
S
Schubido Offline
Junior Member
Schubido  Offline
Junior Member
S

Joined: Nov 2010
Posts: 96
Vienna
Uuups - this is the C-Script forum. eek
I opened your post from the "Newest Posts" section and did not recognize this.
Well, I don't speak C-Script, but I hope the differences are not too big.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1