Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (SBGuy), 652 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
extract characters from a string #487344
03/21/23 19:23
03/21/23 19:23
Joined: Jul 2020
Posts: 9
England
D
Domino Offline OP
Newbie
Domino  Offline OP
Newbie
D

Joined: Jul 2020
Posts: 9
England
I have a 4 character and I wish to know what is the third character.
How di I extract a give character(s) ( character 3 or 4 to 5). Must be a function.

Re: extract characters from a string [Re: Domino] #487345
03/21/23 20:19
03/21/23 20:19
Joined: Aug 2017
Posts: 294
Netherlands
G
Grant Offline
Member
Grant  Offline
Member
G

Joined: Aug 2017
Posts: 294
Netherlands
Look for the strmid() function

Re: extract characters from a string [Re: Domino] #487346
03/21/23 20:22
03/21/23 20:22
Joined: Jun 2008
Posts: 30
Russia\Georgia
VoroneTZ Offline
Newbie
VoroneTZ  Offline
Newbie

Joined: Jun 2008
Posts: 30
Russia\Georgia
function GetChar(STRING* Astr, STRING* Aresult, int Anum) // Source, Result, Index of character
{
str_cpy(Aresult,(Astr.chars)[Anum]); //get 3rd char (i dunno why we have 4th char too)
str_trunc(Aresult,str_len(Aresult)-1); //delete all chars, except 1st
}

<...>
STRING* fstart="1234";
STRING* fresult="";
GetChar(fstart,fresult, 3); //copy 3rd char to fresult
printf(fresult.chars); // print result
<...>


Moderated by  HeelX 

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