Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (howardR, sleakz), 706 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 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