Just starting out? Need help? Post your questions and find answers here.
T4r4ntul4
Posts: 132 Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands
Contact:
Post
by T4r4ntul4 » Fri Mar 17, 2017 9:43 am
How to use CreateFile() ?
It gives a compiler error: incorrect number of parameters
it needs a callback?
from the docs:
Code: Select all
If CreateFile(0, "Text.txt") ; we create a new text file
For a=1 To 10
WriteStringN(0, "Line "+Str(a)) ; we write 10 lines (each with 'end of line' character)
Next
For a=1 To 10
WriteString(0, "String"+Str(a)) ; and now we add 10 more strings on the same line (because there is no 'end of line' character)
Next
ExportFile(0, "text/plain")
CloseFile(0)
EndIf
falsam
Posts: 286 Joined: Mon May 05, 2014 9:49 pm
Location: France
Contact:
Post
by falsam » Fri Mar 17, 2017 10:39 am
Code: Select all
Procedure onCreate()
EndProcedure
If CreateFile(0, "SomeText.txt", @onCreate())
WriteStringN(0, "First line")
WriteStringN(0, "Second line")
ExportFile(0, "text/plain", #PB_LocalFile)
EndIf
This callback is very strange
➽ Windows 11 - jdk-11.0.2 - SB 3.00 - Android 15
➽ https://falsam.com
Sorry for my poor english
T4r4ntul4
Posts: 132 Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands
Contact:
Post
by T4r4ntul4 » Fri Mar 17, 2017 10:59 am
Where can this callback be for used, in createfile? Its empty and doesnt do much?
falsam
Posts: 286 Joined: Mon May 05, 2014 9:49 pm
Location: France
Contact:
Post
by falsam » Fri Mar 17, 2017 11:04 am
The function is
CreateFile(#File, FileName$, @Callback() , [Flags])
For me, this callback is useless. He is never called.
Code: Select all
Procedure onCreate()
Debug "Hello" ; No hello
EndProcedure
If CreateFile(0, "SomeText.txt", @onCreate())
WriteStringN(0, "First line")
WriteStringN(0, "Second line")
ExportFile(0, "text/plain", #PB_LocalFile)
EndIf
➽ Windows 11 - jdk-11.0.2 - SB 3.00 - Android 15
➽ https://falsam.com
Sorry for my poor english
T4r4ntul4
Posts: 132 Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands
Contact:
Post
by T4r4ntul4 » Fri Mar 17, 2017 11:09 am
i assume this is a bug then? callback is not necessary for this function?
Peter
Posts: 1197 Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:
Post
by Peter » Fri Mar 17, 2017 11:11 am
perhaps it's deprecated in further Versions, because it is not mentioned in the SB-Help?
Result = CreateFile(#File, Filename$ [, Flags])
only Fred knows...
T4r4ntul4
Posts: 132 Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands
Contact:
Post
by T4r4ntul4 » Fri Mar 17, 2017 11:16 am
yes i think so, in the IDE statusbar it still says it needs a callback, i think Fred forgot to edit it out in CreateFile() function
falsam
Posts: 286 Joined: Mon May 05, 2014 9:49 pm
Location: France
Contact:
Post
by falsam » Fri Mar 17, 2017 11:18 am
Peter wrote: perhaps it's deprecated in further Versions, because it is not mentioned in the SB-Help?
Yes but if you do not put a callback, there is a compilation error.
T4r4ntul4 wrote: callback is not necessary for this function?
If you do not put a callback, there is a compilation error.
Compiler wrote: Lines 4 CreateFile() : Incorrect number of parameters.
➽ Windows 11 - jdk-11.0.2 - SB 3.00 - Android 15
➽ https://falsam.com
Sorry for my poor english