Quicktest - one size does not fit all?


#1

(Sorry everyone, I realise I’m getting spammy asking for help.)

Assuming ‘variable’ is set as “12” in a notional external file (scene_file_1), does Quicktest test the next scene file (notional scene_file_2) by testing the code in the *if section below using a 1 character length variable?

*temp variable_length length(variable)
*if variable_length = 2
  *set file ({variable#1}&{variable#2})
  *goto_scene {file}

Resulting in:
QUICKTEST FAILED
Error: line 3: There is no character at position -1; the position must be greater than or equal to 1.


#2

Does it work if you play through the game? If not then it probably is a real game breaking error. I personally do simple coding, but I would change it to this

*temp variable_length length(variable)
*if (variable_length=2)
    *set file {variable#1}&{variable#2}
    *goto_scene {file}

Maybe that would work? I don’t know how you usually code, but that is how I would do it. Otherwise look at this

https://retowers.neocities.org/CSGuide/CSGuide.html


#3

I’m not an expert with using an # in code for variables, but move *set before *if and try it.

*temp variable_length length(variable)
*set file ({variable#1}&{variable#2})
*if variable_length = 2
  *goto_scene {file}

If that works and you only want to set file if variable = 2, you will need a workaround. Quicktest is buggy with *if using advanced code.


#4

Thanks @Arasia_Valentia and @JimD for taking the time to have a look at my problem.

Yes, it does :slight_smile:

Thanks, I’ve reformatted to try your suggestion, but my error persists!

I appreciate the link - there’s some stuff in here I hadn’t spotted on the forum or wiki yet. I very much look forward to @RETowers section: Automatic Testing and Commands (*bug, choice_randomtest) (TODO)

Also doesn’t work :confounded: but thank you, an interesting suggestion.

I don’t know if there is a semi-official repository for quicktest bugs? Its partly addressed on the COG site and a little in the wiki, but maybe I’ve missed a list somewhere


#5

Then you have to simplify code to get it to pass QT. Keep simplifying until it passes.

*temp variable_length length(variable)
*temp first_letter "a"
*temp second_letter "b"
*if variable_length = 2
  *set first_letter {variable#1}
  *set second_letter {variable#2}
  *set file first_letter&second_letter
  *goto_scene {file}

Not that I know of :frowning:

Most people don’t even use these features.


#6

Okay, I think you’re adding unnecessary signs. The proper place to extract character n from a variable is foo#n not {foo#n}. i.e. Your code should be (unless I’m missing something else):

*if length(variable) = 2
  *set file ((variable#1)&(variable#2))
  *goto_scene {file}

#7

It is now passing Quicktest!

Thank you @Arasia_Valentia, @JimD and @RETowers :bouquet: