forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


List joining and parting help

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Mon Apr 07, 2003 4:12 pm    Post subject: List joining and parting help Reply with quote

I have been playing with binfile now for a few days and i think im getting the hang of it.

my question is though, how do i take a list i already have, and make it so all the items in the list are one string, with symbols or something between each item?
Then how do i make that string back into a list putting each item back in the list how it was at the start?

thank you
Back to top
View user's profile Send private message
nick
Contributor
Contributor


Joined: 15 Aug 2000
Posts: 50
Location: hamburg,nj

PostPosted: Mon Apr 07, 2003 5:57 pm    Post subject: Reply with quote

Hi:
I think you can take each item in your list and append @chr(13)@chr(10).
This way the binfile will be the exact format as your list. I have done this before and I think I am right. I will try ro look for the code I used.

_________________
nick
Back to top
View user's profile Send private message
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Mon Apr 07, 2003 7:00 pm    Post subject: Reply with quote

im not sure i follow.
Back to top
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Mon Apr 07, 2003 7:06 pm    Post subject: Reply with quote

I think Nick means something like this:

Code:
list create,1
list loadtext,1
"Apple
"Pear
"Orange
"Tomato

%x = 0
repeat
list seek,1,%x
list put,1,@item(1, %x)@chr(13)@chr(10)
%x = @succ(%x)
until @equal(@count(1),%x)

list close,1
exit

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Mon Apr 07, 2003 7:16 pm    Post subject: Reply with quote

This is one way you could do it:
Code:

REM Create a hidden dialog so we can parse the %%String into the List element later.
REM I don't think you can parse into an external(LIST CREATE) list so we are using the one below.
DIALOG CREATE,Dummy Dialog,0,0,0,0
DIALOG ADD,LIST,List1,0,0,0,0
REM Create a list to get the info from.
LIST CREATE,1
REM Add info.
LIST ADD,1,Test 1
LIST ADD,1,Test 2
LIST ADD,1,Test 3
LIST ADD,1,Test 4
LIST ADD,1,Test 5
REM Character to seperate each list item with.
REM The one below will give the same effect as hitting the enter key.
%%FieldSep = @CHR(13)@CHR(10)
REM Go through the list and add each item to the %%String variable.
%x = 0
repeat
  IF @EQUAL(%x,@FSUB(@COUNT(1),1))
    REM If we are adding the last list item, don't add a seperator.
    %%String = %%String@ITEM(1,%x)
  ELSE
    %%String = %%String@ITEM(1,%x)%%FieldSep
  END
  %x = @SUCC(%x)
until @EQUAL(%x,@COUNT(1))
REM Show %%String with all the items put together.
INFO %%String
REM Create a list to put the items from %%String into.
LIST CREATE,2
REM Parse the items from %%String into List1
PARSE "List1",%%String
REM Put everything in List1 into the list called 2.
LIST ASSIGN,2,List1
REM Show all items in list 2.
INFO @TEXT(2)

_________________
-Sheep
My pockets hurt...


Last edited by SnarlingSheep on Mon Apr 07, 2003 8:30 pm; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Mon Apr 07, 2003 8:22 pm    Post subject: Reply with quote

Can someone please cooment these source codes so i can learn from them please.
Back to top
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Mon Apr 07, 2003 8:27 pm    Post subject: Reply with quote

Here's mine, although this source code just illustrates what Nick was
saying, it doesn't necessarily work for what you need.

Code:
REM -- Create a list on LIST 1 --
list create,1
REM -- Load the list with some text --
list loadtext,1
"Apple
"Pear
"Orange
"Tomato

REM -- Start the incremental variable at 0 --
%x = 0
REM -- Start REPEAT/UNTIL loop --
repeat
REM -- Seek list to the position of the var %x --
list seek,1,%x
REM -- Replace the current item with a copy
REM -- of the current item + @chr(13)@chr(10) --
list put,1,@item(1, %x)@chr(13)@chr(10)
REM -- Increment the var %x one number --
%x = @succ(%x)
REM -- If the var %x and the count of the items
REM -- in list 1 are equal then exit the repeat loop --
until @equal(@count(1),%x)

REM -- Close list 1 so we can use it later --
list close,1
REM -- Exit the script --
exit

_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
SnarlingSheep
Professional Member
Professional Member


Joined: 13 Mar 2001
Posts: 759
Location: Michigan

PostPosted: Mon Apr 07, 2003 8:31 pm    Post subject: Reply with quote

I've commented my code above, hopefully it helps a bit more now.
_________________
-Sheep
My pockets hurt...
Back to top
View user's profile Send private message Send e-mail
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Mon Apr 07, 2003 9:01 pm    Post subject: Reply with quote

Thank you both so much, I know im a pain, but i guess everyone has to learn at some point.

This sould do it thank you.
Back to top
View user's profile Send private message
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Mon Apr 07, 2003 9:03 pm    Post subject: Reply with quote

No, you're not a pain, because I was just like you once. Smile
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
nick
Contributor
Contributor


Joined: 15 Aug 2000
Posts: 50
Location: hamburg,nj

PostPosted: Mon Apr 07, 2003 9:47 pm    Post subject: Reply with quote

Hi:
Sorry I didn't answer sooner. Here is a snipet of code that takes the items in your normal list and uses the binfile write function.

Code:

BINFILE open,1,<yourfilename>,create
List seek,1,0
%%binfile = @next(1)
REPEAT
BINFILE WRITE,1,TEXT,%%binfile@chr(13)@chr(10)
%%binfile = @next(1)
UNTIL @null(%%binfile)
BINFILE CLOSE,1


The list 1 and Binfile should be identical. I used a similar routine for adding data to a file without using list savefile. Hope this helps.

_________________
nick
Back to top
View user's profile Send private message
DW
Contributor
Contributor


Joined: 21 Mar 2003
Posts: 175
Location: UK

PostPosted: Mon Apr 07, 2003 9:49 pm    Post subject: Reply with quote

Thank you, you are all so much help.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group