SyntaxBomb - Indie Coders

Languages & Coding => Blitz Code Archives => File Utilities => Topic started by: BlitzBot on June 29, 2017, 00:28:42

Title: [bb] SaveString - saves a string value as a file by Zethrax [ 1+ years ago ]
Post by: BlitzBot on June 29, 2017, 00:28:42
Title : SaveString - saves a string value as a file
Author : Zethrax
Posted : 1+ years ago

Description : Saves the specified string value as a file.

Can be used in combination with the 'GetInternetFile' function linked below to download and save a file.

GetInternetFile - downloads a file as a string
<a href="codearcsac1f.html?code=3069" target="_blank">http://www.blitzbasic.com/codearcs/codearcs.php?code=3069</a>


Code :
Code (blitzbasic) Select
Function SaveString( filepath$, stringval$ )
; Saves the 'stringval$' to the specified 'filepath$' as a file.
; Returns True on success or False if there was an error.

Local file, i, l = Len( stringval$ )
file = WriteFile( filepath$ )
If file = 0 Then Return False
For i = 1 To l
WriteByte file, Asc( Mid( stringval$, i, 1 ) )
Next
CloseFile file
Return True
End Function


Comments : none...