Results 1 to 2 of 2

Thread: [Answers] Low level

  1. #1
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135

    [Answers] Low level

    FSEEK() is actually moving the pointer. If I do the following I get the expected results except that BOF() doesn't return True even before I move through the file.
    Using FGETS(<fd>,0,1) appears to correctly return the current position:
    Code:
    open database southwind
    use customers
    copy to xxx.txt type csv
    xxx=fopen("xxx.txt")
    ? xxx
    ? bof()
    ? fseek(xxx,0,1)
    ? fgets(xxx)
    ? fseek(xxx,0,1)
    ? fseek(xxx,0,0)
    ? fseek(xxx,0,1)


    The FEOF() flag only gets set/reset after a read operation. As Dave says, the fseek(FileHandle,0,0) is returning you to the start of the file, it's just that having been set, FEOF() won't be unset until you do another read operation. Try something like this:

    Code:
    FileHandle = FOPEN(Lianja.Get("Gamesheet.GSHeader.txtGamesheet").text)
    
    Do While .T.
      cGetline = fgets(FileHandle)
      If FEOF(FileHandle)
        exit
      else
        // process ...
      endif
    ENDDO
    
    fseek(FileHandle,0,0)  // Return to start of file
    
    Do While .T.
      cGetline = fgets(FileHandle)
      If FEOF(FileHandle)
        exit
      else
        // process ...
      endif
    ENDDO


    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352

    Last edited by josipradnik; 2016-12-13 at 02:57.

  2. #2
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    A need create a temporary file to use while the session is live and set a text field with this name to use macro on web client.
    The command file=Lianja.evaluate('tmpnam()') work on appbuilder, but not on webclient.
    In fact a need create a POS.
    So I am using catalogView to show items and I need create a grid with items to be saved on table.
    But gadget grid dont work on web.
    A:
    Use a regular grid section, and make the header and/or footer invisible, and you can make it look all like one section, etc.
    For storage: think JSON, and use SessionStorage



    All topics in [Answers] alphabetically: http://www.lianja.com/community/show...p?2717-Answers

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us