ExportFile to a MAC

Just starting out? Need help? Post your questions and find answers here.
Ronster
Posts: 3
Joined: Wed Mar 01, 2017 6:12 pm

ExportFile to a MAC

Post by Ronster »

Hello All.
My first post ever on any forum and a newcomer to SpiderBasic.

I've written an app to generate a short MIDI file template which is then modified via a User interface. I used the 'Web' tab in the Compiler menu to create the app.

The modified data is held in an array (MDhd) and the following snippet, lifted from SB Help, writes the array contents to the 'Screen_Config.mid' file when triggered by a mouse click:

;Write array to file
Result = CreateFile(0,"Screen_Config.mid",#PB_UTF8)
For i = 1 To ArraySize(MDhd())
WriteByte(0,MDhd(i))
Next

;Export file And close
ExportFile(0,"audio/midi", #PB_LocalFile)
CloseFile(0)

On a PC the MIDI file downloads perfectly into the 'Downloads' folder - all is good.

However, on a MAC as soon as my ExportHandler procedure is triggered, the MAC just opens a new blank browser instance with no clues as to what happened to the MIDI file! This happens with both Fire Fox and Safari.

Am I right in thinking that as the code is embedded in the web page it should work across all platforms identically or does it need to be compiled differently to suit a browser running on a MAC?

I’ve assumed, rightly or wrongly, that the ‘iOS’ tab in the Compiler's ‘Create App’ menu only applies to iPads and iPhones similar to the Android option for Android tablets and phones.

Any help would be most gratefully received. I should add that I'm totally ignorant of the workings of a MAC (in case you hadn't already guessed!).

Thank you.
Cheers, Ron.
User avatar
SparrowhawkMMU
Posts: 291
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Re: ExportFile to a MAC

Post by SparrowhawkMMU »

Hi and welcome to the SB forum! :)

ExportFile is working for me on El Capitan. (I have Firefox set as my default browser)

Does the following work for you?

Code: Select all

Procedure ExportTheFile()
	
	If CreateFile(0, "SomeText.txt",#PB_UTF8)
		WriteStringN(0, "First line")
		WriteStringN(0, "Second line")
		
		ExportFile(0, "text/plain")
	EndIf
EndProcedure

OpenWindow(0, 100, 50, 140,100, "test")
ButtonGadget(0,40,30,60,20,"Export")
BindGadgetEvent(0, @ExportTheFile())
If that works, could it be that the wrong MIME type is being used in your code? Have you tried audio/x-midi ? I am not really an expert on audio formats, so please ignore if that would be incorrect.

Edited to say hello!
Ronster
Posts: 3
Joined: Wed Mar 01, 2017 6:12 pm

Re: ExportFile to a MAC

Post by Ronster »

Hi SparrowhawkMMU, thank you for your kind welcome and prompt reply.
I'll take up your suggestion and try a different MIME type (or use the x- 'not registered' prefix) with your code example.

I'll let you know how I get on but it may take some time as I need to blag access to a MAC....

Thanks again.
Regards, Ron.
Ronster
Posts: 3
Joined: Wed Mar 01, 2017 6:12 pm

Re: ExportFile to a MAC

Post by Ronster »

I'm much relieved to say that exporting to a MAC works fine.

I got my favourite beta tester (my daughter) to try it in Fire Fox instead of Safari and it worked straight away without changing the MIME type.

It's probably just a matter of tweaking the Safari settings but for now I'm happy!
User avatar
SparrowhawkMMU
Posts: 291
Joined: Wed Aug 19, 2015 3:02 pm
Location: United Kingdom

Re: ExportFile to a MAC

Post by SparrowhawkMMU »

Great news :)

Hope you enjoy SpiderBasic as much as I do. Truly wonderful toolset.
Post Reply