Read/Write to OneDrive with Small Basic

Trevor_S 21 Reputation points
2021-10-31T17:33:59.86+00:00

Can Small-Basic read/write to cloud storage (e.g. OneDrive), without needing to sync it locally? I'm looking to hold a "high score" for a game, which can be compared to the current score. These lines, which are to a local sync for OneDrive, work:

HighScore = File.ReadLine("C:\Users\trevo\OneDrive\Folder\HighScore.txt",1)
If score > HighScore Then
GraphicsWindow.ShowMessage( "Game Over. You have beaten the current high score: " + HighScore + ".", "Title" )
File.WriteLine("C:\Users\trevo\OneDrive\Folder\HighScore.txt",1,score)
Else
GraphicsWindow.ShowMessage( "Game Over.", "Title" )
EndIf

When replacing the filepath/name with the OneDrive edit link (a URL starting "https://1drv.ms/") the program still runs but nothing is read / written, making every game a new high score!

Small BASIC
Small BASIC
A programming language created by Microsoft that serves a stepping stone for beginners from block-based coding languages to more complex text-based languages.
280 questions
0 comments No comments
{count} votes

Accepted answer
  1. JR 126 Reputation points
    2021-12-23T00:06:13.643+00:00

    TrevorS-3701,

    If you want to go through the network the easiest way to do it would be to use the LitDev extension.
    There goto LDNetwork. Within that you will see that you can set a highscore and other players can do the same.

    JR


3 additional answers

Sort by: Most helpful
  1. LitDev 126 Reputation points
    2023-09-09T15:59:55.71+00:00

    A bit late, but following JR's suggestion, LDNetwork has been updated (version 1.2.25.0 - currently Beta).

    A couple of reasons:

    1] litdev.co.uk has reinstated to litdev.uk (where highscore is saved)

    2] SSL security (https) is now supported for network file transfer (see https://litdev.uk/mybb/forumdisplay.php?fid=3 for more details)

    1 person found this answer helpful.
    0 comments No comments

  2. JR 126 Reputation points
    2021-12-10T22:51:32.753+00:00

    TrevorS-3701,

    I changed your code a little just to see what it would do. It did write the file OK and it was able to read it. I'm thinking you might have something wrong for the address to one drive. Maybe, in the address you don't have a folder called folder.

    JR

    score=2

    HighScore = File.ReadLine("C:\Users\jrmrh\OneDrive\HighScore.txt",1)
    If score > HighScore Then
    GraphicsWindow.ShowMessage( "Game Over. You have beaten the current high score: " + HighScore + ".", "Title" )
    File.WriteLine("C:\Users\jrmrh\OneDrive\HighScore.txt",1,score)
    Else
    GraphicsWindow.ShowMessage( "Game Over.", "Title" )
    EndIf


  3. JR 126 Reputation points
    2021-12-23T18:40:54.127+00:00

    Here's a code snippet that works for a game called "madball"

    Result=LDNetwork.HighScore("Madball","TM",6)
    TextWindow.WriteLine(Result)

    You will have to have the extension loaded and working in small basic.

    JR

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.