Author Topic: READLN problem (variable not remembered for auto reinstallation)  (Read 1074 times)

Offline K4thos

  • Planewalker
  • *****
  • Posts: 110
According to weidu documentation ACTION_READLN works like this
Quote
Waits for the user to provided an enter-terminated string and store it in variable. Said string will be stored and re-used at reinstall time. See the READLN tutorial.

The bolded part doesn't seem to work unless I missed something. Here is a test code:

Code: [Select]
BACKUP ~test/backup~
AUTHOR ~K4thos~

BEGIN ~component 1~

BEGIN ~component 2~

ACTION_IF NOT VARIABLE_IS_SET var BEGIN
PRINT ~var not set~
END

OUTER_WHILE (NOT VARIABLE_IS_SET var) OR (NOT IS_AN_INT var) OR (var < 1) BEGIN
PRINT ~Type test~
ACTION_READLN var
END
PRINT ~var set to %var%~
Repo steps:
1. Install component 1
2. Install component 2 (you will see "var not set" message and will be asked to type in an iteger that will be stored via ACTION_READLN into 'var' variable)
3. Run the installer again and this time choose to re-install component 1
4. When the second component shows up press either 'q' or 'n'

The result is that the second component once again prints "var not set" and asks for typing in variable via ACTION_READLN even though it should not be needed since the component is reinstalled automatically by weidu.

I've checked READLN.1 file in backup directory and it has some nonsense rather than variable name:
Code: [Select]
„•¦ľ                #666@READLN.1.TEXT file on the other hand has correct value stored:
Code: [Select]
~~~~~666~~~~~Any idea what is wrong in my test code? If the function is not meant to remember variable name than how else the value could be used during reinstallation?
« Last Edit: February 08, 2017, 11:06:47 AM by K4thos »

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: READLN problem (variable not remembered for auto reinstallation)
« Reply #1 on: February 08, 2017, 01:52:07 PM »
Perhaps the documentation could be clearer, but "reinstall time" refers to stack operations. If you reinstall component 1 while component 2 is still installed, component 2 will be reinstalled with the old value for the READLN var without prompting the user again. If you [R]e-install component 2 you are deliberately prompted for the READLN var because you might be reinstalling component 2 because you want to enter a different value.

The "nonsense" in readln.1 is because it's a binary file.
« Last Edit: February 08, 2017, 01:53:09 PM by Wisp »

Offline K4thos

  • Planewalker
  • *****
  • Posts: 110
Re: READLN problem (variable not remembered for auto reinstallation)
« Reply #2 on: February 08, 2017, 04:39:23 PM »
Correct me if I'm wrong but what you said seems to be exactly what I try to achieve:
Quote
If you reinstall component 1 while component 2 is still installed, component 2 will be reinstalled with the old value for the READLN var without prompting the user again
This is not the case (at least with the test code I've posted). As I mentioned in repo steps I did just that - reinstall ONLY component 1 hoping that component 2 will automatically get that value and install correctly again (because weidu automatically uninstalls all previous components as part of normal weidu re-installing procedure). And it didn't happen - weidu prompted to type in the value again even though I did not choose to reinstall component 2.
Quote
If you [R]e-install component 2 you are deliberately prompted for the READLN var because you might be reinstalling component 2 because you want to enter a different value.
I'm not talking about [R]. The problem happens when either [N]o or [Q]uite is pressed when the weidu asks if you want to reinstall component 2, when you previously re-installed component 1.
« Last Edit: February 09, 2017, 04:10:11 AM by K4thos »

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: READLN problem (variable not remembered for auto reinstallation)
« Reply #3 on: February 09, 2017, 12:03:18 PM »
I misremembered. Old READLN values are reused when the variable INTERACTIVE is 0, which happens when your mod is being reinstalled because of some other mod.

Offline K4thos

  • Planewalker
  • *****
  • Posts: 110
Re: READLN problem (variable not remembered for auto reinstallation)
« Reply #4 on: February 09, 2017, 04:05:38 PM »
Is there any practical reason why auto re-installation within the same mod is considered INTERACTIVE when [R]einstallation option is not chosen? If this is not going to be changed in future I'd like to request additional new special variable that would be set if the current re-installation process is done automatically. With such variable it won't be hard to code workaround locally to get the READLN value (saved in external file). Without it I can't really think about any way to handle this task considering both INTERACTIVE variable and AT_INTERACTIVE_UNINSTALL behaves the same way regardless if the code is re-installed manually or as domino uninstall and reinstall after reinstalling/uninstalling earlier component from the same mod.

Thanks in advance.
« Last Edit: February 09, 2017, 07:13:47 PM by K4thos »

Offline Wisp

  • Moderator
  • Planewalker
  • *****
  • Posts: 1176
Re: READLN problem (variable not remembered for auto reinstallation)
« Reply #5 on: February 11, 2017, 04:02:33 PM »
I'm pretty sure it's in some holy book or other that thou shalt do no work on READLN or its damned ilk. I do not wish to venture into those maddening depths, not unless my mission is to drive a stake through interactive WeiDU's unholy heart and cleanse that evil with fire.

On a more serious note, I'd not invest in READLN. Its value is probable to sharply decrease in the mid- to long-term. Find some other way of getting the info from the user. I forwarded something here, but the implementation is being postponed for now, as I realised it was a bit of putting the cart before the horse.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: