This is indeed a good method. (I was thinking of it too, btw.) It works well, but if the code is left as is, it will break non-ASCII characters, like symbols and japanese characters, since you only read the last 8 bits of the characters that are actually UTF-16. This can also be easily modified to be able to convert DAT and GRP files (considering to use 32 bits, or 64 with reals) into this bitmap to also import on a PC. I'll be using this now, actually. (SBAPI exists still but spamming it with my projects is not a good idea.)
acls dim bindata% var filedata$ = loadv("txt:myfile") var i%, j% for i% = 0 to len(filedata$) - 1 for j% = 7 to 0 step -1 push bindata%, (asc(filedata$[i%]) >> j%) and 1 next nextIn our outer loop, we are just looping through all characters in the file. The "asc" turns the character into its numerical ASCII equivalent. This is an 8-bit value, so we do another loop from 7 to 0 where the break that bit-value into its individual bits. The "and 1" simply removes all data from the byte except for the final, least-significant bit. If we use ">>" beforehand, a right-shift, then we can combine the two to select particular bits from the byte, and thus break the byte up into its individual bits. Once we have done this, we want to draw an image to the screen. This image will simply contain all of our bits as either black or white pixels. In order to fit the maximum amount of data into the screen, we will want to use "xscreen" to resize the screen to 1280 by 720. This will allow us to fit 1 bit per pixel, and thus 1280x720 bits, and thus (1280x720)/8 bytes in the screen, or = 115,200 bytes of data. Once we've setup the screen and loaded our bit-data, we will need to plot it. Simply loop through all the bit-data and keep track of your X and Y coordinates. Every time you plot a pixel, increment the X coordinate. If the X coordinate goes off the right-side of the screen, then reset it to 0 and increment the Y coordinate.
xscreen 1280, 720 var i% var x% = 0 var y% = 0 for i% = 0 to len(bindata%) - 1 if bindata%[i%] then gcolor rgb(255, 255, 255) else gcolor rgb(0, 0, 0) endif gpset x%, y% inc x% if x% >= 1280 then x% = 0 inc y% endif nextIf the program ends, then it will say "OK" on the screen and show the flashing cursor which will conflict with the data we just created, so you will want to have the program pause after this. I just use these lines below to have it pause until you press enter/return on the keyboard.
while !keyboard(40):wend while keyboard(40):wend aclsWe converted our program to an image, but how does that help get it to your smartphone? Very simple: take a screenshot. Press the screenshot button then the home button and go to your Album and click the screenshot you just took, press A again and there should be an option "Send to Smartphone". This allows you to transfer the image or a bunch of images over your Wifi from your Switch to your smartphone. Once you've sent your screenshot to the smartphone, go to this URL in your phone's browser: https://jsfiddle.net/t7s91Leg/show There is a file upload button. Just click upload and select your image and it will convert it back into the program text! Since you can transfer 115 kilobytes in a single image, you can probably transfer your entire program in one image. If your program is somehow larger than this, you may need to break it apart into multiple images. To transfer back to the Switch, the easiest way I know of is to use PetitModem on the 3DS and then upload it with a public key, and then you can download it to the Switch using the public key. So the transfer uses the 3DS as a middle-man.