AT2k Design BBS Message Area
Casually read the BBS message area using an easy to use interface. Messages are categorized exactly like they are on the BBS. You may post new messages or reply to existing messages!

You are not logged in. Login here for full access privileges.

Previous Message | Next Message | Back to Scripts Only! (Code Only)  <--  <--- Return to Home Page
   Networked Database  Scripts Only! (Code Only)   [25 / 68] RSS
 From   To   Subject   Date/Time 
Message   Steve Winn    All   Split sub   December 4, 2006
 7:52 PM  

Here is a subroutine I just made which will split data using a delimiter and
store it in the array. Actually this is a full example, but you would be
interested in the Split and Clear_Array functions to put it in another script.

-- BEGIN SCRIPT --
CLEAR
' You need to set x1 and y1 then call the subroutine.
' x1 is the string with the data.
' y1 is the delimiter.
LET x1 = "test:100:200:blah::blah"
LET y1 = ":"
GOSUB Split

' Print the results.
PRINT $1
PRINT $2
PRINT $3
PRINT $4
PRINT $5
PRINT $6

GOTO Exit



Split:
' This splits up a string using the delimiter and returns
' the result in the array.
' Clear the array.
GOSUB Clear_Array

' The counter variable.
LET z1 = 1

Split_Loop:
' Get the position of the delimiter.
LET x0 = x1
LET y0 = y1
LET z0 = !8

' If no more delimiter then exit.
IFVAL z0 = 0 GOTO Split_Loop_End

' Extract the next value.
LET z0 = z0 - 1
LEFT x2, x0, z0

' Assign this value to the next array slot.
LET $z1 = x2

' Update the temp string.
LET z0 = z0 + 2
MID x1, x0, z0

' Increase the array counter.
LET z1 = z1 + 1
GOTO Split_Loop

Split_Loop_End:
' Add the last entry (or first heh).
LET $z1 = x1

LET x0 = ""
LET x1 = ""
LET x2 = ""
LET y0 = ""
LET y1 = ""
LET z0 = ""
LET z1 = ""
RETURN



Clear_Array:
DO x0, 1, 255
  LET $x0 = ""
LOOP
RETURN



Exit:
-- END SCRIPT --

Hope this helps.

Steve


--
[AT2k] -- Your VBBS/VADV Support Center -- [www.at2k.org] -- [bbs.at2k.org]
  Show ANSI Codes | Hide BBCodes | Show Color Codes | Hide Encoding | Hide HTML Tags | Show Routing
Previous Message | Next Message | Back to Scripts Only! (Code Only)  <--  <--- Return to Home Page

VADV-PHP
Execution Time: 0.0167 seconds

If you experience any problems with this website or need help, contact the webmaster.
VADV-PHP Copyright © 2002-2024 Steve Winn, Aspect Technologies. All Rights Reserved.
Virtual Advanced Copyright © 1995-1997 Roland De Graaf.
v2.1.241108