Board Logo
« tabular data in text file »

Welcome Guest. Please Login or Register.
Jan 18th, 2018, 3:55pm


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: tabular data in text file  (Read 48 times)
zzz000abc
Full Member
ImageImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 268
xx tabular data in text file
« Thread started on: Jan 13th, 2018, 1:10pm »

hi,
here is program to create table in text file
Code:
        input "enter table name  ";tblnam$
        st0$="enter ":st1$=" col heads ":st2$="row  ":st3$=str$(k)
        maxfdw$="0 0 0":newfdw$=""
      while 1
            if k=0 then st$=st0$+st1$ else st$=st0$+st2$+st3$+" "
            input "";st$;s$
            if s$="" then exit while
            if k=0 then fn=wc(s$)
            newfdw$=fdw$(s$,fn)
            maxfdw$=mxfdw$(newfdw$,maxfdw$,fn)
            l$=l$+s$+";"
            k=k+1:st3$=str$(k) 'record number
      wend
         open "abc.dat"for append as #1
             print space$(20);upper$(tblnam$)
              #1,space$(20);upper$(tblnam$)
         close#1

       for i=1 to k
            if i=1 then hd=1 else hd=0
            n=tp(word$(l$,i,";"),maxfdw$,fn,hd)
      next
      function tp(fdn$,fdw$,fn,hd)
            l$="|"
          for i=1 to fn
                a$(i)=word$(fdn$,i)
                a(i)=int(val(word$(fdw$,i)))+5
          next
          for i=1 to fn
                if len(a$(i)) mod 2=0 then k=(a(i)-len(a$(i)))/2:t=0 else k=(a(i)-len(a$(i))-1)/2:t=1
                a$(i)=space$(k)+a$(i)+space$(k)+space$(t)
                l$=l$+a$(i)+"|"
          next
            tot=0
          for i=1 to fn
                tot=tot+int(val(word$(fdw$,i)))+5
          next
          for j=1 to (tot+fn+1)
                b$=b$+"-"
          next
            open "abc.dat" for append as#1
            if hd=1 then print #1,b$
            print l$
            print #1,l$
            print #1,b$
            close#1
            tp=0
      end function
      function wc(l$)
          while word$(l$,k+1)<>""
                k=k+1
          wend
            wc=k
      end function
      function fdw$(l$,fno)
          for i=1 to fno
                t=len(word$(l$,i))
                t$=t$+str$(t)+chr$(32)
          next
            fdw$=trim$(t$)
      end function
      function mxfdw$(fdw1$,fdw2$,fno)
            t$=""
          for i=1 to fno
              if val(word$(fdw1$,i))>val(word$(fdw2$,i)) then
                    t$=t$+word$(fdw1$,i)+chr$(32)
              else
                    t$=t$+word$(fdw2$,i)+chr$(32)
              end if
          next
            mxfdw$=trim$(t$)
      end function

 

* above code generates a file abc.dat in JB folder
* don't forget to keep Courier font or font name containing mono
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls