Convert string // преобразовать строку

is it possible to convert a string into executable code in a program ?
можно ли в программе преобразовать строку в исполняемый код ?

Could you explain it in more detail?

I want to write the components of the For and While loops, I will access the component and fill it with the necessary data

Я хочу написать компоненты циклов For и While, я буду обращаться к компоненту и заполнять его необходимыми данными

import QtQuick 2.9

Item {
    id: forMain // идентификатор
    property int minCount: contentUi.getValueByKey("Min_Count") // получить минимальное значение
    property int maxCount: contentUi.getValueByKey("Max_Count") // получить максимальное значение
	//************
	property string begin: contentUi.getValueByKey("begin") // получить тело цикла
    //*************
    Component.onCompleted: { 
    for ( var i = minCount; i <= maxCount; i++) {
        //begin
        }
    }
    
}

For.pma (17.6 KB)

You can use the JavaScript eval function for this eval() - JavaScript | MDN

image

Warning: Executing JavaScript from a string is an enormous security risk. It is far too easy for a bad actor to run arbitrary code when you use eval() .

Thank you! Спасибо! :grinning:


Back to Flipabit >
Copyright © 2018. Flipabit Team. All rights reserved.