Add hours a the file

Hello friends, I wanted to ask you if it is possible to add date and time to a file generated in appinventor. I add a label with hour and date in my app but when I add it to the file it gives me an error when trying to generate this file, I imagine that it is because it is not a text string.

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

1 Like

Yeah, you have to show your block as Taifun said, thank you

1 Like

app

Hello Marcelo

We need to see the error message!

If you are on Android 10/11, you need to save the file to the App Specific Directory.

How often is the Clock1 Timer updating Label1? If it happens to be updating just as the file name is being assembled, that may be an issue.

1 Like

This is the error, but it only occurs when I add the date. If I remove the date from the name the file is saved perfectly.
Screenshot_20201111-232746~2

That error is from the code above? Surely just using call Clock1 Now would result in Label1 getting all of the date-time data, a huge string.

In any event, I think the value separator ":" (colon) might not be allowed in a filename?

1 Like

Good, thanks chris. I will check later if that can be one of the causes of the error. But now that you mention it I think the date spaces are probably causing this error.

you have to eliminate / and : from the date
files/11_11_2020_11_27_38_p.m..txt

1 Like

You get an error using a slash: "/".
".", ":", " " (space), "_", "-" are possible.

1 Like

Which apparently you do not get if the date is removed from the file name:

There are issues born out of uncoordinated changes to Android by Google. App Inventor needs all of it's file handling overhauled and simplified - no doubt the introduction of iOS will make this necessary anyway.

Edit: I see what you mean Anke - you cannot use a slash as a value delimiter in the file name, which I hope would be obvious given that it signifies the next directory in many OS. However, perhaps this is what is wrong in Marcelo's actual code, as apposed to the could-not-possibly-work code that he posted. :grin:

Thank you all very much, yes, the error was in the "spaces" and the "/" :man_facepalming:.

Greetings to all

No, as I've shown (only "/"):

grafik

1 Like

There is a difference though between what can be done and what should be done. If the files are to be transferred out of the Android ecosystem, the syntax has to be compatible with other operating systems and other programs, so avoiding unnecessary punctuation and special characters in files names is best practice.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.