first on a stirng series gives error

Discussion in 'Rebol' started by YueM, May 1, 2010.

  1. YueM

    YueM New Member

    I am having an error when using first on a string series, can someone let me know what is wrong with my code ?
    I am playing with the series feature and see how it works. I am trying to select an option from a drop down list and then select a file from my c: drive . the option selected is "now" and the file name is "new.xls",
    I pick the first character of "now" and compare with the first character of "new.xls" , so I expect both to yield a true if they are equal. which they are in this case.
    However it's giving me an error message.

    the code is below:-

    rebol [ ]

    view layout [
    k: drop-down "Hello" "Now" "Bre" "You"

    ; there is a file new.xls in c/test folder
    button "click me" [ z: request-file/file %/c/test

    print series? (find/last form z "/"
    print second (find/last form z "/"

    print series? k/text
    print first k/text

    ;if I choose "now" from the drop-down and new.xls from
    ;c/test folder, then if I compare the first character
    ;this should give me a true
    if (first k/text = second (find/last form z "/")) [
    print "true"



    ** script error: first expected series argument of type: series pair ....

    ** near: if first k/text = second
  2. Graham

    Graham Developer Staff Member

    Operator precedence is the issue here. Try this

    	if (first k/text ) = second find/last form z "/" [ 
    		print "true"
  3. YueM

    YueM New Member

    Thanks Grahmam for reviewing the code and the solution provided.
  4. Graham

    Graham Developer Staff Member

Share This Page