Gablea wrote:They was produced by my Visual Basic back office application.
What is the 01 char then?
An invalid character, neither tab nor zero nor anything usable. Which lines of the VB app produces it?
Once you have fixed that problem, you can use the
Recall(filename, stringarray) and
Cell(row, col, stringarray) functions posted below, using Recall.fbi: (simple example:
Print "The description of product #5: "; Cell(5, posdescription, Products()))
Code: Select all
' Recall.fbi, 14.10.2018, jj2007
#include "Windows.bi" ' needed for lstrcpyn
#ifndef maxCell
#Define maxCell 100 ' whatever you consider enough for a single cell
#endif
Dim shared retstr As string * maxCell+1
Function Recall(fname As String, locArray() As String) As Integer
Dim As Integer ct=0, cursize=100 ' locArray is a local representation of a dynamic array
If Open(fname For Input As #1) = 0 Then
Do While Not Eof(1)
if ct=0 or ct>cursize then
cursize+=cursize shr 1
ReDim Preserve locArray(cursize)
endif
Line Input #1, locArray(ct)
ct+=1
Loop
Close #1
ReDim Preserve locArray(ct)
Else
Print "Error opening file"
End If
Return ct
End Function
Function Cell(row As integer, col As integer, locArray() As String) As string
Dim As integer ct=0, ctTabs=0, posLeft=-1, posRight=0
Dim As ubyte ptr pString
Dim c As ubyte
pString=StrPtr(locArray(row))
if pString then
Do
c=pString[ct]
if pString[ct]=9 then
ctTabs=ctTabs+1
if col=0 then
posLeft=0
if ctTabs>col then posRight=ct+1
else
if posLeft=-1 and ctTabs>=col then
posLeft=ct+1
elseif ctTabs>col then
posRight=ct+1
endif
endif
endif
ct=ct+1
Loop Until c=0 or posRight
endif
if posRight=0 then
retstr[0]=0
else
lstrcpyn(StrPtr(retstr), pString+posLeft, Min(maxCell, posRight-posLeft))
endif
return retstr
end function
Usage:
Code: Select all
#include "..\Recall.fbi"
Enum product
BarcodeNumber, posdescription, salelocation, agerestricted, agelimit, pricetype, retailprice, vatcode,_
print_guarantee_message, print_guarantee_code, displaymessage, messagenumber, sendtoppr,_
requestserial, itemnotallowed, itemnotallowed_reason, restrict_product_qty, product_qty_allowed,_
discount_not_allowed, no_refund_allowed, ask_for_qty_before_selling, healthy_start_voucher_ok
End Enum
Dim shared Products() As string
Print "Arg1: ";Command$(1)
if Recall(Command$(1), Products()) then
Print "records loaded:";ubound(Products)
For i As Integer=0 To ubound(Products)-1 ' print the first and last Cells
If i<10 Or i>=ubound(Products)-5 Then
Print i,
For j As Integer=0 To 5
Print Cell(i, j, Products()),
Next
print
ElseIf i=10 Then
Print " ..."
EndIf
Next
Print "OK"
endif
Sleep