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
    • 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 2 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
      • stefanhes
        ... / remove the last ; after ADD$ ... / remove LEN(NUM) or replace it with NUM only ... /remove DT$ ... hth Stefan Hesseling
        Message 3 of 12 , Dec 24, 2006
        • 0 Attachment
          --- 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$;
          / remove the last ; after ADD$
          > DOT = LEN(NUM) + LEN(LNAME$) + LEN(FNAME$) + LEN(ADD$)
          / remove LEN(NUM) or replace it with NUM only
          > DOT = DOT + 10: DDT = 70 - DOT
          > FOR DD = 1 TO DDT
          > PRINT "-";
          > NEXT DD
          > DT$
          /remove DT$
          > NEXT X
          >

          hth

          Stefan Hesseling
        • pigmanpc
          I need all of this to be on the same line. The dt$ contains a date that I want to move to the right side of the windows. Again thanks.
          Message 4 of 12 , Dec 24, 2006
          • 0 Attachment
            I need all of this to be on the same line. The dt$ contains a date
            that I want to move to the right side of the windows.
            Again thanks.


            --- In libertybasic@yahoogroups.com, "stefanhes" <sjmhesseling@...> wrote:
            >
            > --- 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$;
            > / remove the last ; after ADD$
            > > DOT = LEN(NUM) + LEN(LNAME$) + LEN(FNAME$) + LEN(ADD$)
            > / remove LEN(NUM) or replace it with NUM only
            > > DOT = DOT + 10: DDT = 70 - DOT
            > > FOR DD = 1 TO DDT
            > > PRINT "-";
            > > NEXT DD
            > > DT$
            > /remove DT$
            > > NEXT X
            > >
            >
            > hth
            >
            > Stefan Hesseling
            >
          • Gordon Rahman
            This is what I did? FILENAME$ = testabestand.txt OPEN FILENAME$ FOR RANDOM AS #1 LEN = 146 FIELD #1,_ 20 AS LNAME$,_ 15 AS FNAME$,_ 40 AS ADD$,_ 15 AS
            Message 5 of 12 , Dec 24, 2006
            • 0 Attachment
              This is what I did?

              FILENAME$ = "testabestand.txt"

              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$

              goto [secondPart]

              '*****************************************
              'first part just to fill my file
              [inputLoop]
              print
              input "Last Name >";LNAME$
              input "First Name >";FNAME$
              input "Addres >";ADD$
              input "City >"; CITY$
              input "State >"; STATE$
              input "Zip Code >"; ZIP$
              input "Telephone >";TEL$
              input "ADT >"; ADT$
              input "Childeren >";CHILD$
              input "Ages >";AGES$
              input "DT >";DT$

              confirm "Is this entry correct?"; yesNo$
              if yesNo$ = "no" then [inputLoop]
              recNumber = recNumber + 1
              put #1, recNumber

              confirm "Enter more records?"; yesNo$
              if yesNo$ = "yes" then [inputLoop]

              close #1
              end

              'end first part
              '*********************************************

              [secondPart]
              FL = LOF(#1) / 146

              DIM array$(FL)

              FOR X = 1 TO FL
              GETTRIM #1, X
              NUM = X
              array$(X) = str$(NUM)+" "+LNAME$+", "+FNAME$+" "+ADD$
              DOT = LEN(str$(NUM)) + LEN(LNAME$) + LEN(FNAME$) + LEN(ADD$)
              DOT = DOT + 10
              DDT = 70 - DOT

              FOR DD = 1 TO DDT
              PRINT "-";
              NEXT DD
              print array$(X)
              'DT$
              NEXT X
              close #1
              wait


              You make no sence, but mind you my English is bad.
              Could you explain your wishes better for me?

              Gordon.
            • jose hernandez
              You can use the following sintax: Example for a file to 50 items line = 50 End of file bfr = 0 Buffer to open open c: folder filename.fil
              Message 6 of 12 , Dec 25, 2006
              • 0 Attachment
                You can use the following sintax:


                ' Example for a file to 50 items

                line = 50 ' End of file
                bfr = 0 ' Buffer to open

                open "c:\folder\filename.fil" for random as #1 len=146
                10 bfr=bfr+1 : if bfr = line then close #1 : end
                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$
                gettrim #1, bfr

                array$(bfr) = var1$+" "+var2$+" "+................. 'create array, use the variables as you wants

                goto 10 'return to next field

                any questions contact me
                mail : jjh2000_100@...


                ----- Original Message ----
                From: pigmanpc <pigmanpc@...>
                To: libertybasic@yahoogroups.com
                Sent: Sunday, December 24, 2006 1:16:32 PM
                Subject: [libertybasic] Help with code

                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




                __________________________________________________
                Do You Yahoo!?
                Tired of spam? Yahoo! Mail has the best spam protection around
                http://mail.yahoo.com

                [Non-text portions of this message have been removed]
              • pigmanpc
                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
                Message 7 of 12 , Dec 30, 2006
                • 0 Attachment
                  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
                • stefanhes
                  ... Did you use the font COURIER NEW ? Stefan Hesseling
                  Message 8 of 12 , Dec 31, 2006
                  • 0 Attachment
                    > column. The code i have here does work but the dashes do not make the
                    > date on the right in a column.
                    >

                    Did you use the font COURIER NEW ?

                    Stefan Hesseling
                  • Yahoo
                    ... 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
                    Message 9 of 12 , Dec 31, 2006
                    • 0 Attachment
                      At 12:05 AM 12/31/06 -0000, you 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.
                      <<<<--------------------------------------------------

                      Run this snip to get the idea.
                      Bill J.

                      X=1
                      LNAME$="layer"
                      FNAME$="paul"
                      ADD$="2370 se 45th ave"
                      DT$="10/25/2006"
                      lg=66 : dash$=""
                      totDash=lg-(len(LNAME$)+len(FNAME$)+len(ADD$)+16)
                      for j=1 to totDash
                      dash$=dash$+"="
                      next j
                      print Using("####", X)+" "+LNAME$+", "+FNAME$+" "+ADD$+" "+dash$+DT$
                    • 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 10 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 11 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 12 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.