Problem using SaveStringToTextFile

Getting an error while trying to save text to a file. I have included a Gig File demonstrating this.

022624 Test Load and Save.gig (91.2 KB)

Press the SAVE_Button to save and then the Load_Button to load the text file.

Seems you have to full qualify the file name

Example:
“/Users/phil/Downloads/Phil.txt”

Instead of first uploading a gig file, why not just tell us what error you got and exactly what you were doing.

Yep, this is the way I tried it initially and got the error. Then I switched to let GP decide where it was going, but it still failed.

The Gig File demonstrates the problem better than I could explain it. I don’t want the discussion to get off track. The Rackspace contained in the Gig File is very simple and loads immediately. If you were to look at the script, you would see it is very straightforward. I don’t know if the problem is with my computer, my GP Script coding error, or a bug in GP Script 4.8.2 etc. I am also interested to see if other GP users will experience this problem.

You’ll have to provide a full path for the text file’s destination! Also you’ll have to use a “/” instead of " \ ".
When i used the path “c:/Phil.txt” everything worked well!

1 Like

That was my problem! I was using "" instead of “/”. In Windows, you would use the back-slash. So, since I use Windows, I went for the back_slash. :eyes:

1 Like

That may be but it presumes that people are standing by at their computer to immediately load and explore a foreign gig file.

Please try to make it as easy as possible for the rest of us rather than just complaining you have an error without even bothering to tell us what the error actually was. If the error is in a script, then post the script, or at least the section of the script where the error is occurring.

Thank you for your understanding.

3 Likes

I can do that in the future if you wish :slight_smile:

We all wish :wink:

1 Like

Yes please. I still want to know what the error message was!

I didn’t get an error msg per se. The boolean came back false which told me the write was unsuccessful. As Erik pointed out, it was because I used backslashes instead of front slashes in the file name.

The documentation is unclear on this point.

I would think you would spend your time wishing for something more meaningful. :sweat_smile:

Well, you got an error result! Posting the line of code that returned that error result would have shown the issue immediately

Nope. Don’t confuse the requirement for a back-slash in the user interface usage (which was necessary because some idiot decided to use the forward slash for command parameters and then when directories were added to DOS they were stuck) and writing in a programming language where the path separator can be anything the language designer chooses.

In fact, you can’t actually use a backslash as a path separator if you’re writing in C or C++ because the backslash actually means something else . So you have to use two backslashes.

When you write code for Windows and need to refer to file paths you can absolutely use the forward slash when working with the Windows APIs.

The he command line prompt windows lets you use the forward slash.

screenshot_8109

Yes, it’s true that the language manual has little to say about files, mainly because file handling was never really an important aspect of Gig Performer. That said, if you search for “path” in the language manual, there is an example so I suppose that’s better than nothing :slight_smile:

screenshot_8111

OK, that’s new to me. Good to know. That’ 's why you get paid the big bucks. :slight_smile: