Where have I gone wrong

General FreeBASIC programming questions.
jj2007
Posts: 1229
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Where have I gone wrong

Postby jj2007 » Sep 29, 2018 14:57

Gablea wrote:Is it is tab spaced does that mean if a field has a comer in it it would not crash the system when it read it in?
Definitely no problem. Tab alias Chr(9) is the only delimiter, much easier and safer than that "crappy, old", "csv" format.
Gablea
Posts: 1049
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Re: Where have I gone wrong

Postby Gablea » Sep 29, 2018 15:11

Thsts good and From what a reading I should be able to save it back to the databse in a format the tills can would work.

I think I may go with this for my data files :)

Just have to work out how to stop the tills from reading the file if I’m updating it on the back office
Gablea
Posts: 1049
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Re: Where have I gone wrong

Postby Gablea » Sep 29, 2018 20:03

@jj2007

Just wanted to make sure this will work on a DOS machine (as I am sure i seen I need to include a Windows.bi file)

I keep getting network error when I try to download the GuiTableControl.zip

Do i need to see that to create the database files? (i am now trying to integrate your code into the KPoS application)
jj2007
Posts: 1229
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Where have I gone wrong

Postby jj2007 » Sep 29, 2018 20:49

Try this link. When right-clicking into the spreadsheet, the last option is "Save database".
Gablea
Posts: 1049
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Re: Where have I gone wrong

Postby Gablea » Sep 29, 2018 21:04

I would try that link but my antivirus keep marking your downloads as viruses
paul doe
Posts: 922
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Where have I gone wrong

Postby paul doe » Sep 29, 2018 21:24

Gablea wrote:I would try that link but my antivirus keep marking your downloads as viruses

Try to run it into a privileged folder (marked on your antivirus as 'excluded'); the one where you run your FB code will do.
Last edited by paul doe on Sep 29, 2018 22:56, edited 1 time in total.
jj2007
Posts: 1229
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Where have I gone wrong

Postby jj2007 » Sep 29, 2018 22:04

Gablea wrote:I would try that link but my antivirus keep marking your downloads as viruses
Try Paul's advice to exclude a specified folder. Sorry for that, it is a frequent problem with exes that do not follow common C/C++ coding patterns. Assembly is powerful but often a little bit different, and some AV are not able to understand that. What I upload is freshly built and absolutely clean.
badidea
Posts: 1542
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Where have I gone wrong

Postby badidea » Sep 29, 2018 22:33

Virustotal.com: Judged clean by most scanners, some exceptions (at top):

Code: Select all

ALYac
Gen:Variant.Razy.309337

Arcabit
Trojan.Razy.D4B859

BitDefender
Gen:Variant.Razy.309337

Emsisoft
Gen:Variant.Razy.309337 (B)

eScan
Gen:Variant.Razy.309337

F-Secure
Gen:Variant.Razy.309337

GData
Gen:Variant.Razy.309337

MAX
malware (ai score=83)

McAfee-GW-Edition
BehavesLike.Stymic.lc

Ad-Aware
Clean

AegisLab
Clean

AhnLab-V3
Clean

Alibaba
Clean

Antiy-AVL
Clean

Avast
Clean

Avast Mobile Security
Clean

AVG
Clean

Avira
Clean

AVware
Clean

Babable
Clean

Baidu
Clean

Bkav
Clean

CAT-QuickHeal
Clean

ClamAV
Clean

CMC
Clean

Comodo
Clean

Cylance
Clean

Cyren
Clean

DrWeb
Clean

ESET-NOD32
Clean

F-Prot
Clean

Fortinet
Clean

Ikarus
Clean

Jiangmin
Clean

K7AntiVirus
Clean

K7GW
Clean

Kaspersky
Clean

Kingsoft
Clean

Malwarebytes
Clean

McAfee
Clean

Microsoft
Clean

NANO-Antivirus
Clean

Panda
Clean

Qihoo-360
Clean

Rising
Clean

Sophos AV
Clean

Sophos ML
Clean

SUPERAntiSpyware
Clean

Symantec
Clean

TACHYON
Clean

Tencent
Clean

TheHacker
Clean

TrendMicro
Clean

TrendMicro-HouseCall
Clean

VBA32
Clean

VIPRE
Clean

ViRobot
Clean

Yandex
Clean

Zillya
Clean

ZoneAlarm
Clean

Zoner
Clean

CrowdStrike Falcon
Unable to process file type

Cybereason
Unable to process file type

eGambit
Unable to process file type

Endgame
Unable to process file type

