Parse Variable - Forum

Forum Navigation
You need to log in to create posts and topics.

Parse Variable

Hello All,

Coming from VisualNeo Win and trying to understand.

Have a variable called [imagesNames]; this variable contains for example:

Pak Choy Mini Hok Du_1.jpg,Pak Choy Mini Hok Du_2.jpg,Pak Choy Mini Hok Du_3.jpg,Pak Choy Mini Hok Du_4.jpg,Pak Choy Mini Hok Du_5.jpg

Now I need to write to a MySql database each image name:

$sqlAlias[6]="addimages";
$sqlQuerys[6]="INSERT INTO myflora_repeat_images (parent_id, images) VALUES (?,?)";
$sqlMaxUserLevel[6]=0;

My thought was that the variable [imagesNames] will work as a array and loop trough:

Loop 0 [imagecount] [image_no]
neoPhpExecSql "flora" "addimages" "[id]::[imagesNames([image_no])]" ""
EndLoop

But this doesn't work??? Tried already for several hours but no result. Yet the old way of NeoBook thinking I think ;-)

I want to implement in my Seed/Flora database application a possibility to add images of the plants. Using for this the acImageUploader plugin from Asley Cruz.
The plugin on is self works perfect, and gives back the above variable with the uploaded image names.

Thanks a lot everyone,

Best regards,

 

Eric

 

 

 

 

 

Hello @ebear, and welcome to VisualNEO Web! It's great that you're diving in from VisualNeo Win. You're right that the approach here requires a slightly different syntax and method than you're used to from NeoBook days.

Issue Summary:

You're trying to loop through a comma-separated list of image names ([imagesNames]) and insert each one into a MySQL table using a loop, but [imagesNames([image_no])] isn't functioning as expected.

Why It Doesn't Work:

In VisualNEO Web, arrays and string handling work differently than NeoBook. [imagesNames] is just a string. It doesn't automatically behave like an array unless you split it manually into an array.

Solution Approach:

You need to split the string [imagesNames] into a proper array and then loop through the array items.

Here’s a step-by-step method:

  1. Split your string into an array:

    StrParse "[imagesNames]" "," [imagesArray]
  2. Get array length:

    ArrayLength [imagesArray] [imagecount]
  3. Loop through and insert:

    Loop 0 [imagecount] [image_no]
    ArrayItem [imagesArray] [image_no] [singleImageName]
    neoPhpExecSql "flora" "addimages" "[id]::[singleImageName]" ""
    EndLoop

This way, [imagesArray] holds each image name, and you insert them one by one into your MySQL database.

Explanation:

  • StrParse breaks the string into array elements.

  • ArrayItem gets the specific element at index [image_no].

  • neoPhpExecSql sends the ID and the current image name to the SQL query.

Hello Luis,

First of all thanks a lot for your reaction. As you know I already own and updated VisualNeo Web for a long time, but due to our family situation I didn't had the time to really start with exploring it. Im also a gardening lover, we have around 4000 m2 land around our house and we grow all our vegetables, fruits and herbs our self. Now I have a enormous collection of seeds (more then we grow) and I already walked a long time with the idea to create an application where I can store all the data of the seeds, plants etc. I have many ideas with it. I didn't want to start again with a Windows application so I thought this is the time to switch to Web Based. I have many applications running as Windows applications, on of the bigger is the HealthCare application we use for our Son.

With becoming more experienced with VisualNeo Web, the idea is to convert all the apps I wrote in the past to Web Based.

Two issues I found in the answer from you above:

  1. I think that "ArrayLength" should be "ArrayLen" ?
  2. The action "ArrayItem" seems not to exist, did you make a mistake or Im I missing something?

Otherwise you answer is clear, I had already an idea that it had to be something like this, but I could not find the answer.

Thanks a lot, probably I will have some more questions in the future went the forum or help doesn't give the right answer.

 

Regards,

 

Eric

 

 

 

 

Hi Eric (@ebear)

You are right. I used our public VisualNEO Web GPT and did a quick look. It seemed ok, but included some hallucinations.

It's ArrayLen and not ArrayLength. Note that this is correct too:

SetVar [imagecount] [imagesArray.length]

This is the correct Loop:

Loop 0 [imagecount] [image_no]
  SetVar [singleImageName] [imagesArray([image_no])]
  neoPhpExecSql "flora" "addimages" "[id]::[singleImageName]" ""
EndLoop

Important: neoPhpExecSql use async calls.
This means it's not a good idea using this command within a loop.

Use this approach instead:

Step 1: Parse the image names into an array.

StrParse "[imagesNames]" "," [imagesArray]
SetVar [imagecount] [imagesArray.length]
SetVar [imageIndex] 0
handleNextImageInsert

Step 2: Last line is for calling a subroutine whose name is handleNextImageInsert with this code:

If [imageIndex] < [imagecount]
    SetVar [singleImageName] [imagesArray([imageIndex])]
    neoPhpExecSql "flora" "addimages" "[id]::[singleImageName]" "handleNextImageInsert"
    Math "[imageIndex]+1" "0" [imageIndex]
EndIf

Step 3: Start the first insert calling the subroutine:

handleNextImageInsert

I think this should work better.
Let me know if you need addional information.
By the way, your project seems really interesting!

Hello Luis,

Above works perfect, thanks a lot. Now looking into convert images before upload (resizing, compressing, converting to other format e.g.. jpg etc.).

The project will be when ready quit complex:

Currently I have online a Joomla website where I use Fabrik as database management, but I would like to have more possibilities and custom development.

See my website: https://beerhorst.eu/

The online Database in the above website is connected to the VisualNeo Web project, so updates etc via Fabrik and the VisualNeo Project are both ways.
The Visual Neo Project is yet local (except the used database). When online I will update to give the Forum access...

This project, is as you know my first project in VisualNeo Web, and it is a good learning process for the conversion of my other and future applications.

Thanks a lot for your always great support.

 

Best regards,

Eric

 

 

Vadim has reacted to this post.
Vadim

@ebear I do really like your project!
I have a 1000 m2 garden and I'm personally interested in following your steps :)
Please keep us updated on its development.

Thank you!

Aha Luis, so also gardening nice....

Main thing I have to solve is the implementation of the Niimbot printer, as I use this printer to print labels for the seed containers, plant labels etc. I don't want to manually create the labels but to select the plant in the database and press print. These labels contain the plant name item number and a QR code. Currently I'm working on the QR code scan in the Project to search and show the information about the plant. The idea is when in the garden you can scan the plant label with you phone and the information (including sowing date etc.) will be shown on the phone.

When you already had a look on my website you see in the Database currently around 180 vegetables, fruits and Herbs. I'm cataloging my collection and I think (not complete sure) I have till now only 1/3 in the Database  online.... Lots of work but I love it.... We now already don't buy any vegetables everything we have is self grown.

As I already wrote before I will make the app Public on internet as soon as I have the main "public: things running.

Regards,

 

Eric

luishp and Vadim have reacted to this post.
luishpVadim

Test web app...

Took some time to get finally something online... Today I uploaded the first testing webapp created with VisualNeo Web. See also above...
The new Flora database is not yet finished, but I also linked the old database....

Take a look, and please shoot at me... Im just starting to migrate from VisualNeo Win to Web....

http://resp.beerhorst.eu

Have a nice evening,

Eric

Ps. the background image is from the area we live...

 

 

luishp and Phil78 have reacted to this post.
luishpPhil78