to list file in directory adding View and Download icons

Code tips and tricks for beginners
Post Reply
MarioL
Posts: 30
Joined: Sun Mar 21, 2021 8:38 am
Has thanked: 327 times
Been thanked: 42 times

to list file in directory adding View and Download icons

Post by MarioL »

It's example code that I use to list and manage the files recorded by the rain gauge.
Click on Sheet font to display the text in a new browser tab.
Click on Floppy font to open the "save as" window.



Condivido un esempio di codice che uso per elencare e gestire i file registati dal pluviometro.
Il carattere Foglio è un link che visualizza il testo in una nuova scheda del browser.
Il carattere Floppy è un link apre la finestra salva file con nome.

Code: [Local Link Removed for Guests]

' *************************************************************************************
' *****                                 File Info                                 *****
' *************************************************************************************
'    Filename: /TestFileList.anx
'    Date    : 08/01/2024
'    Version : _
'    Edit. by: MarioL.
'    Function: example to list file in directory adding View and Download icons
'    Firmware: ANNEX WiFi 1.48
'    Hardware: ESP8266-12
'    Doc.Ref.: Annex WiFi RDS Help Version 1.40,
'    Note    : S.O.: WIN10 home, browser: FIREFOX 124.0.1 (64 bit)
' ***************************************************************************************


'create files in /LOG/ directory
FILE.APPEND "/LOG/RECORD_01.TXT", "this is file record n.1"
FILE.APPEND "/LOG/RECORD_02.TXT", "this is file record n.2"
FILE.APPEND "/LOG/RECORD_03.TXT", "this is file record n.3"
FILE.APPEND "/LOG/RECORD_04.TXT", "this is file record n.4"


myIP$ = WORD$(IP$,1)   'return local IP address Module



'CREATE FILE LIST WITH WIEV AND DOWNLOAD ICONS

cls    'Clear the html content of the page

A$ =  ||
D$ = FILE.DIR$("/LOG/") ' Will search for files and return the names of entries found. "/LOG/" is directory name

While D$ <> ""
    A$ = A$ + D$  'add nomefile
    A$ = A$ + | <a href="http://| + myIP$ + D$ +|" target="_blank">&#128195</a>| ' add character fold (view link)
    A$ = A$ + | <a href="http://| + myIP$ + D$ +|" download>&#128190 </a><br>|   'add character floppy (download link)
  D$ = FILE.DIR$
Wend

html A$ : A$ = "" 'more free RAM

end


You do not have the required permissions to view the files attached to this post.
Post Reply