Palo Alto Networks
Unable to process file type

SentinelOne
Unable to process file type

Symantec Mobile Insight
Unable to process file type

Trustlook
Unable to process file type

Webroot
Unable to process file type

I was not afraid to download, the chance that jj2007 makes a virus for linux is low :-)
I hope you don't mind that VirusTotal.com now has a copy of your file.
jj2007
Posts: 1229
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Where have I gone wrong

Postby jj2007 » Sep 30, 2018 0:52

badidea wrote:Virustotal.com: Judged clean by most scanners, some exceptions (at top):
...
I was not afraid to download, the chance that jj2007 makes a virus for linux is low :-)
I hope you don't mind that VirusTotal.com now has a copy of your file.
No problem, lol

As long as the "real" ones like Symantec, Kaspersky, McAfee, Malwarebytes give me a green light, it's ok. We even have a dedicated sub-forum called "AV Software sh*t list". Many programmers say "give your exe a proper manifest, and the AV will keep quiet". That's a great idea, if I was a virus writer, I would give my malware a proper manifest, simple, isn't it? But I digress...

@Gablea: I uploaded a new version here, unzip both files to a folder and drag the Products.tab over GuiTableControl.exe

Try Ctrl F, just for fun. The new version fixes a bug in the translation from csv to tab. Gablea has records like ...

Code: Select all

5025301439101,"BENROSS 9"FAN",0004,0,-,S,1599,A,0,-,0,-,0,0,0,-,0,-,0,0,0,0
... that contain quotes, e.g. the 9"FAN. Single quotes, that is... and AFAIK the norm says double or triple quotes are needed. This is why I call the csv format an awful mess. Here is one line from an official United Nations database:

Code: Select all

"1569","WB Staff estimates. Cambodia Poverty Assessment 2013 "Where Have All The Poor Gone?",  May 2013. Cambodia Socio-Economic Survey 2009.","Next_column_JJ"
I added the "Next_column_JJ" for testing. Can you imagine what the poor parser has to decide when it hits the Gone?", May 2013 part? M$ Excel fails miserably, my parser treats it nicely so far. Stay away from csv if you can!
Gablea
Posts: 1049
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Re: Where have I gone wrong

Postby Gablea » Oct 09, 2018 20:36

hi All,

I hope you are all well

I have been trying for the last few days to work out how I can add jj2007 code but I can not get my brain to work

What would I put into a global file (accessed by any part of the program) I would assume the function int would be a global one

Is there any that is given JUST for a given data file? I have not done much work on the Linux version as I have been busy working on the Windows version of the PoS application (mainly because I have customer running it)

jj2007 if you could guide me how to integrate this into the PoS app i would be most grateful
paul doe
Posts: 922
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Where have I gone wrong

Postby paul doe » Oct 09, 2018 22:56

Gablea wrote:...
I'm still trying to work out how I could make a universal function that would work will all the data files that my systems uses they are listed below
...

To do this you need classes, not functions. How much do you know about object-oriented programming? It is possible to do this, but it's fairly advanced stuff. You can't simply have 'a function to rule them all', simply because the data structure for each file is different. So, reading and writing them is bound to change, but you can encapsulate this and use another class to perform transparent loading/saving of files through a common interface.
jj2007
Posts: 1229
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Where have I gone wrong

Postby jj2007 » Oct 09, 2018 23:27

Gablea wrote:jj2007 if you could guide me how to integrate this into the PoS app i would be most grateful
Show me what you have so far, tomorrow I may have some spare time.
grindstone
Posts: 647
Joined: May 05, 2015 5:35
Location: Germany

Re: Where have I gone wrong

Postby grindstone » Oct 10, 2018 9:33

jj2007 wrote:
Gablea wrote:Is it is tab spaced does that mean if a field has a comer in it it would not crash the system when it read it in?
Definitely no problem. Tab alias Chr(9) is the only delimiter, much easier and safer than that "crappy, old", "csv" format.
I fully agree. In addition to it it's much easier to handle. You only need 2 simple SUBs to read and save any of the data files. Element (0) of the array holds the field names, while the others contain the records as an array of strings. And it even tolerates the faults in jj2007's "Products.tab" file (yes, there are some :-) ).

Code: Select all

Type tRecord
   As String fieldContent(Any)
End Type

ReDim As tRecord products(0)

Sub loadDataFile(fileName As String, array() As tRecord)
   Dim As String g
   Dim As Integer x, y, b, e, count, ff
      
   ReDim array(0)
   
   ff = FreeFile   
   Open fileName For Input As #ff
   Line Input #ff, g 'get field name string
      
   'get number of fields
   For x = 0 To Len(g) - 1
      If g[x] = 9 Then
         count += 1
      EndIf
   Next
   
   With array(0) 'array(0) holds the field names
      ReDim .fieldContent(count) 'redim field name array
      'parse field names string to fieldContent of array(0)
      x = 0
      For e = 0 To Len(g) - 1
         If g[e] = 9 Then
            .fieldContent(x) = Mid(g, b + 1, e - b)
            b = e + 1
            x += 1
         EndIf
      Next
      .fieldContent(x) = Mid(g, b + 1) 'get last field name (terminated by CR/LF)
   End With
      
   count = 1
   Do Until Eof(ff)
      ReDim Preserve array(count)
      With array(count)
         ReDim .fieldContent(LBound(array(0).fieldContent) To UBound(array(0).fieldContent))
         Line Input #ff, g 'get record
         
         'parse record to field content array
         x = 0
         b = 0
         For e = 0 To Len(g) - 1
            If g[e] = 9 Then
               .fieldContent(x) = Mid(g, b + 1, e - b)
               '? array(0).fieldContent(x);" ";.fieldContent(x);Tab(50);b;" ";e;" ";Len(g)
               b = e + 1
               x += 1
            EndIf
         Next
         .fieldContent(x) = Mid(g, b + 1) 'get last field content
         '? array(0).fieldContent(x);" ";.fieldContent(x);Tab(50);b;" ";e;" ";Len(g)
         count += 1
      End With
      '?
      'Sleep
   Loop
   Close ff
   
End Sub

Sub saveDataFile(fileName As String, array() As tRecord)
   Dim As Integer ff, x, y
   
   ff = FreeFile
   Open fileName For Output As #ff
   For x = LBound(array) To UBound(array)
      With array(x)
         For y = LBound(.fieldContent) To UBound(.fieldContent) - 1
            Print #ff, .fieldContent(y);Chr(9);
            'Print array(0).fieldContent(y);" ";.fieldContent(y);"*"
         Next
         Print #ff, .fieldContent(UBound(.fieldContent))
         'Print array(0).fieldContent(UBound(.fieldContent));" ";.fieldContent(UBound(.fieldContent));"*"
      End With
      '?
      'Sleep
   Next
   Close ff
End Sub


loadDataFile(ExePath + "\KPoS\TableControlV2\Products.tab", products())
saveDataFile(ExePath + "\KPoS\TableControlV2\Products2.tab", products())

'printout array
For y As Integer = 1 To UBound(products)
   With products(y)
      For x As Integer = LBound(products(0).fieldContent) To UBound(products(0).fieldContent)
         ? x;" ";products(0).fieldContent(x);Tab(35); .fieldContent(x)
      Next
   End With
   ?
   Sleep
   
Next

? UBound(products)
?"OK"

Sleep
End
Gablea
Posts: 1049
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Re: Where have I gone wrong

Postby Gablea » Oct 10, 2018 16:02

@Grindstone

Thanks for the code I shall have a read and test and let you know how it performs

@Paul Doe
I do not know much about oop as I’m use to using Visual Basic and even in that I access the database of MySQL directly. FreeBASIC is a lot to learn
Gablea
Posts: 1049
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Re: Where have I gone wrong

Postby Gablea » Oct 12, 2018 18:53

jj2007 wrote:
Gablea wrote:jj2007 if you could guide me how to integrate this into the PoS app i would be most grateful
Show me what you have so far, tomorrow I may have some spare time.



hi jj2007 to be honest i do not have anything to show you i have changed some of my code that handles csv but that is it I have not a clue how I would even start to integrated your tab to Data file coding

I can send you the KPoS code (uses the same database functions as my other apps but is not as developed for use with the PoS hardware so it is not as dependent on the hardware to be present)

I just hope I can at some point get my head around this. I understand your code (as it just want I am looking for to convert tab data files into records that the PoS can use and store in memory or on the hard drive (in memory would be good as most of the PoS terminals have 512MB RAM and at least a 600MHz CPU)

Its just understanding that transition from CSV format to your format (and your format is a much better format anyway more forgiving then what csv is)

the dream for my software is to DUMP The Windows Operating system from the Front end machines (PoS terminals) fully and use a true linux system on the front of the stores (still need to work out how I can talk to a IP/TCP Socket device from FreeBASIC)

Return to “General”

Who is online

Users browsing this forum: No registered users and 29 guests