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

Help with code

Expand Messages
  • pigmanpc
    OPEN FILENAME$ FOR RANDOM AS #1 LEN = 146 FIELD #1,_ 20 AS LNAME$,_ 15 AS FNAME$,_ 40 AS ADD$,_ 15 AS CITY$,_ 2 AS STATE$,_ 5 AS ZIP$,_ 12 AS TEL$,_ 2 AS
    Message 1 of 12 , Dec 24, 2006
    • 0 Attachment
      OPEN FILENAME$ FOR RANDOM AS #1 LEN = 146
      FIELD #1,_
      20 AS LNAME$,_
      15 AS FNAME$,_
      40 AS ADD$,_
      15 AS CITY$,_
      2 AS STATE$,_
      5 AS ZIP$,_
      12 AS TEL$,_
      2 AS ADT$,_
      2 AS CHILD$,_
      23 AS AGES$,_
      10 AS DT$

      FL = LOF(#1) / 146

      DIM array$(FL)

      FOR X = 1 TO FL
      GETTRIM #1, X
      NUM = X
      array$(X) = NUM;" ";LNAME$;", ";FNAME$;" ";ADD$;
      DOT = LEN(NUM) + LEN(LNAME$) + LEN(FNAME$) + LEN(ADD$)
      DOT = DOT + 10: DDT = 70 - DOT
      FOR DD = 1 TO DDT
      PRINT "-";
      NEXT DD
      DT$
      NEXT X


      I am getting a sintax error when I am loading the array.
      Please let me know what is wrong

      I am trying to put dashes between the address and the date so the date
      will always be on the right side of my listbox.

      thanks pigmanpc
    • Gordon Rahman
      Hello Pigmanpc, I know that you want to place the array in a listbox. In the listbox you found that the DATE doesn t fit neatly. This is all because of the
      Message 2 of 12 , Dec 31, 2006
      • 0 Attachment
        Hello Pigmanpc,

        I know that you want to place the array in a listbox.
        In the listbox you found that the DATE doesn't fit neatly.
        This is all because of the font you use.
        Please follow our advice and use Courier new for instance.

        I already replied with the code.
        Good luck.... I have no problem here with the listing.

        Gordon.



        --- In libertybasic@yahoogroups.com, "pigmanpc" <pigmanpc@...> wrote:
        >
        > Here is the code that I am having trouble with
        >
        > OPEN FILENAME$ FOR RANDOM AS #1 LEN = 146
        > FIELD #1,_
        > 20 AS LNAME$,_
        > 15 AS FNAME$,_
        > 40 AS ADD$,_
        > 15 AS CITY$,_
        > 2 AS STATE$,_
        > 5 AS ZIP$,_
        > 12 AS TEL$,_
        > 2 AS ADT$,_
        > 2 AS CHILD$,_
        > 23 AS AGES$,_
        > 10 AS DT$
        >
        > FL = LOF(#1) / 146
        >
        > DIM array$(FL)
        >
        > FOR X = 1 TO FL
        > GETTRIM #1, X
        > DASH$ = ""
        > DOT = 0
        > DDT = 0
        > DOT = LEN(LNAME$) + LEN(FNAME$) + LEN(ADD$)
        > DDT = 50 - DOT
        > FOR DD = 1 TO DDT
        > DASH$ = DASH$ + "="
        > NEXT DD
        > array$(X) = Using("####", X) + " " + LNAME$ + ", " +
        FNAME$ +
        > " " + ADD$ + DASH$ + DT$
        >
        > NEXT X
        >
        > The out put I need will look like this.
        >
        > 1 layer, paul 2370 se 45th ave
        =========================10/25/2006
        > 2 lost, friend somewhere
        ===============================10/29/2006
        > 3 lambskin, woolie black sheep lane
        ===================11/02/2006
        >
        >
        > The LNAME$ and FNAME$ and ADD$ are all variable length. the DT$
        > contains the date that I am trying to put on the right side in a
        > column. The code i have here does work but the dashes do not make
        the
        > date on the right in a column.
        >
        > thanks
        > pigmanpc
        >
      • William E. Lopez
        array$(X) = NUM; ;LNAME$; , ;FNAME$; ;ADD$; NUM is a numerical variable and cannot be loaded into array$(X) without first converting it to STR$(NUM).
        Message 3 of 12 , Jan 2, 2007
        • 0 Attachment
          array$(X) = NUM;" ";LNAME$;", ";FNAME$;" ";ADD$;


          NUM is a numerical variable and cannot be loaded into array$(X) without first converting it to STR$(NUM).

          Before printing, you can use a WHILE/WEND as follows:

          WHILE LEN(array$(X))<70
          array$(X)=array$(X)+"-" 'pads the string to 70 characters
          WEND

          PRINT array$(X);DT$

          You should finish with 80 characters per line, assuming DT$ is mm/dd/yyyy

          [Non-text portions of this message have been removed]
        • Gordon Rahman
          Hello Pigmanpc, I think that I have to advice you to read some of the tutorials and the helpfile very carefully. Especially the chapters concerning variables,
          Message 4 of 12 , Jan 2, 2007
          • 0 Attachment
            Hello Pigmanpc,

            I think that I have to advice you to read some of the tutorials and
            the helpfile very carefully. Especially the chapters concerning
            variables, strings and arrays.

            It's not allowed to mix up strings with numerical variables.
            So...the statement < array$(X) =
            NUM ;" ";LNAME$;", ";FNAME$;" ";ADD$; >
            will generate a syntax error.
            NUM is a numerical variable while LNAME$ is
            a string variable. array$(X) is a string variable too. Every
            variable ending on a $ sign is a string variable.
            To change NUM into a string I used str$(NUM).
            So please read everything about the function str$()too, while you
            are reading about variables in the helpfile....

            Gordon



            --- In libertybasic@yahoogroups.com, "pigmanpc" <pigmanpc@...> wrote:
            >
            > OPEN FILENAME$ FOR RANDOM AS #1 LEN = 146
            > FIELD #1,_
            > 20 AS LNAME$,_
            > 15 AS FNAME$,_
            > 40 AS ADD$,_
            > 15 AS CITY$,_
            > 2 AS STATE$,_
            > 5 AS ZIP$,_
            > 12 AS TEL$,_
            > 2 AS ADT$,_
            > 2 AS CHILD$,_
            > 23 AS AGES$,_
            > 10 AS DT$
            >
            > FL = LOF(#1) / 146
            >
            > DIM array$(FL)
            >
            > FOR X = 1 TO FL
            > GETTRIM #1, X
            > NUM = X
            > array$(X) = NUM;" ";LNAME$;", ";FNAME$;" ";ADD$;
            > DOT = LEN(NUM) + LEN(LNAME$) + LEN(FNAME$) + LEN(ADD$)
            > DOT = DOT + 10: DDT = 70 - DOT
            > FOR DD = 1 TO DDT
            > PRINT "-";
            > NEXT DD
            > DT$
            > NEXT X
            >
            >
            > I am getting a sintax error when I am loading the array.
            > Please let me know what is wrong
            >
            > I am trying to put dashes between the address and the date so the
            date
            > will always be on the right side of my listbox.
            >
            > thanks pigmanpc
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.