sc-im icon indicating copy to clipboard operation
sc-im copied to clipboard

Value of string expression disappeared everytime opening the documents

Open amalgame21 opened this issue 3 years ago • 10 comments

To reproduce:

In the sc-im tutorial "Lesson12_String_Functions.sc" Completed the lesson, save the file Press :q<Enter> to close the sc-im reopen the "Lesson12_String_Functions.sc" with sc-im again all the string expression value is lost.

but the string expression is still exist in those cells you need to go to every single cell, press e/E and hit enter to display the value of string expression

amalgame21 avatar Jan 12 '22 10:01 amalgame21

Hello. Will check it out next week.

andmarti1424 avatar Jan 13 '22 12:01 andmarti1424

Thank you very much!

amalgame21 avatar Jan 19 '22 09:01 amalgame21

A simple example:

# This data file was generated by the Spreadsheet Calculator Improvised (scim)
# You almost certainly shouldn't edit it.

set external_functions
newsheet "Sheet1"
movetosheet "Sheet1"
offscr_sc_cols 0
offscr_sc_rows 0
nb_frozen_rows 0
nb_frozen_cols 0
nb_frozen_screenrows 0
nb_frozen_screencols 0
format B 45 2 0
format C 30 2 0
leftstring A0 = "London"
leftstring B0 = "curl -s wttr.in/"#A0#"?format=+%c%t+%h+%w #"
leftstring C0 = @ext(B0,0)
goto C0

In A0 we place a city name. Then, in B0, we concatenate A0 with some predefined strings to produce a certain shell command. And then, in C0, we call the string function @ext, passing to it this constructed command.

Now, if we open this sheet, B0 will be empty, and the function in C0 will fail because of that. But if we'll go to B0, press E<CR>, and then do the same with C0, the results will magically appear :)

Of course, we can skip the concatenation step, I did it just for the clarity, and use this:

format D 30 2 0
leftstring D0 = @ext("curl -s wttr.in/"#A0#"?format=+%c%t+%h+%w #",0)

However, if we open this sheet, D0 will simply be empty -- until we do E<CR> on it, forcing the concatenation/function call to actually run :)

(On a side note, hell, sc-im is really powerful, and you don't even need lua for that :)

097115 avatar Jan 21 '22 07:01 097115

@amalgame21 Please update to latest commit on dev branch and retry.

andmarti1424 avatar Feb 02 '22 14:02 andmarti1424

Don't know if I'm missing the point but let's say we have this simple sc-im file:

# This data file was generated by the Spreadsheet Calculator Improvised (scim)
# You almost certainly shouldn't edit it.

set external_functions
newsheet "Sheet1"
movetosheet "Sheet1"
offscr_sc_cols 0
offscr_sc_rows 0
nb_frozen_rows 0
nb_frozen_cols 0
nb_frozen_screenrows 0
nb_frozen_screencols 0
format A 30 2 0
label A0 = @ext("ls -1 | head -n1 #",1)
goto A0

Then, if we open it with sc-im, it reports Running external function..., but the cell still shows empty until re-evaluating it with E<CR>(dev branch, ab0eae9 commit).

097115 avatar Feb 02 '22 14:02 097115

That seems a different problem and has to do with the @ext function particularly. To be sure.. If you change the @ext function to another does it refresh ok?

andmarti1424 avatar Feb 02 '22 14:02 andmarti1424

@andmarti1424

Sorry, was wrong :) The correct answer is not always :)

With this test file:

# This data file was generated by the Spreadsheet Calculator Improvised (scim)
# You almost certainly shouldn't edit it.

set external_functions
newsheet "Sheet1"
movetosheet "Sheet1"
offscr_sc_cols 0
offscr_sc_rows 0
nb_frozen_rows 0
nb_frozen_cols 0
nb_frozen_screenrows 0
nb_frozen_screencols 0
label A0 = @replace("foo","foo","bar")
label B0 = @capital("foo")
label C0 = @capital(A0)
goto B0

A0 and B0 indeed are shown on startup, while C0 isn't (but again, C0 is a bit different story, as I understand?)

097115 avatar Feb 02 '22 15:02 097115

Please update again to latest commit on dev branch and retry. Thanks.

andmarti1424 avatar Feb 02 '22 15:02 andmarti1424

@andmarti1424 Confirm, all three are shown (and @ext works, too).

You are a hero, thanks! :)

097115 avatar Feb 02 '22 15:02 097115

Will leave this open for some time though

andmarti1424 avatar Feb 02 '22 15:02 andmarti1424