Need help about place blocks for matching?

Hi all.
as the picture attached, I need to place: call Base64Convertor1.FileToBase64Direct into the if-then block, the 'if' need a condation, 'then' don't have a nest to hold it, how should I do it?
thanks.

nest11

  1. Where are trying to use this condition?
  2. How do you get the file?
  3. By download or upload?

May be try like this if possible

if hasFilepath = true then
    call Base64Converter1.FileToBase64Direct
else
    call Base64Converter1.FileToBase64
end if
1 Like

What's this Base64Convertor component?

Where did you get it?

and what logical true/false condition did you want to test?

1 Like

thanks.
this is a general question, I met this situation often, and don't know how to deal with.
just like your code:

if hasFilepath = true then
    call Base64Converter1.FileToBase64Direct

how to place a 'Base64Converter1.FileToBase64Direct' with wedge into if-then?

thanks.
specifically, I uploaded a jpg picture into APP say dog.jpg, and I like to Base64Convert it:

  1. what's the difference between Base64Converter1.FileToBase64Direct and Base64Converter1.FileToBase64?

  2. whatever the logical true/false condition is, can't fit a 'Base64Converter1.FileToBase64Direct' in?

  3. I did it this way: set global.Base64String to call Base64Converter1.FileToBase64Direct file: global image, can't sure if it is a appropriate treatment method.

Just now read the code of the extension and i feel the develper @TIMAI2 may decide like this to do..

Differences between FileToBase64 and FileToBase64Direct

  1. Return Type and Event Handling:
  • FileToBase64:
    • This method does not return the Base64 string directly. Instead, it triggers an event named AfterBase64Created with the Base64 string as an argument.
    • This is useful if you want to handle the result asynchronously or if you need to perform additional operations after the conversion is complete.
  • FileToBase64Direct:
    • This method returns the Base64 string directly.
    • Use this method if you want to get the Base64 string immediately and handle it in the same block of code.
  1. Usage Context:
  • Use FileToBase64 when you want to decouple the conversion process from the handling of the result. This can be useful in more complex applications where you need to perform multiple operations in sequence.
  • Use FileToBase64Direct when you want a straightforward conversion and immediate access to the result.

How to Use in App

To use these methods, you would typically follow these steps:
Using FileToBase64:

  • Drag and drop the Base64Convertor component onto your screen from the palette.
  • Use the FileToBase64 method in your blocks code. You will need to specify the file path as an argument.
  • Set up an event handler for the AfterBase64Created event to handle the Base64 string once it is generated.

Example in Blocks:

when Button1.Click do
  call Base64Convertor1.FileToBase64 with filePath "/path/to/your/file"
end

when Base64Convertor1.AfterBase64Created with base64String do
  // Handle the Base64 string here
  set Label1.Text to base64String
end

Using FileToBase64Direct:

  • Similarly, drag and drop the Base64Convertor component onto your screen.
  • Use the FileToBase64Direct method in your blocks code and specify the file path as an argument.
  • The method will return the Base64 string directly, which you can then use immediately.

Example in Blocks:

when Button1.Click do
  set base64String to call Base64Convertor1.FileToBase64Direct with filePath "/path/to/your/file"
  set Label1.Text to base64String
end

And i conclude that.,

  • FileToBase64 is used for asynchronous handling and event-driven programming.
  • FileToBase64Direct is used for immediate, synchronous access to the Base64 string.

For me, my extension appears to have stopped working, for some unknown reason. It may be working for you ?

EDIT - ignore, using a different version that was only for testing

Here, using blocks, with a file from assets:
(I show the first 50 characters of the base64 string in the labels)

Direct:

With Event:

Screen:

image