Arrowat: Facebook: Youtube: Twitter: Instagram: LinkedIn:

Creating and Reading files using JavaScript Studio

Posted date: 7/26/2015

By Melvin Dev

On this page

  • Create a Music Collection app
  • Create a file
  • Read a file

Javascript Studio allows you to create file and read files in two ways, One is open and closing tags like you do on HTML tags, and the other is on design mode.

NOTE: These are features, these are not a Javascript coding or part of Javascript development. and the code must be Commented with <!-- --> or //

We are going to start with and small app and we will called Music Collection.
There is no difference on JavaScript Studio for Windows Phone and JavaScript Studio for Windows.
If you have not downloaded javascript studio please go to Download JavaScript Studio Page

Creating files using Javascript Studio

  1. Open Javascript Studio Professional and Tap "Blank App" button it will open the editor page
    "I haven't developed any apps by now that's why the App section has nothing"


  2. Tap Save App to save your App.
    "Is recommended to save the app first before starting to code"


  3. Write a name "Music Collection" and then "Tap Save Now"


Now you have created the app and saved it, we will start coding, you can remove the navigation part from the code, by now we will remove it, then "Tap Save Changes".

  • image

We will by start creating a file uisng the feature "built in tag code" to create a file follow the following steps

  1. Tap inside of "article" tag
  2. Tap Snippet button
  3. Select JSS- CreateFile ('JSS' means Javascript Studio feature')
  4. Tap Add button to add the Create file code


If you are curious and you want to Run the app now you will get an error thrown by Javascript Studio because the file has not specified a name.

  • image

    Tap Back to code button.

Note that the 'JSS-Createfile' code must be commented as you see it. if not it will appear in the app when it is running.

If you close the app and go to the start page of Javascript Studio you will see the app saved, click the app again and it will be open running.

  • Save app


    Running App


Even if you close the app and you open it Running you will get the same error because we have not written the file name, Tap Edit App button.
Now we have tested the app and we have seen the error, let's start writing a file name and adding text.

  1. Tap inside of <Name> </Name> tag and write the file name "My Music" and inside of <Text> </Text> write the following then Tap Run button to Run the App and the file will be created.


    File was Created

    Tip: You can add formated HTML tags into the file and it will be depend how you will want to show it. as you will see in the next section"Reading File".

When we are creating a file Using JavaScript Studio you can have only one JSS-CreateFile tag, if you have more than one, the first tag will be evaluated and it will create the file, the rest will be ignored, if you want to create another file you can create it writing a different file name, if you write a file name that already exist it will be overwriting the content.
After you have created a file you can delete all script tag JSS-CreateFile

Reading files using Javascript Studio

You can read files the same way you create it. each file you create can be accessed from the same app only.
You have two ways to read a file, One is open and closing tags like you do on HTML tags, and the other is on design mode.
We will read the file that we created in the previous section. to read a file using JSS-ReadFile Follow the following steps.

  1. Open Music Collection App if you have closed it.
  2. Tap Inside of the <article> tag then Tap Snippet button
  3. Select JSS-ReadFile
  4. Tap Add Button



  5. Run the app. Tap Run button, you will get an error because there is no file name specified "the file we want to read"


  6. Tap Back to code button

  7. Try something, write an name you want inside of <Name> </Name> let's write a file name Movie tips


  8. Tap Run Button you will see the error that the file does not exist


  9. Tap Back to code
  10. Delete the JSS-ReadFile that we added

The easy way to read files is knowing the files that we have created. To see the files you have created in the app follow the following steps

  1. Tap File Button at the top on the left of the screen a File Dialog will appear



    From this File dialog you can perform Creating, Reading, Editing, Deleting Files.

  2. Select My Music File this is the file that we created at the beginning of this tutorial.
  3. Tap Add Reading Code button to add the JSS-ReadFile Code

  4. Tap Run Button to see the result and read the file My Music

    Note that you can place the <ShowFileContentHere/> tag in any part of the code, the content file that we are reading will be shown there.

Now you have learned how to Create and save apps, Create file, Read file. you can continue exploring Javascript Studio to see how this app can help you on the Go "Using your windowsphone or tablet".

Arrowat MSDN Bing Github Twitter Facebook Linkedin

© 2024 Melvin Dev™