Loading ...
Sorry, an error occurred while loading the content.

Re: [libertybasic] Re: how to calculate lines that contains numbers?

Expand Messages
  • Dave
    Bill, I readily admit, in my post i reversed the (d$, n, / ) (only in my post, not in my program) I thought I made my question clear.... d$ = str$(Date$(d))
    Message 1 of 11 , Nov 30, 2008
    • 0 Attachment
      Bill,
      I readily admit, in my post i reversed the (d$, n, "/")
      (only in my post, not in my program)

      I thought I made my question clear....
      d$ = str$(Date$(d))
      print "d$ = "; d$
      result is >> d$ = '09/08/2008'

      Please note that Date$(number) produces chr$(39), then "09/08/2008", then chr$(39)

      My question is: how to parse d$ using Word$()?



      ----- Original Message -----
      From: Bill Lopez
      To: libertybasic@yahoogroups.com
      Sent: Sunday, November 30, 2008 5:51 PM
      Subject: Re: [libertybasic] Re: how to calculate lines that contains numbers?


      By default, WORD$() uses the space (CHR$(32)) as the delimiter for words. However you have the option to specify a different string delimiter, as I have done here using "/" as the string delimiter.

      [code]

      d$="09/08/2008"

      FOR k=1 TO 3
      w=w+1
      PRINT WORD$(d$,w,"/")
      NEXT k

      END

      [/code]

      w gets the 1st, 2d, and 3d word set apart by "/" with each iteration of the loop.

      [Non-text portions of this message have been removed]





      [Non-text portions of this message have been removed]
    • Stefan Pendl
      ... Why do you use STR$(), DATE$() already returns a string in this case? ---code start (watch for line wraps) call SplitText date$(), call SplitText
      Message 2 of 11 , Dec 1, 2008
      • 0 Attachment
        >
        > Bill,
        > I readily admit, in my post i reversed the (d$, n, "/")
        > (only in my post, not in my program)
        >
        > I thought I made my question clear....
        > d$ = str$(Date$(d))
        > print "d$ = "; d$
        > result is >> d$ = '09/08/2008'
        >
        > Please note that Date$(number) produces chr$(39), then
        > "09/08/2008", then chr$(39)
        >
        > My question is: how to parse d$ using Word$()?
        >

        Why do you use STR$(), DATE$() already returns a string in this case?

        '---code start (watch for line wraps)
        call SplitText date$(), " "
        call SplitText date$("mm/dd/yyyy"), "/"
        call SplitText date$("mm/dd/yy"), "/"
        call SplitText date$("yyyy/mm/dd"), "/"
        call SplitText date$(36485), "/"
        end

        sub SplitText String$, Delimiter$
        Count = 0
        print
        print String$

        do
        Count = Count + 1
        print Count; ". Word is ... "; word$(String$, Count, Delimiter$)
        loop until word$(String$, Count + 1, Delimiter$) = ""
        end sub
        '---code end

        ---
        Stefan Pendl
      Your message has been successfully submitted and would be delivered to recipients shortly.