hi, about that code:
Sub GetSubBranch(sBranch, Index)
Dim hbuf as long;
Dim sSubBranch as str;
hbuf = alloc_buffer(250);
Put_Buffer(hbuf, 0, sBranch);
sSubBranch = Asciifield("STR", hbuf, Index, ".");
free_buffer(hbuf);
return(sSubBranch);
End Sub
How to get the parent branch here?
ok, I got it (dont forget to check for null-result in case of out-of-range):
Sub GetSubBranch(sBranch, Index)
'Retrieve subbranch from index
'if index == 0, parent branch is returned
Dim hbuf as long;
Dim sSubBranch as str;
hbuf = alloc_buffer(250);
Put_Buffer(hbuf, 0, sBranch);
if(Index ==0) then
sSubBranch = Asciifield("STR", hbuf, Asciifield("COUNT", hbuf,".")-1, ".");
else
sSubBranch = Asciifield("STR", hbuf, Index, ".");
end if
free_buffer(hbuf);
return(sSubBranch);
End Sub
Hello,
I think that is even better:
sub helper_GetSubBranch(sBranch, Index,i_dir)
'Retrieve subbranch from index
'Switch index-direction 0 = left, 1 = right
'if index == 0, parent branch is returned
Dim hbuf as long;
Dim sSubBranch as str;
hbuf = alloc_buffer(250);
Put_Buffer(hbuf, 0, sBranch);
if(Index ==0) then
sSubBranch = Asciifield("STR", hbuf, Asciifield("COUNT", hbuf,".")-1, ".");
else
if(i_dir ==0) then
sSubBranch = Asciifield("STR", hbuf, Index, ".");
else
sSubBranch = Asciifield("STR", hbuf, Asciifield("COUNT", hbuf,".")-Index, ".");
end if
end if
free_buffer(hbuf);
return(sSubBranch);
End Sub
- 1
- 2


