Writing to a spreadsheet in Game maker studio 2.0 - gml

I'm making a short game for one of my classes, its for a small research study, so i want to be able to write the participants game data to a new line in a spreadsheet. I've seen stuff on reading from a .csv file but nothing about writing to it and was wondering what i need to do for that.

CSV, as per the name, is a very simple format - items go one per line and are separated by commas. If the item contains a comma or is multi-line, it should be surrounded by double-quotes ". If the item also needs to contain double quotes, they are replaced by pairs of double quotes "".
name,value
ex1,hello
ex2,"hello, you!"
ex3,"hello, ""quotes""!"
ex4,"hello,
lines!"
Rest assured, this is not hard to produce with file_text_* or buffer functions. You can check this implementation for an example.

Related

LabVIEW Inserting/overwriting text into existing string

I was wondering if folks have found a reliable way to inject text into an existing string. Some context, I'm writing data to a string indicator formatted like a table, and I wanted to inject values into so they maintain a specific format, spacing-wise. Writing to a table would definitely be easier, however I am porting a legacy program and wanted to provide familiarity to the end user.
Essentially, I want to do the equivalent of typing into a .txt file with the INSERT function enabled, where it just overwrites the content already in the string. Example below (dashes added to show spacing) of how it is currently looking when I inject the values with hard coded spacing:
Time---value---avg. value---result
60------10---------20---------PASS
120------11---------20---------PASS
180------9---------15---------FAIL
I'd prefer it to look more lined up, like below:
Time---value---avg. value---result
60------10---------20---------PASS
120-----11---------20---------PASS
180-----9--------- 15---------FAIL
Writing my application using LabVIEW 2019
Edit: Header will obviously not change, only each subsequent line where the values can result in entries not looking lined up
What about "Replace Substring" function (https://zone.ni.com/reference/en-XX/help/371361R-01/glang/replace_substring/)? Doesn't it meet your requirements?
The diagram below outputs 01234999990123PASS890123456789. The values of the integer and the word PASS are added replacing characters in the existing string, exactly like overstrike would do.

How to determine Thousands Separator using Format in VBA

I would like to determine the Thousand Separator used while running a VBA Code on a target machine without resolving to calling system built-in functions such as (Separator = Application.ThousandsSeparator).
I am using the following simple code using 'Format':
ThousandSeparator = Mid(Format(1000, "#,#"), 2, 1)
The above seems to work fine, and would like to confirm if this is a safe method of doing it without resorting to system calls.
I would expect the result to be a single char string in the form of , or . or ' or a Space as applicable to the locale on the machine.
Please note that I want to only use a language statement such as Format or similar (no sys calls). Also this relates to Thousands Separator not Decimal Separator. This article Using VBA to detect which decimal sign the computer is using does not help or answer my question. Thanks
Thanks in advance.
The strict answer to whether it is safe to use Format to get the thousands separator is No.
E.g. on Windows, it is possible to enter up to three characters into the Thousands Separator field in the regional settings in the control panel.
Suppose you enter asd and click OK.
If you now call Format(1000, "#,#") it will give you 1a000. That is only the first letter of your thousands separator. You have failed to retrieve it correctly.
Reading the registry:
? CreateObject("WScript.Shell").RegRead("HKCU\Control Panel\International\sThousand")
you get back asd in full.
To be fair, the Excel international properties do not seem to be of much help either. Application.International(xlThousandsSeparator) in this situation will return the separator originally defined in your computer's locale, not the value you've overridden it to.
Having that said, the practical answer is Yes, because it would appear (and if you happen to know for sure, please post an answer here) that there is no culture with multi-char thousand separator (even in China where scary things like 1ε„„2345δΈ‡6789 or 1ε„„2345萬6789 exist, they happen to be represented with just one UTF-16 character), and you probably are happy to ignore the people who decided to play with their locale settings in that fashion.

Replacing first and last character of every word using REGEXP_REPLACE

My question is somewhat specific, I'm not using any kind of code compiler to achieve the result in the title, I am using a IRC Client that allows the use of "Quirks" so the users can have specific mannerisms when chatting, like starting every word with an uppercase, or changing every "s" into a "2".
Problem is that I can't see the whole code so even though I'm not familiar with REGEXP_REPLACE it makes things harder to learn.
The client simplifies the whole coding process, here's a screenshot of the
interface
Filling the text boxes with "^(\w)" and "upper(\1)" respectively makes the first character capitalized, "(\w)$" and "upper(\1)" does the same with the last character.
I've discovered that "\b(\w)" will uppercase the first character of every word, i've tried "\b(\w)%" for the last character but it didn't work, as there is some syntax error, probably...
So, how do I get every last character capitalized?
1:

CHCSVParsing an unusual csv file

I'm having difficulties as to how I should parse this kind of csv file.
For example:
06:16 PM,7,299,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0026_heavy_rain_showers_night.png,Moderate rain at times,14,22,180,S,3.1,81,10,993,75
2014-01-31,9,48,3,38,22,35,176,S,119,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0003_white_cloud.png,Cloudy,6.0
2014-02-01,7,45,3,37,19,30,220,SW,113,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0001_sunny.png,Sunny,2.2
2014-02-02,9,47,3,37,17,27,236,SW,113,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0001_sunny.png,Sunny,0.0
2014-02-03,8,46,3,37,21,34,152,SSE,116,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0002_sunny_intervals.png,Partly Cloudy,1.8
2014-02-04,9,48,3,38,20,32,191,SSW,263,http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0009_light_rain_showers.png,Patchy light drizzle,1.4
"London","United Kingdom","City Of London, Greater London",51.517,-0.106,7421228,http://www.worldweatheronline.com/London-weather/City-of-London-Greater-London/GB.aspx
For example, I need to get the first two values on the first line, all the values on the 2nd to 6th line, and the first value of the 7th line.
I currently have a model class with properties for all the values I need to get.
I'm not sure how to do it in this situation. So far, I know how to parse that csv (if I didn't need to get the first two values on the 1st line, and the first value of the 7th line)
What would be the logic to parse in this situation? Hope you guys can give me some idea how to do it.
Thanks
Split the string into lines (busing a scanner or array method depending on how big the string is). Once you have your lines, takes the special ones and pass to appropriate methods to extract the required values. Likewise for the main lines.
You can use your parser on each line individually or use a scanner or array method if that's easier depending on what content you need to extract and where it is.

