how to suggest a name to save

1 回表示 (過去 30 日間)
Luca Re
Luca Re 2023 年 11 月 25 日
編集済み: Luca Re 2023 年 11 月 25 日
function SaveAsButtonPushed(app, event)
sav=Carico_i_nomiFile_e_Dati_Folder_Struct(6);
if ~isempty(sav)
sav=strcat(sav,'.ttslist2'); %%per ora stabilisco che la lista abbia questa estensione!
app.CurrentOpenList=sav;
app.CurrentopenfilelistTextArea.Value=sav;
app.MyTable(:,15)={0}; %%azzero la colonna select
StratList=app.MyTable; %sono i dati
save(sav,'StratList');
fprintf("Salvato i dati nella lista : %s \n",sav);
answer=msgbox("Strategia Salvata");
end
app.SaveAsButton.Visible="off";
app.SaveButton.Visible="off";
end
i want in Nome File write a name which is not on the list (but I want him to suggest it to me)
Example:

回答 (1 件)

John D'Errico
John D'Errico 2023 年 11 月 25 日
Asking a computer to suggest a name is impossible. It cannot know what name might be appropriate, and more importantly, what you think is appropriate.
However, you can just generate a random string of letters, and even numbers. As long or short as you like. Then test to see if that name (unlikely as it might be) is already in use. If it is, then just generate a new string, until you find one that is not already taken. The problem is, this will result in a list of names that are a complete mess in your directories. I doubt you will be happy.
Alternatively, you could just choose the name "untitled" (or something like that), followed by a number. If that name is already taken, then increase the number you will append, until it finds a name that is not in use.
  5 件のコメント
Stephen23
Stephen23 2023 年 11 月 25 日
@John D'Errico: it is still not clear to me what the OP wants.
Luca Re
Luca Re 2023 年 11 月 25 日
編集済み: Luca Re 2023 年 11 月 25 日
I expressed myself badly.. I want to write "Aggreg_" in the name.. then it will be my job to complete it

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by