Old 06-01-2016, 01:08 PM   #1
SaschArt
Human being with feelings
 
SaschArt's Avatar
 
Join Date: Aug 2013
Posts: 236
Default String to array

A solution exist in JSFX to fill an array from a string? I tried this code with no success:

Code:
@init

arr_max=33;
arr=0;


function splitString(str) 
local(i,pos) (
  
  i=0;
  pos=0;
  while (pos<strlen(str)) (
    arr[i]=strcpy_substr(#,str,pos,2);
    pos+=2;
    i+=1;
  );
);

@gfx 100 10
gfx_r=gfx_g=gfx_b=1;
gfx_x=gfx_y=3;

i=0;
while (i<=arr_max ?
  arr[i] ? (
    #arr = sprintf(#, "%d", i);
    #arr+="=>";
    #arr+= arr[i];
    #arr+=" ";
    gfx_drawstr(#arr);
    gfx_x=3;
    gfx_y+=gfx_texth+1;
  );
  i+=1;
);
SaschArt is offline   Reply With Quote
Old 06-03-2016, 06:09 AM   #2
SaschArt
Human being with feelings
 
SaschArt's Avatar
 
Join Date: Aug 2013
Posts: 236
Default

Solved with
arr[i]=strcpy_substr(i+1,str,pos,2);
SaschArt is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 03:10 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.