How to change sentence construction using Word VBA?

I have over a hundred text files and I need to change the construction of several sentences using a specific format. I am not very familiar or experienced with Word VBA but I hope I could get some ideas to help me get started. I have below the original paragraph and its desired output. Basically I need to place the values (e.g. 40-120 parts) after each item (e.g. isoleucine) and enclose those with "(" and ")".
Original: An acid combination for increasing immunity, comprising the following raw materials by weight: 40-120 parts of isoleucine, 45-135 parts of leucine, 76.5-229.5 parts of lysine hydrochloride, 21.5-64.5 parts of methionine, 35-105 parts of phenylalanine, 40-120 parts of valine, 30-90 parts of threonine, 39-117 parts of arginine, 23-69 parts of histidine, 37.5-112.5 parts of glycine, 50-150 parts of aspartate, 900-2700 parts of dried mushroom, 750-2250 parts of medlar and 250-750 parts of licorice.
Desired Output: An acid combination for increasing immunity comprises (pts.wt.): isoleucine (40-120), leucine (45-135), lysine hydrochloride (76.5-229.5), methionine (21.5-64.5), phenylalanine (35-105), valine (40-120), threonine (30-90), arginine (39-117), histidine (23-69), glycine (37.5-112.5), aspartate (50-150), dried mushroom (900-2700), medlar (750-2250) and licorice (250-750).
Maybe you could try the following sequence :
Find the part you want to change (numbers seperated by - and parts) with the Find function (another link) and a well-formed regexp (meant wildcards for Word)
Set the brackets at the beginning and at the end of the matched element (use the range object)
Delete the last word ("part") - or whatever you want to do
Loop through every results to do the same (see an example of looping through find function here)
Don't forget you can record macro if you are looking for some tips or specific objects (even if the code produced is less complete than the one produced by Excel vba).
Please don't hesitate to post some code if you want some more help,
Regards,
Max