A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Searching a string and then setting variables

Hybrid View

  1. #1
    Junior Member
    Join Date
    Oct 2000
    Posts
    12
    Hi,
    I am trying to search a string in Flash 4 for the character # and if it is found I want to put everything before it into a new variable. For example for the string “Hello this is # a long # string”. I want the result
    variabl1= Hello this is
    variable2= a long
    variable3= string
    I am really stuck with it and any help would be very appreciated.
    -------------------------
    Set Variable: "count" = 1
    Loop While (count <= Length (input))
    Set Variable: "character" = Substring ( input, count,1 )
    If (Substring ( input, count, 1) eq "#")
    Set Variable: "break" = count - 1
    End If
    Set Variable: "character" = Substring (input,0,break)
    Set Variable: "output" = character
    Set Variable: "count" = count + 1
    End Loop
    --------------------------
    This is the way I am trying to do it but as I said I am stuck. Please help.

  2. #2
    Member
    Join Date
    Aug 2000
    Posts
    45
    I would say it is possible doing such string extraction using Flash (client-side process). It would be more powerful, though, if you use PERL (server side processing) with its Regular expression. So, for everyone reading this post, I would like to know your comments : How do you prefer it : using Flash, or CGI ??? And also your comments

    Thx

  3. #3
    Junior Member
    Join Date
    Oct 2000
    Posts
    12
    Hi,
    Thank you for your comments Ferry I,. I agree with you that it will be easier to do this with server side scripting but i have to do this in Flash 4.

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Posts
    263
    bill999,

    Here is the script that will do what you asked for.
    Granted, it could probably be cleaned up a little.
    But Flash is just a hobby for me.

    Set Variable: "start" = 1
    Set Variable: "index" = 1
    Set Variable: "var_length" = 0
    Set Variable: "var_num" = 1
    Loop While (index < Length (input))
    If (Substring (input,index,1) eq "#")
    Set Variable: "variable"&var_num = Substring (input,start,var_length )
    Set Variable: "var_num" = var_num + 1
    Set Variable: "var_length" = -1
    Set Variable: "start" = index + 1
    End If
    Set Variable: "index" = index + 1
    Set Variable: "var_length" = var_length + 1
    End Loop
    Set Variable: "variable"&var_num = Substring (input,start,var_length + 1 )

    Hope this helps.
    MA

    [Edited by Magister Arenei on 10-24-2000 at 01:06 AM]

  5. #5
    Junior Member
    Join Date
    Oct 2000
    Posts
    12
    Hi Magister Arenei,
    Thank you very much for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center