Results 1 to 4 of 4

Thread: File_Load driving me mad but it shouldn't

  1. #1
    Junior Member
    Join Date
    Nov 2014
    Posts
    4
    Rep Power
    0

    Question File_Load driving me mad but it shouldn't

    Greetings,
    I'm using the following script which creates 2 files (HTML and TXT) in my desktop folder which works fine. My problem is with the File_Load. It returns gibberish (for me, it always returns ˙ūC).

    =====================================================
    ' Create file containing list of Windows Hotfixes
    ' using the Windows Management Instrumentation Command (WMIC)
    ' command. This can produce and HTML file (cmdh) or a TXT file
    ' (cmdt).

    Uses "OS", "File"

    String buffer
    String wm = "wmic qfe list full "
    String Desktop = OS_GetSpecialFolder(%CSIDL_DESKTOP)
    String h1 = "/format:htable > "
    String h2 = Desktop & "hotfix.html"

    String t1 = "/format:texttablewsys > "
    String t2 = Desktop & "hotfix.txt"

    String cmdh = wm & h1 & $DQ & h2 & $DQ
    String cmdt = wm & t1 & $DQ & t2 & $DQ
    String lap = OS_GetSpecialFolder(%CSIDL_LOCAL_APPDATA)

    RunCommand(cmdh)
    RunCommand(cmdt)

    buffer = FILE_Load(t2)
    ClipBoard_SetText(buffer)
    MsgBox(0,buffer)
    MsgBox(0,t2)

    Function RunCommand( sCommand As String )
    String tempBat = lap + "TEMP\temp.bat"
    FILE_Save(tempBat, sCommand)
    OS_Shell(tempBat, %OS_WNDSTYLE_HIDE, %OS_SHELL_SYNC)
    End Function
    =====================================================
    What the heck am I doing wrong? The File_Load seems so straight-forward.

    Regards
    Last edited by Django; 23-11-2014 at 19:02.

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,153
    Rep Power
    736
    Hi Django,

    believe it or not, file_load works correctly in this case. The problem is the data display. The generated output is in Unicode, MsgBox expects ASCII.

    To handle this situation systematically, you can enhance your script with the following:
    buffer = FILE_Load(t2)
    If IsUnicode(buffer) Then
      buffer = Unicode2Ascii(buffer)
    End If
    
    Unicode strings are part of my proposals for ThinBASIC 2.x series, we already talked about it with Eros.


    Petr
    Last edited by Petr Schreiber; 23-11-2014 at 19:58.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    55
    Posts
    1,554
    Rep Power
    174
    just some small hint - i think it's still undocumented (except small mentioning under "What's new")
    regarding File_Load/File_Save:

    If both are the only functions you need of file-module (Uses "File") and if you use at least tB-version 1.9.11 then you can omit the file-module and just use

    String sData = Load_File(sFilename)
    'or
    If Save_File (sFilename, sData) Then
     ' successfully saved
    EndIf
    
    - which are to thinCore built in functions.

    It will reduce the final size of your code...
    Last edited by ReneMiner; 24-11-2014 at 12:33.
    I think there are missing some Forum-sections as beta-testing and support

  4. #4
    Junior Member
    Join Date
    Nov 2014
    Posts
    4
    Rep Power
    0
    Thank you Petr. I don't think I would have ever thought about something so obscure.

    Thanks Rene, I'm still on version 1.8.9.0 but I'll keep your suggestion in mind.

    Best regards.

Similar Threads

  1. Google self driving test
    By ErosOlmi in forum Technology
    Replies: 1
    Last Post: 31-03-2012, 14:40
  2. Nevada Gives Green Light to Self-Driving Cars
    By danbaron in forum Science
    Replies: 2
    Last Post: 26-06-2011, 05:39
  3. using file_load?
    By sandyrepope in forum thinBasic General
    Replies: 3
    Last Post: 18-07-2007, 07:15

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •